i am trying to run a python code, which calls the check_output() function for maven commands.
The first 'mvn clean test' works fine, but then i got stuck in an Error for the second mvn command, where it says:
File ~\Documents\PowerTac\powertac\powertac-tools\python-scripts\test_Extractor.py:29 in <module>
print(subprocess.check_output(['mvn', 'exec:exec', '-Dexec.args='+ args],
File ~\Anaconda3\envs\env_cirebro\lib\subprocess.py:415 in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File ~\Anaconda3\envs\env_cirebro\lib\subprocess.py:516 in run
raise CalledProcessError(retcode, process.args,
CalledProcessError: Command '['mvn', 'exec:exec', '-Dexec.args="org.powertac.logtool.example.MktPriceStats D:/Powertac/finals-2021/3/finals_2021_3.tar.gz D:/Powertac/finals-2021/data/mktPr3.csv"']' returned non-zero exit status 255.
My code looks like this:
import os, subprocess
processEnv = {'JAVA_HOME': os.environ.get('JAVA_HOME'),
'Path' : os.environ.get('PATH')}
logtoolDir = 'C:/Users/phili/Documents/PowerTac/powertac/powertac-tools/logtool-examples/'
logtoolDir = logtoolDir.replace(os.sep, '/')
args = r'"org.powertac.logtool.example.MktPriceStats D:/Powertac/finals-2021/3/finals_2021_3.tar.gz D:/Powertac/finals-2021/data/mktPr3.csv"'
extractorClass = 'MktPriceStats'
tarPath ='D:/Powertac/finals-2021/3/finals_2021_3.tar.gz'
dataDir = 'D:/Powertac/finals-2021/data'
datafileName = 'mktPr3.csv'
args = ''.join(['"org.powertac.logtool.example.' + extractorClass, ' ',
tarPath, ' ',
dataDir + "/" + datafileName + '"'])
print('mvn', 'exec:exec', '-Dexec.args='+ args)
print(subprocess.check_output(['mvn', 'clean', 'test'],
shell = True, env = processEnv, cwd = logtoolDir))
print(subprocess.check_output(['mvn', 'exec:exec', '-Dexec.args='+ args],
shell = True, env = processEnv, cwd = logtoolDir))
I assume that somehow the 'shell=True' is hiding that the command is not correct.
When I type in the command-string that was produced by my code into the cmd, everthing works. Maybe even my env varibales are set wrong.
Does anyone have a suggestion how i can solve it?
Thanks.