'popen' calls not happening?
Hi all We've been successfully using this code from an external method to run a third-party program, but it's mysteriously stopped working:: try: child_stdout, \ child_stdin, \ child_stderr = popen3('/usr/local/zope/creme/2-3-0/Extensions/passfeko /usr/local/zope/creme/2-3-0/Extensions/passfeko.xml') success.append("'passfeko' executed.\n") #DBG except: exception = sys.exc_info() errors.append( "Could not execute 'passfeko'" \ + '\n --' + str(exception[0]) \ + '\n --' + str(exception[1]) \ + '\n --' + str(exception[2]) \ ) # TODO: display the traceback. The third-party program, 'passfeko', writes a textfile, taking the 'passfeko.xml' file as input. If I run:: ./passfeko passfeko.xml from the commandline, the textfile is flawlessly created. When run from Zope, no exception is raised, but no textfile is created. Any ideas? Jean
Is that all your 'except' clause does? Because if so, you're not going to get any tracebacks at all, because the expect is catching them all and doing nothing with them. Try removing the try..except. seb * Jean Jordaan <jean@upfrontsystems.co.za> [010907 11:44]:
Hi all
We've been successfully using this code from an external method to run a third-party program, but it's mysteriously stopped working::
try: child_stdout, \ child_stdin, \ child_stderr = popen3('/usr/local/zope/creme/2-3-0/Extensions/passfeko /usr/local/zope/creme/2-3-0/Extensions/passfeko.xml') success.append("'passfeko' executed.\n") #DBG except: exception = sys.exc_info() errors.append( "Could not execute 'passfeko'" \ + '\n --' + str(exception[0]) \ + '\n --' + str(exception[1]) \ + '\n --' + str(exception[2]) \ ) # TODO: display the traceback.
The third-party program, 'passfeko', writes a textfile, taking the 'passfeko.xml' file as input. If I run::
./passfeko passfeko.xml
from the commandline, the textfile is flawlessly created.
When run from Zope, no exception is raised, but no textfile is created.
Any ideas?
Jean
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Hi Seb
Is that all your 'except' clause does? Because if so, you're not going to get any tracebacks at all, because the expect is catching them all and doing nothing with them. Try removing the try..except.
If there is a traceback, won't it be included in the 'errors' list by 'str(exception[2])' ?
exception = sys.exc_info() errors.append( "Could not execute 'passfeko'" \ + '\n --' + str(exception[0]) \ + '\n --' + str(exception[1]) \ + '\n --' + str(exception[2]) \ ) # TODO: display the traceback.
Since no exception is being raised, however, this doesn't really touch on the issue of the popen call not working .. jean
* Jean Jordaan <jean@upfrontsystems.co.za> [010907 12:24]:
Hi Seb
Is that all your 'except' clause does? Because if so, you're not going to get any tracebacks at all, because the expect is catching them all and doing nothing with them. Try removing the try..except.
If there is a traceback, won't it be included in the 'errors' list by 'str(exception[2])' ?
yes, but where are you returning the value of 'errors'?
exception = sys.exc_info() errors.append( "Could not execute 'passfeko'" \ + '\n --' + str(exception[0]) \ + '\n --' + str(exception[1]) \ + '\n --' + str(exception[2]) \ ) # TODO: display the traceback.
Since no exception is being raised, however, this doesn't really touch on the issue of the popen call not working ..
No exception is being raised because you are catching the exception. If you either (a) return the value of errors, or (b) remove the try..except clause, then you'll know if an exception is being raised or not. seb
yes, but where are you returning the value of 'errors'?
The external method ends with:: return dongles, errors, success, secfeko and that is displayed to screen in a subsequent DTML method. It has successfully displayed exceptions when they occurred, but it isn't displaying any now.
No exception is being raised because you are catching the exception.
Hmm, as I understand it, *if* an exception was being raised, I would be assigning its details to 'errors'. Stepping thru the code in pdb, however, shows that the assignment to 'errors' never happens --- the 'except' suite is not being executed. I've also tried without wrapping the popen3 call in a 'try', same thing (the textfile doesn't get written) .. Jean
* Jean Jordaan <jean@upfrontsystems.co.za> [010907 12:48]:
yes, but where are you returning the value of 'errors'?
The external method ends with::
return dongles, errors, success, secfeko
Oh, OK, I thought perhaps you'd forgotten to do this :-)
I've also tried without wrapping the popen3 call in a 'try', same thing (the textfile doesn't get written) ..
Well, here's some more suggestions, hopefully more useful: - you're capturing stderr from the child process but you're not returning it. If it's failing for some reason, which it appears to be doing, you won't know about it. - try running your external method from the command line - try replacing the call with something simple like 'touch' hth, seb
Hi seb I've found the problem --- I was being sloppy about what the current working directory is! At the commandline, it was the same directory as the executable.
From Zope --- it was the Zope root. So my missing textfile was lying snugly one directory up from where I was looking for it. Aaargh!
Thanks for the help :] jean
participants (2)
-
Jean Jordaan -
seb bacon