I made a python script to run sen2cor on a Virtual Machine (Linux). If I want to run it from the terminal I first need to call “source /home//sen2cor/L2A_Bashrc” and afterward “python run_sen2cor.py”.
Is it possible to implement command prompt into a python script? I tried:
Traceback (most recent call last):
File "/home/pi/anaconda2/bin/L2A_Process", line 9, in <module>
load_entry_point('sen2cor==2.0.6', 'console_scripts', 'L2A_Process')()
File "/home/pi/anaconda2/lib/python2.7/site-packages/sen2cor-2.0.6-py2.7.egg/sen2cor/L2A_Process.py", line 237, in main
processor = L2A_Process(directory)
File "/home/pi/anaconda2/lib/python2.7/site-packages/sen2cor-2.0.6-py2.7.egg/sen2cor/L2A_Process.py", line 21, in __init__
self._config = L2A_Config(workdir)
File "/home/pi/anaconda2/lib/python2.7/site-packages/sen2cor-2.0.6-py2.7.egg/sen2cor/L2A_Config.py", line 27, in __init__
self._home = os.environ['SEN2COR_HOME'] + '/'
File "/home/pi/anaconda2/lib/python2.7/UserDict.py", line 40, in __getitem__
raise KeyError(key)
KeyError: 'SEN2COR_HOME'
prod_path = "path/to/your/product. SAFE"
p = subprocess.Popen(["L2A_Process {0} --resolution=10".format(prod_path)],
shell=True, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
# Display output in console
for line in iter(p.stdout.readline, ''):
print line[:-1] # The -1 is just to remove the \n at the end of every line
I think there is a better way, using something like boa_product = GPF.createProduct('Sen2Cor', params, product)
but I have not managed to get that to work. (Should be possible though, as running gpt -h shows that there exists a Sen2Cor Operator)
As @marpet and @antonio19812 told me in this conversation Sen2Cor and Snappy the GPF.createProduct(‘Sen2Cor’,…) command is not working yet and we hope that the problem will be solved soon.