Trick to executing command line python out of Django
Is there a trick to executing this command line
cmd_line = 'python /home/amr/bin/addReadSnap.py -s ' + str(cycle)
using this function from django?
import sys
import os
import string
from subprocess import call, Popen
def exec_external_cmd(cmd_line):
retcode = None
try:
process = Popen(cmd_line, bufsize=2048, executable="/bin/
bash", shell=True, stdout=None, stderr=None)
while retcode == None:
retcode = process.poll()
if retcode < 0:
print >>sys.stderr, "Child was terminated by signal", -
retcode
elif retcode > 0:
print >>sys.stderr, "Child returned", retcode
except OSError, e:
print >>sys.stderr, "Execution failed:", e
return retcode
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home