On Tue, Oct 22, 2013 at 9:04 PM, SM <[email protected]> wrote:
> def run(self):
> (process, err) = Popen(self.fwcmd, stdout=PIPE,
> stderr=PIPE).communicate()
> if len(err) > 0:
> # print("Error")
> # Error handling code
> else:
> # print("Success")
Store the Popen() instance before calling its communicate() method:
p = self.process = Popen(self.fwcmd, stdout=PIPE, stderr=PIPE)
out, err = p.communicate()
if p.returncode:
raise CalledProcessError(p.returncode, self.fwcmd, (out, err))
communicate() sets returncode; an error is indicated by a non-zero
value. Some programs write non-error information to stderr, so use the
return code to detect an error.
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor