Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python subprocess.call with cwd not working

I have tried various things, none work. Here are my attempts:

subprocess.call(['cordova-test android tests --app platforms/android/build/outputs/apk/android-debug.apk --device-name=emulator-5554 --no-compile'],
      cwd = ['/Users/User/Documents/dev/engineerappcopy'], shell = True)

next

subprocess.call(['cordova-test android tests --app platforms/android/build/outputs/apk/android-debug.apk --device-name=emulator-5554 --no-compile'],
       cwd = shlex.split(['/Users/User/Documents/dev/engineerappcopy'])

next

subprocess.call(['cordova-test android tests --app platforms/android/build/outputs/apk/android-debug.apk --device-name=emulator-5554 --no-compile'],
       cwd = ['/Users/User/Documents/dev/engineerappcopy'])
like image 927
Josh Bloom Avatar asked Apr 26 '17 20:04

Josh Bloom


1 Answers

First, argument line must be a string (with spaces, optionally) or a list of the arguments, but not the command line as sole argument.

Then, current working directory must be a string, not a list.

Try this:

subprocess.call(['cordova-test','android','tests','--app','platforms/android/build/outputs/apk/android-debug.apk','--device-name=emulator-5554','--no-compile'],
       cwd = '/Users/User/Documents/dev/engineerappcopy')
like image 170
Jean-François Fabre Avatar answered Oct 15 '22 15:10

Jean-François Fabre