[Tutor] handling timeouts, normal completion, or exceptions when interacting with CVS

Alan Gauld alan.gauld at btinternet.com
Mon Nov 20 06:17:59 CET 2006


"Tony Cappellini" <cappy2112 at gmail.com> wrote

> def SendCVSCommand(self)
>
>      self.__cvsCmd = "cvs update -A -C someArchiveName"
>
>      try:
>         hProcess = popen(self.__cvsCmd, "r") # will run the cvs 
> command,
> and checkout this module to the current directory
>         # HOW LONG DO WE WAIT BEFORE CONTINUING????
>         sleep(timeToWait)
>
>         # how do we check for errors??????????

I don't think you need the sleep because the call to popen won't
return untl the command has completed.

And you check for errors by reading the output from stdout
and stderr just as you would at a console.

result = hProcess.read()

and parse the string in result.

You probably want to use popen2 or popen3 to separate the
stdout/stderr streams.

HTH

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list