|
From: <di...@us...> - 2010-11-19 16:50:24
|
Revision: 695
http://safekeep.svn.sourceforge.net/safekeep/?rev=695&view=rev
Author: dimi
Date: 2010-11-19 16:50:18 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
More cleanup of the subprocess usage
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 16:44:13 UTC (rev 694)
+++ safekeep/trunk/safekeep 2010-11-19 16:50:18 UTC (rev 695)
@@ -22,8 +22,6 @@
import getpass, pwd, xml.dom.minidom
import socket, smtplib
-from subprocess import PIPE, STDOUT
-
######################################################################
# Global settings
######################################################################
@@ -108,12 +106,20 @@
def do_spawn(args, stdin=None, stdout=False):
debug('Run [' + args + ']')
- shell = isinstance(args, types.StringTypes)
- proc = subprocess.Popen(args, bufsize=1, shell=shell, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
+ _shell = isinstance(args, types.StringTypes)
+ if stdin:
+ _stdin = subprocess.PIPE
+ else:
+ _stdin = None
+ if stdout:
+ _stderr = None
+ else:
+ _stderr = subprocess.STDOUT
+ proc = subprocess.Popen(args, bufsize=1, shell=_shell, stdin=_stdin, stdout=subprocess.PIPE, stderr=_stderr, close_fds=True)
if stdin:
proc.stdin.write(stdin)
- proc.stdin.close()
+ proc.stdin.close()
lines=[]
for line in proc.stdout:
if stdout:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|