Reputation: 727
Below is my code. It works when calling in terminal but does not work from a python 2.7 script.
/usr/bin/python3.5 /var/www/html/web_map/simplemap/resources/py/align_raster.py
/mnt/13aa104a-192c-43e5-95af-68aba6ac57a9/temp/85a0b2f9-c3fb-4913-9d70-a0c49f3649ba/chlor_a-modis-aqua-01_2013.tif,
/mnt/13aa104a-192c-43e5-95af-68aba6ac57a9/temp/85a0b2f9-c3fb-4913-9d70-a0c49f3649ba/chlor_a-modis-aqua-02_2013.tif,
/mnt/13aa104a-192c-43e5-95af-68aba6ac57a9/temp/85a0b2f9-c3fb-4913-9d70-a0c49f3649ba/chlor_a-modis-aqua-03_2013.tif,
/mnt/13aa104a-192c-43e5-95af-68aba6ac57a9/temp/85a0b2f9-c3fb-4913-9d70-a0c49f3649ba/chlor_a-modis-aqua-04_2013.tif,
/mnt/13aa104a-192c-43e5-95af-68aba6ac57a9/temp/85a0b2f9-c3fb-4913-9d70-a0c49f3649ba/chlor_a-modis-aqua-05_2013.tif,
/mnt/13aa104a-192c-43e5-95af-68aba6ac57a9/temp/85a0b2f9-c3fb-4913-9d70-a0c49f3649ba/chlor_a-modis-aqua-06_2013.tif,
/mnt/13aa104a-192c-43e5-95af-68aba6ac57a9/temp/85a0b2f9-c3fb-4913-9d70-a0c49f3649ba/chlor_a-modis-aqua-07_2013.tif,
/mnt/13aa104a-192c-43e5-95af-68aba6ac57a9/temp/85a0b2f9-c3fb-4913-9d70-a0c49f3649ba/chlor_a-modis-aqua-08_2013.tif,
/mnt/13aa104a-192c-43e5-95af-68aba6ac57a9/temp/85a0b2f9-c3fb-4913-9d70-a0c49f3649ba/chlor_a-modis-aqua-09_2013.tif,
/mnt/13aa104a-192c-43e5-95af-68aba6ac57a9/temp/85a0b2f9-c3fb-4913-9d70-a0c49f3649ba/chlor_a-modis-aqua-10_2013.tif,
/mnt/13aa104a-192c-43e5-95af-68aba6ac57a9/temp/85a0b2f9-c3fb-4913-9d70-a0c49f3649ba/chlor_a-modis-aqua-11_2013.tif
_aligned.tif
This is the output in terminal.
Segmentation fault (core dumped)
That is a QGIS python standalone script. It always shows that error but the file processes whatever is required.
This is not working.
cmd = '/usr/bin/python3.5 /var/www/html/web_map/simplemap/resources/py/align_raster.py {} {}'.format(
output_files_string, output_suffix
)
print(cmd)
result = call(cmd.split(), shell=False)
I also tried shell=True
,
It coulld be caused by the code dump but is there a way to trick python that the file is fine?
Edit: the code dump is fixed with this solution.
Edit2: I think this issue is related with Apache CGI Python. As it fails when running from a browser only.
Upvotes: 0
Views: 320
Reputation: 1
Use subprocess
library
import subprocess
subprocess.Popen(cmd, shell=True)
You can even prevent outputs to your python console, by setting
import subprocess
subprocess.Popen(cmd,
shell=True,
stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT)
Upvotes: 0