← Back to team overview

sikuli-driver team mailing list archive

[Bug 1304366] Re: Unable to run .exe file with environment variable

 

With shell=True, on Windows the given command string is given to
CMD.EXE, which expects the string to be an executable command and be
quoted according to the rules of CMD.EXE.

If the executable filename contains special characters, that have a
meaning when parsing a command line - like your (  ... ) - then the
complete command has to be in double-double-quotes:

subprocess.call('""%MyApp%""', shell = True)

... but IMHO this should work also:

subprocess.call(os.environ["MYAPP"])

-- 
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/1304366

Title:
  Unable to run .exe file with environment variable

Status in Sikuli:
  Invalid

Bug description:
  Hi RaiMan,

  I wrote a new version of my previous bug. This time I don't use the
  os.environ but subprocess.call.

  Thanks! I very much appreciate your helpfulness in this forum.

  I don't want to hard code the path to the .exe file I want to test in my .sikuli file. Our scheduler will run the .exe file through the settings of environment variables, without hard coding.
  And we don't want to change the path setting, but only run through an environment variable. 
  I wrote the following  script, it works on python but not on sikuli. Would you have any alternatives\workarounds?

  #MyApp environment variable is created in system in variables under System\Advanced Settings
  # My file path is: C:\2014-03-07(20h30)\bin\MyApp.exe
  #We can run the following script on Python, it's OK
  #We can also run "%MyApp%" on command prompt, it's OK. 

  from sikuli import*
  import os, sys
  import subprocess

  os.system('echo %MyApp%')  #We have the path to environment variable. [GOOD]
  subprocess.call('"%MyApp%"', shell = True) #But we can't run it [BAD]

  We have the following error message (not pasted the whole message):

  'C:\2014-03-07' is not recognized as an internal or external command,
  operable program or batch file.
  Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
  at javax.swing.text.FlowView$FlowStrategy.layoutRow(Unknown Source)
  at javax.swing.text.FlowView$FlowStrategy.layout(Unknown Source)
  at javax.swing.text.FlowView.layout(Unknown Source)
  at javax.swing.text.BoxView.setSize(Unknown Source)
  at javax.swing.text.BoxView.updateChildSizes(Unknown Source)
  at javax.swing.text.BoxView.setSpanOnAxis(Unknown Source)
  at javax.swing.text.BoxView.layout(Unknown Source)
  at javax.swing.text.BoxView.setSize(Unknown Source)
  at javax.swing.text.BoxView.updateChildSizes(Unknown Source)
  at javax.swing.text.BoxView.setSpanOnAxis(Unknown Source)
  at javax.swing.text.BoxView.layout(Unknown Source)
  at javax.swing.text.BoxView.setSize(Unknown Source)
  at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(Unknown Source)
  at javax.swing.plaf.basic.BasicTextUI.modelToView(Unknown Source)
  at

To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1304366/+subscriptions


References