I'm trying to make a simple web service which reads an MSEED file and outputs some information on that.
The most reasonable choice seemed to be using python with the excellent obspy module (A Python Toolbox for seismology/seismological observatories), which is widely used in the seismological community.
I succed in reading a file and getting some information from it with this simple python code:
import obspy
import numpy
import sys
my_filename = "SOME FILE"
my_start_time = "2012-01-01T08:00:00"
my_end_time = "2012-01-01T09:00:00"
dt = obspy.UTCDateTime(my_start_time)
et = obspy.UTCDateTime(my_end_time)
st = obspy.read(my_filename, starttime=dt, endtime=et)
....then do something....
Now, if I want to implement it as a web service, among the several different choiche I can install the mod_python on Apache, and invoke such script in a bit different way.
I do as follows (the script is in a file called test.py
):
from mod_python import util
import obspy
import numpy
import sys
def index(req):
[...]
startdate="2012-01-01T08:00:01"
enddate="2012-01-01T08:10:00"
myfilename=" SOME FILE"
dt = obspy.UTCDateTime(startdate)
et = obspy.UTCDateTime(enddate)
##### read file
st = obspy.read(my_filename, starttime=dt, endtime=et) ******
[...]
What happens is that on the last line it hangs without giving any error. when invoking the script from my server http://localhost.my/cgi-bin/test.py it works well until the last line, then after that it doesn't even print anything but, again WITHOUT OUTPUT ERRORS
Eveno more weird, if I change the last line with
st = obspy.read(my_filename, headonly=True)
then it works.
What I tried:
- Changing permission to files/folders. The script and the file are in my /var/www/cgi-bin directory. Assigning readable to everyone to files and directory did not work
- moving files to different folders
- changing the owner of the file/dir (to www-data)
But it still doesn't work.
I don't understand if it is a problem of the obspy module or some limitation to the apache mod_python.
Any idea about how to solve this issue?