scala - Executing sbt in command line via python script and outputting to file -


i have set of json files in directory /desktop/jsons, , have scala script takes in json , outputs stuff. can run manually in terminal cding directory of scala script (/me/dev/scalastuff) , running

sbt --error "run /desktop/jsons/jsonexample.json",

which outputs stuff want in terminal.

i want write python script automatically , additionally outputs json file "stuff" thats outputted scala script.

my issues right using subprocessing. when try run

basedir = '/me/dev/scalastuff' p = subprocess.popen(['sbt --error "run /desktop/jsons/jsonexample.json"'], cwd = basedir, stdout = subprocess.pipe) out = p.stdout.read() print out

i oserror: [errno 2] no such file or directory.

i'm stumped why occurring. i'm new subprocess, light on me!

popen in python takes list of shell arguments. you're passing one!

so it's trying execute file named wholly 'sbt --error "run /me/desktop/jsons/jsonexample.json"'.

obviously, doesn't work.

if use popen; pass simple array -- needn't care escaping:

subprocess.popen(['sbt', '--error', 'run /me/desktop/...'], cwd = basedir, stdout = subprocess.pipe) 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -