On 09/10/2014 11:20 AM, jarod...@libero.it wrote:
If I follow the exmple I have this type of error:
File "./RNA_prova.py", line 73, in run
for line in p1.stdout():
TypeError: 'NoneType' object is not callable
You have at least two errors in your script below:
This time you're not piping the subprocess stdout, but redirecting it to
a file so nothing is ever going to appear in p1.stdout.
Second, p1.stdout is not a method so you're not supposed to call it.
Use p1.stdout instead of p1.stdout().
This is the class I use:
def run(cmd,pi):
import subprocess
import time
import logging
logging.basicConfig(level=logging.DEBUG,format="%(asctime)s -
%(name)s - %
(levelname)s - %(message)s")
#logging.debug(" Running pipelines: %s" % (cmd))
# setup logging
log_file = "None"
tou = "file"+"_.log.txt"
if log_file is not None:
logfh = open(tou, "w")
else:
logfh = None
print
"####################################################"
p1 =
subprocess.Popen(cmd,shell=True,stdout=logfh,stderr=logfh,cwd=pi)
#logging.info(" Running pipelines: %s" % (cmd))
for line in p1.stdout():
process(line)
p1.stdout.close()
if p.wait() != 0:
raise Exception
# end logging
if logfh is not None:
logfh.close()
return 0
How can be sure the process start finish before to proced with the other
comands?
thanks in advance for any help!
For additional help it would be more motivating if we could discuss some
fixed concrete code along with precise error descriptions instead of
ever shifting pieces of code.
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor