From: <di...@us...> - 2009-06-04 15:35:31
|
Revision: 666 http://safekeep.svn.sourceforge.net/safekeep/?rev=666&view=rev Author: dimi Date: 2009-06-04 15:35:29 +0000 (Thu, 04 Jun 2009) Log Message: ----------- Share the popen2 code Modified Paths: -------------- safekeep/trunk/safekeep Modified: safekeep/trunk/safekeep =================================================================== --- safekeep/trunk/safekeep 2009-05-21 16:05:15 UTC (rev 665) +++ safekeep/trunk/safekeep 2009-06-04 15:35:29 UTC (rev 666) @@ -121,17 +121,7 @@ def error(msg): log(msg, 'ERR') -def try_to_run(cmd): - proc = popen2.Popen4(cmd) - proc.tochild.close() - for line in proc.fromchild: - info(line.rstrip()) - proc.fromchild.close() - rc = proc.wait() - - return os.WIFEXITED(rc) and os.WEXITSTATUS(rc) in (0,1) - -def spawn(args): +def do_spawn(args): if isinstance(args, str) or isinstance(args, unicode): debug('Run [' + args + ']') cmd = args.split(' ')[0] @@ -143,7 +133,10 @@ for line in proc.fromchild: info(line.rstrip()) proc.fromchild.close() - rc = proc.wait() + return proc.wait() + +def spawn(args): + rc = do_spawn(args) if os.WIFEXITED(rc): if os.WEXITSTATUS(rc) == 0: ret = None @@ -159,6 +152,10 @@ error('%s failed: %s' % (cmd, ret)); return ret +def try_to_run(cmd): + rc = do_spawn(args) + return os.WIFEXITED(rc) and os.WEXITSTATUS(rc) in (0,1) + def send_notification(email, smtp): global logbuf if not logbuf: return This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |