An indirect calling of a draw.io command prompt leads to calling nodejs

95 views Asked by At

Background: I want to embed the .csv to drawio-xml conversion into my work flow by calling the cmd prompt draw.io -x input.csv -o output.xml indirectly (e.g. by autohotkey or in a jupyter cell). But I'm getting the error "bad option -x". First I tried adding draw.io to system variable Path and switched over to absolute pathes, but it didn't help. Neither did a prior cd to the working directory. Then I found out, via the -h option, that the origin of the error is that nodejs is called instead of draw.io. To keep the examples simple, I switch thus over to just calling the -h option.

I created a .bat file having the following content:

draw.io -h
pause

If I run the .bat file via mouse click or cmd prompt, I get the help print of draw.io. However, if I run the .bat file indirectly via autohotkey or via a python jupyter cell within vs code, I get the help print from nodejs.

python script:

import subprocess as sp
p = sp.run(r'C:\tools\python_projects\eigene\db_viewer\drawio.bat', capture_output=True)
print('exit status:', p.returncode)
print('stdout:', p.stdout.decode())
print('stderr:', p.stderr.decode())

autohotkey script: ^ยด:: run C:/tools/python_projects/eigene/db_viewer/drawio.bat

I get the same results when using a .py file instead of a .bat file.

drawio-test.py file content:

import subprocess as sp
p = sp.run('draw.io -h', capture_output=True, shell=True)
print('stdout:', p.stdout.decode())

In the following screenshot you can see how calling the file via command prompt by python drawio-test.py prints the drawio help (yellow markings), but calling the same via a jupyter cell prints the nodejs help (red markings).

What is going on here?


windows 10, python 3.11, drawio 21.2.8

0

There are 0 answers