Hello eryksun,
Thanks, very much, for the very quick and helpful reply. It fixed my
problem.

-Sm


On Tue, Oct 22, 2013 at 10:33 PM, eryksun <eryk...@gmail.com> wrote:

> On Tue, Oct 22, 2013 at 9:04 PM, SM <sunith...@gmail.com> 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  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to