how to catch error with system()

eight02645999 at yahoo.com eight02645999 at yahoo.com
Mon Dec 12 07:55:23 EST 2005


hi

i have a piece of python code extract that calls an external java
program
cmd = """java someclass someargs"""
try:
   ret = os.WEXITSTATUS(os.system(cmd))
except:
   print blah
else:
   dosomething(ret)

the thing is, the java class "someclass" produces it's own errors when
something goes wrong.
something like
java.io.FileNotFoundException: somefile (No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:106)
        at java.io.FileInputStream.<init>(FileInputStream.java:66)
        ......

how can i supress this error from showing when i execute
./pythonscript.py and at the same time logging it to an errlog file??

thanks




More information about the Python-list mailing list