|
From: <di...@us...> - 2010-11-19 16:22:44
|
Revision: 690
http://safekeep.svn.sourceforge.net/safekeep/?rev=690&view=rev
Author: dimi
Date: 2010-11-19 16:22:38 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Get rid of a bunch of subprocess calls
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 16:13:21 UTC (rev 689)
+++ safekeep/trunk/safekeep 2010-11-19 16:22:38 UTC (rev 690)
@@ -184,11 +184,7 @@
server.quit()
else:
cmd = ['/usr/sbin/sendmail', '-t']
- pin = subprocess.Popen(cmd, stdin=PIPE).stdin
- try:
- pin.write(msg)
- finally:
- pin.close()
+ call(cmd, stdin=msg)
def is_temp_root(dir):
return dir != '/'
@@ -1134,10 +1130,8 @@
if status or deploy:
cmd = '%s %s@%s "if test -f .ssh/authorized_keys; then cat .ssh/authorized_keys; fi"' % (basessh, cfg['user'], cfg['host'])
- debug(cmd)
- out = subprocess.Popen(cmd, shell=True, stdout=PIPE).stdout
- authtext = out.read()
- if out.close():
+ authtext = call(cmd)
+ if authtext is None:
warn('%s: Failed to read the authorized_keys file.' % id)
auth_keys = parse_authorized_keys(authtext)
this_keys = parse_authorized_keys(output)
@@ -1156,10 +1150,9 @@
print '%s: Keys will be deployed on the client.' % id
if deploy:
cmd = '%s %s@%s "umask 077; test -d .ssh || mkdir .ssh; cat >> .ssh/authorized_keys"' % (basessh, cfg['user'], cfg['host'])
- debug(cmd)
- pipe = subprocess.Popen(cmd, shell=True, stdin=PIPE).stdin
- pipe.write('%s\n' % '\n'.join([key[4] for key in new_keys]))
- if pipe.close():
+ keys = '%s\n' % '\n'.join([key[4] for key in new_keys])
+ out = call(cmd, shell=True, stdin=keys)
+ if out is None:
error('Failed to deliver the keys to the client')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|