简体   繁体   中英

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'])

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')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM