|
From: <di...@us...> - 2010-02-09 16:00:35
|
Revision: 672
http://safekeep.svn.sourceforge.net/safekeep/?rev=672&view=rev
Author: dimi
Date: 2010-02-09 15:45:01 +0000 (Tue, 09 Feb 2010)
Log Message:
-----------
Use the send() function directly
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-02-09 15:40:06 UTC (rev 671)
+++ safekeep/trunk/safekeep 2010-02-09 15:45:01 UTC (rev 672)
@@ -73,8 +73,7 @@
if is_client or verbosity_level >= cutoff:
logbuf.append(msg)
if is_client:
- print msg
- sys.stdout.flush()
+ send(msg)
else:
print >> sys.stderr, msg
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-02-10 16:06:43
|
Revision: 674
http://safekeep.svn.sourceforge.net/safekeep/?rev=674&view=rev
Author: dimi
Date: 2010-02-10 16:06:37 +0000 (Wed, 10 Feb 2010)
Log Message:
-----------
Bertrand Lecervoisier <ber...@la...>
Use the correct package name.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-02-09 16:01:11 UTC (rev 673)
+++ safekeep/trunk/safekeep 2010-02-10 16:06:37 UTC (rev 674)
@@ -499,7 +499,7 @@
if passwdfile:
- environ['PGPASSFILE'] = passwdfile
+ os.environ['PGPASSFILE'] = passwdfile
try:
ec = spawn(cmd, shell=True)
finally:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-19 07:02:25
|
Revision: 677
http://safekeep.svn.sourceforge.net/safekeep/?rev=677&view=rev
Author: dimi
Date: 2010-11-19 07:02:19 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Oops, typo
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 06:55:25 UTC (rev 676)
+++ safekeep/trunk/safekeep 2010-11-19 07:02:19 UTC (rev 677)
@@ -1072,7 +1072,7 @@
nice = cfg['nice'] or nice_rem
if nice:
- nice_cmd = 'nice -n%s' % (nice)
+ nice_cmd = 'nice -n%s ' % (nice)
else:
nice_cmd = ''
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-19 07:34:18
|
Revision: 681
http://safekeep.svn.sourceforge.net/safekeep/?rev=681&view=rev
Author: dimi
Date: 2010-11-19 07:34:12 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Make sure we init the var
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 07:32:28 UTC (rev 680)
+++ safekeep/trunk/safekeep 2010-11-19 07:34:12 UTC (rev 681)
@@ -286,7 +286,7 @@
key_ctrl = host_el[0].getAttribute('key-ctrl')
key_data = host_el[0].getAttribute('key-data')
else:
- host = user = key_ctrl = key_data = None
+ host = user = nice = key_ctrl = key_data = None
if host and not user:
user = 'root'
if host and not key_ctrl:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-19 08:34:41
|
Revision: 684
http://safekeep.svn.sourceforge.net/safekeep/?rev=684&view=rev
Author: dimi
Date: 2010-11-19 08:34:35 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Use the Popen call directly
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 08:30:06 UTC (rev 683)
+++ safekeep/trunk/safekeep 2010-11-19 08:34:35 UTC (rev 684)
@@ -1104,7 +1104,7 @@
if backup_user is not work_user:
gencmd = 'su -s /bin/sh -c %s - %s' % (commands.mkarg(gencmd), backup_user)
debug(gencmd)
- if subprocess.call(gencmd, shell=True):
+ if subprocess.Popen(gencmd, shell=True).wait():
error('%s: Failed to generate key %s. Skipping client.' % (id, privatekeyfile))
break
if not os.path.isfile(publickeyfile):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-19 08:57:33
|
Revision: 685
http://safekeep.svn.sourceforge.net/safekeep/?rev=685&view=rev
Author: dimi
Date: 2010-11-19 08:57:27 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Avoid subprocess where we can easily
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 08:34:35 UTC (rev 684)
+++ safekeep/trunk/safekeep 2010-11-19 08:57:27 UTC (rev 685)
@@ -149,9 +149,9 @@
error('%s failed: %s' % (cmd, ret));
return ret
-def try_to_run(args, shell=False):
+def try_to_run(args):
try:
- rc = do_spawn(args, shell=shell)
+ rc = do_spawn(args)
except OSError, ex:
return False
return rc in (0,1)
@@ -1104,7 +1104,7 @@
if backup_user is not work_user:
gencmd = 'su -s /bin/sh -c %s - %s' % (commands.mkarg(gencmd), backup_user)
debug(gencmd)
- if subprocess.Popen(gencmd, shell=True).wait():
+ if os.system(gencmd):
error('%s: Failed to generate key %s. Skipping client.' % (id, privatekeyfile))
break
if not os.path.isfile(publickeyfile):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-19 14:41:10
|
Revision: 686
http://safekeep.svn.sourceforge.net/safekeep/?rev=686&view=rev
Author: dimi
Date: 2010-11-19 14:41:04 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Add ability to capture the output of a spawned proccess
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 08:57:27 UTC (rev 685)
+++ safekeep/trunk/safekeep 2010-11-19 14:41:04 UTC (rev 686)
@@ -112,7 +112,7 @@
else:
return args
-def do_spawn(args, shell=False):
+def do_spawn(args, shell=False, stdout=False):
global cmd
argslist = args_to_list(args)
cmd = argslist[0]
@@ -125,15 +125,19 @@
debug('Run [' + ' '.join(argslist) + ']')
proc = subprocess.Popen(argslist, bufsize=1, shell=False, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
proc.stdin.close()
+ lines=[]
for line in proc.stdout:
- info(line.rstrip())
+ if stdout:
+ lines.append(line)
+ else:
+ info(line.rstrip())
proc.stdout.close()
- return proc.wait()
+ return (proc.wait(), ''.join(lines))
def spawn(args, shell=False):
global cmd
try:
- rc = do_spawn(args, shell=shell)
+ rc, out = do_spawn(args, shell=shell)
except OSError, ex:
error("OSError: %s: %s" % (cmd, ex))
@@ -151,7 +155,7 @@
def try_to_run(args):
try:
- rc = do_spawn(args)
+ rc, out = do_spawn(args)
except OSError, ex:
return False
return rc in (0,1)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-19 14:56:52
|
Revision: 687
http://safekeep.svn.sourceforge.net/safekeep/?rev=687&view=rev
Author: dimi
Date: 2010-11-19 14:56:46 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Provide a more expressive function to call external commands
and deal with the standard input/output.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 14:41:04 UTC (rev 686)
+++ safekeep/trunk/safekeep 2010-11-19 14:56:46 UTC (rev 687)
@@ -112,7 +112,7 @@
else:
return args
-def do_spawn(args, shell=False, stdout=False):
+def do_spawn(args, shell=False, stdin=None, stdout=False):
global cmd
argslist = args_to_list(args)
cmd = argslist[0]
@@ -124,6 +124,8 @@
# Otherwise split into separate elements.
debug('Run [' + ' '.join(argslist) + ']')
proc = subprocess.Popen(argslist, bufsize=1, shell=False, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
+ if stdin:
+ proc.stdin.write(stdin)
proc.stdin.close()
lines=[]
for line in proc.stdout:
@@ -134,12 +136,14 @@
proc.stdout.close()
return (proc.wait(), ''.join(lines))
-def spawn(args, shell=False):
+def _spawn(args, shell=False, stdin=None, stdout=False):
global cmd
try:
- rc, out = do_spawn(args, shell=shell)
+ rc, out = do_spawn(args, shell, stdin, stdout)
except OSError, ex:
- error("OSError: %s: %s" % (cmd, ex))
+ ret = "OSError: %s" % (ex)
+ error('%s failed: %s' % (cmd, ret));
+ return ret
if not rc:
ret = None
@@ -151,8 +155,23 @@
ret = 'unknown exit status: %d' % rc
if ret:
error('%s failed: %s' % (cmd, ret));
- return ret
+ return (ret, out)
+# this just spawns an external program (optionally through a shell)
+# and returns True it it fails, and False if it successed
+def spawn(args, shell=False):
+ rc, out = _spawn(args, shell)
+ return rc
+
+# this spawans an external program (optionally through a shell),
+# feeds it any input via stdin, captures the output and returns it.
+# if it fails it returns None, otherwise it returns the output
+def call(args, shell=False, stdin=None):
+ rc, out = _spawn(args, shell, stdin, stdout=True)
+ if not rc:
+ return None
+ return out
+
def try_to_run(args):
try:
rc, out = do_spawn(args)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-19 15:07:50
|
Revision: 688
http://safekeep.svn.sourceforge.net/safekeep/?rev=688&view=rev
Author: dimi
Date: 2010-11-19 15:07:44 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Get rid of cmd_run function.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 14:56:46 UTC (rev 687)
+++ safekeep/trunk/safekeep 2010-11-19 15:07:44 UTC (rev 688)
@@ -179,12 +179,6 @@
return False
return rc in (0,1)
-def cmd_run(args):
- argslist = args_to_list(args)
- debug('Run [' + ' '.join(argslist) + ']')
- p = subprocess.Popen(argslist, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
- return (p.stdin, p.stdout)
-
def send_notification(email, smtp):
global logbuf
if not logbuf: return
@@ -545,10 +539,7 @@
(dump['file'], dump['db'], e))
def lvm_snap_information():
- (cin, cout) = cmd_run(['lvs', '--separator', ':', '--noheadings'])
- lines = cout.readlines()
- cout.close()
- cin.close()
+ lines = call(['lvs', '--separator', ':', '--noheadings']) or ''
lvms = []
for line in lines:
if line.count(':') > 3:
@@ -558,10 +549,7 @@
return lvms
def mount_information(reverse = False):
- (cin, cout) = cmd_run(['mount'])
- lines = cout.readlines()
- cout.close()
- cin.close()
+ lines = call(['mount']) or ''
mounts = []
pattern = re.compile(r"^(\S+) on (.+) type (\S+) \((\S+)\)")
if reverse:
@@ -979,11 +967,14 @@
if cfg['retention'] and os.path.isdir(rdiff_logdir) and not cleanup:
do_server_data_cleanup(cfg)
+ cmd = []
if cfg['host']:
- cmd = 'ssh %s -T -i %s -l %s %s safekeep --client' % (verbosity_ssh, cfg['key_ctrl'], cfg['user'], cfg['host'])
- else:
- cmd = 'safekeep --client'
- (cin, cout) = cmd_run(cmd)
+ cmd.extend(['ssh', verbosity_ssh, '-T', '-i', cfg['key_ctrl'], '-l', cfg['user'], cfg['host'])
+ cmd.extend(['safekeep', '--client'])
+
+ proc = subprocess.Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
+ cin = proc.stdin
+ cout = proc.stdout
cin.write('ALOHA: %s, %s\n' % (PROTOCOL, VERSION))
cin.flush()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-19 16:13:32
|
Revision: 689
http://safekeep.svn.sourceforge.net/safekeep/?rev=689&view=rev
Author: dimi
Date: 2010-11-19 16:13:21 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Get rid of args_to_list()
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 15:07:44 UTC (rev 688)
+++ safekeep/trunk/safekeep 2010-11-19 16:13:21 UTC (rev 689)
@@ -106,24 +106,10 @@
def error(msg):
log(msg, 'ERR')
-def args_to_list(args):
- if isinstance(args, str) or isinstance(args, unicode):
- return args.split(None)
- else:
- return args
-
def do_spawn(args, shell=False, stdin=None, stdout=False):
- global cmd
- argslist = args_to_list(args)
- cmd = argslist[0]
- if shell:
- # If passed to a shell then give args exactly as specified.
- debug('Run [' + args + ']')
- proc = subprocess.Popen(args, bufsize=1, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
- else:
- # Otherwise split into separate elements.
- debug('Run [' + ' '.join(argslist) + ']')
- proc = subprocess.Popen(argslist, bufsize=1, shell=False, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
+ debug('Run [' + args + ']')
+ proc = subprocess.Popen(args, bufsize=1, shell=shell, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
+
if stdin:
proc.stdin.write(stdin)
proc.stdin.close()
@@ -137,7 +123,11 @@
return (proc.wait(), ''.join(lines))
def _spawn(args, shell=False, stdin=None, stdout=False):
- global cmd
+ if isinstance(args, str) or isinstance(args, unicode):
+ cmd = args.split(None)[0]
+ else:
+ cmd = args[0]
+
try:
rc, out = do_spawn(args, shell, stdin, stdout)
except OSError, ex:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <di...@us...> - 2010-11-19 16:35:51
|
Revision: 691
http://safekeep.svn.sourceforge.net/safekeep/?rev=691&view=rev
Author: dimi
Date: 2010-11-19 16:35:45 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Get rid of the direct subprocess call.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 16:22:38 UTC (rev 690)
+++ safekeep/trunk/safekeep 2010-11-19 16:35:45 UTC (rev 691)
@@ -957,10 +957,8 @@
if cfg['host']:
cmd.extend(['ssh', verbosity_ssh, '-T', '-i', cfg['key_ctrl'], '-l', cfg['user'], cfg['host'])
cmd.extend(['safekeep', '--client'])
-
- proc = subprocess.Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
- cin = proc.stdin
- cout = proc.stdout
+
+ (cin,cout) = os.popen2(cmd)
cin.write('ALOHA: %s, %s\n' % (PROTOCOL, VERSION))
cin.flush()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-19 16:36:58
|
Revision: 692
http://safekeep.svn.sourceforge.net/safekeep/?rev=692&view=rev
Author: dimi
Date: 2010-11-19 16:36:52 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Typo
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 16:35:45 UTC (rev 691)
+++ safekeep/trunk/safekeep 2010-11-19 16:36:52 UTC (rev 692)
@@ -955,7 +955,7 @@
cmd = []
if cfg['host']:
- cmd.extend(['ssh', verbosity_ssh, '-T', '-i', cfg['key_ctrl'], '-l', cfg['user'], cfg['host'])
+ cmd.extend(['ssh', verbosity_ssh, '-T', '-i', cfg['key_ctrl'], '-l', cfg['user'], cfg['host']])
cmd.extend(['safekeep', '--client'])
(cin,cout) = os.popen2(cmd)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-19 16:43:42
|
Revision: 693
http://safekeep.svn.sourceforge.net/safekeep/?rev=693&view=rev
Author: dimi
Date: 2010-11-19 16:43:36 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Auto "shell" detection: if the command is a string,
it will be executed via the shell, otherwise it will
be executed directly.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 16:36:52 UTC (rev 692)
+++ safekeep/trunk/safekeep 2010-11-19 16:43:36 UTC (rev 693)
@@ -16,7 +16,7 @@
# along with Safekeep. If not, see <http://www.gnu.org/licenses/>.
from __future__ import generators
-import getopt, os, os.path, re, sys, fnmatch, stat
+import getopt, os, os.path, re, sys, fnmatch, stat, types
import subprocess
import commands, tempfile, time, traceback
import getpass, pwd, xml.dom.minidom
@@ -106,8 +106,9 @@
def error(msg):
log(msg, 'ERR')
-def do_spawn(args, shell=False, stdin=None, stdout=False):
+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)
if stdin:
@@ -122,14 +123,14 @@
proc.stdout.close()
return (proc.wait(), ''.join(lines))
-def _spawn(args, shell=False, stdin=None, stdout=False):
+def _spawn(args, stdin=None, stdout=False):
if isinstance(args, str) or isinstance(args, unicode):
cmd = args.split(None)[0]
else:
cmd = args[0]
try:
- rc, out = do_spawn(args, shell, stdin, stdout)
+ rc, out = do_spawn(args, stdin, stdout)
except OSError, ex:
ret = "OSError: %s" % (ex)
error('%s failed: %s' % (cmd, ret));
@@ -149,15 +150,15 @@
# this just spawns an external program (optionally through a shell)
# and returns True it it fails, and False if it successed
-def spawn(args, shell=False):
- rc, out = _spawn(args, shell)
+def spawn(args):
+ rc, out = _spawn(args)
return rc
# this spawans an external program (optionally through a shell),
# feeds it any input via stdin, captures the output and returns it.
# if it fails it returns None, otherwise it returns the output
-def call(args, shell=False, stdin=None):
- rc, out = _spawn(args, shell, stdin, stdout=True)
+def call(args, stdin=None):
+ rc, out = _spawn(args, stdin, stdout=True)
if not rc:
return None
return out
@@ -505,7 +506,7 @@
if passwdfile:
os.environ['PGPASSFILE'] = passwdfile
try:
- ec = spawn(cmd, shell=True)
+ ec = spawn(cmd)
finally:
if passwdfile:
del os.environ['PGPASSFILE']
@@ -1149,7 +1150,7 @@
if deploy:
cmd = '%s %s@%s "umask 077; test -d .ssh || mkdir .ssh; cat >> .ssh/authorized_keys"' % (basessh, cfg['user'], cfg['host'])
keys = '%s\n' % '\n'.join([key[4] for key in new_keys])
- out = call(cmd, shell=True, stdin=keys)
+ out = call(cmd, 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.
|
|
From: <di...@us...> - 2010-11-19 16:44:19
|
Revision: 694
http://safekeep.svn.sourceforge.net/safekeep/?rev=694&view=rev
Author: dimi
Date: 2010-11-19 16:44:13 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Cleanup
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 16:43:36 UTC (rev 693)
+++ safekeep/trunk/safekeep 2010-11-19 16:44:13 UTC (rev 694)
@@ -124,7 +124,7 @@
return (proc.wait(), ''.join(lines))
def _spawn(args, stdin=None, stdout=False):
- if isinstance(args, str) or isinstance(args, unicode):
+ if isinstance(args, types.StringTypes):
cmd = args.split(None)[0]
else:
cmd = args[0]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <di...@us...> - 2010-11-19 17:00:03
|
Revision: 696
http://safekeep.svn.sourceforge.net/safekeep/?rev=696&view=rev
Author: dimi
Date: 2010-11-19 16:59:55 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Better handle errors in case things go really bad
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 16:50:18 UTC (rev 695)
+++ safekeep/trunk/safekeep 2010-11-19 16:59:55 UTC (rev 696)
@@ -642,6 +642,9 @@
if not line: raise ConfigException('Unexpected end of file')
cfgStr += line
+ do_client_config_parse(cfgStr, dflt_id)
+
+def do_client_config_parse(cfgStr, dflt_id=None):
dom = xml.dom.minidom.parseString(cfgStr)
try:
return parse_config(dom.documentElement, dflt_id)
@@ -774,6 +777,7 @@
debug("Do client main loop")
should_cleanup = True
bdir = '/'
+ cfg = do_client_config_parse('<backup/>', 'def')
try:
while True:
try:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-19 17:01:53
|
Revision: 697
http://safekeep.svn.sourceforge.net/safekeep/?rev=697&view=rev
Author: dimi
Date: 2010-11-19 17:01:47 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
We have to deal with strings here
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 16:59:55 UTC (rev 696)
+++ safekeep/trunk/safekeep 2010-11-19 17:01:47 UTC (rev 697)
@@ -105,7 +105,7 @@
log(msg, 'ERR')
def do_spawn(args, stdin=None, stdout=False):
- debug('Run [' + args + ']')
+ debug('Run [' + ' '.joint(args) + ']')
_shell = isinstance(args, types.StringTypes)
if stdin:
_stdin = subprocess.PIPE
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-19 17:17:43
|
Revision: 698
http://safekeep.svn.sourceforge.net/safekeep/?rev=698&view=rev
Author: dimi
Date: 2010-11-19 17:17:37 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Cleanup error handling
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 17:01:47 UTC (rev 697)
+++ safekeep/trunk/safekeep 2010-11-19 17:17:37 UTC (rev 698)
@@ -778,6 +778,7 @@
should_cleanup = True
bdir = '/'
cfg = do_client_config_parse('<backup/>', 'def')
+ ex = None
try:
while True:
try:
@@ -813,12 +814,14 @@
send('ERROR Unknown command: %s' % line)
break
except Exception, e:
- traceback.print_exc(file=sys.stdout)
- send('ERROR %s' % e)
+ ex = e
+ break
finally:
if should_cleanup:
do_client_cleanup(cfg, bdir)
+ if ex:
+ send('ERROR %s' % (ex or ''))
######################################################################
# Server implementation
@@ -1482,8 +1485,7 @@
else:
assert False, 'Unknown mode: %s' % (mode)
except Exception, ex:
- traceback.print_exc(file=sys.stdout)
- error('ERROR: %s' % ex)
+ error('ERROR: %s' % (ex or ''))
if email and not noemail:
send_notification(email, smtp)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-19 17:58:37
|
Revision: 699
http://safekeep.svn.sourceforge.net/safekeep/?rev=699&view=rev
Author: dimi
Date: 2010-11-19 17:58:31 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
A few silly typos
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 17:17:37 UTC (rev 698)
+++ safekeep/trunk/safekeep 2010-11-19 17:58:31 UTC (rev 699)
@@ -105,7 +105,7 @@
log(msg, 'ERR')
def do_spawn(args, stdin=None, stdout=False):
- debug('Run [' + ' '.joint(args) + ']')
+ debug('Run [' + ' '.join(args) + ']')
_shell = isinstance(args, types.StringTypes)
if stdin:
_stdin = subprocess.PIPE
@@ -642,7 +642,7 @@
if not line: raise ConfigException('Unexpected end of file')
cfgStr += line
- do_client_config_parse(cfgStr, dflt_id)
+ return do_client_config_parse(cfgStr, dflt_id)
def do_client_config_parse(cfgStr, dflt_id=None):
dom = xml.dom.minidom.parseString(cfgStr)
@@ -814,6 +814,7 @@
send('ERROR Unknown command: %s' % line)
break
except Exception, e:
+ traceback.print_exc(file=sys.stdout)
ex = e
break
finally:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-19 18:50:29
|
Revision: 701
http://safekeep.svn.sourceforge.net/safekeep/?rev=701&view=rev
Author: dimi
Date: 2010-11-19 18:50:23 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Use our abstraction instead
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 18:46:12 UTC (rev 700)
+++ safekeep/trunk/safekeep 2010-11-19 18:50:23 UTC (rev 701)
@@ -1117,7 +1117,7 @@
if backup_user is not work_user:
gencmd = 'su -s /bin/sh -c %s - %s' % (commands.mkarg(gencmd), backup_user)
debug(gencmd)
- if os.system(gencmd):
+ if spawn(gencmd):
error('%s: Failed to generate key %s. Skipping client.' % (id, privatekeyfile))
break
if not os.path.isfile(publickeyfile):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-19 19:16:31
|
Revision: 702
http://safekeep.svn.sourceforge.net/safekeep/?rev=702&view=rev
Author: dimi
Date: 2010-11-19 19:16:25 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
First cut at a decent fallback for the subprocess module
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-19 18:50:23 UTC (rev 701)
+++ safekeep/trunk/safekeep 2010-11-19 19:16:25 UTC (rev 702)
@@ -17,11 +17,17 @@
from __future__ import generators
import getopt, os, os.path, re, sys, fnmatch, stat, types
-import subprocess
import commands, tempfile, time, traceback
import getpass, pwd, xml.dom.minidom
import socket, smtplib
+try:
+ import subprocess
+ from subprocess import PIPE, STDOUT
+except:
+ PIPE = -1
+ STDOUT = -2
+
######################################################################
# Global settings
######################################################################
@@ -108,26 +114,47 @@
debug('Run [' + ' '.join(args) + ']')
_shell = isinstance(args, types.StringTypes)
if stdin:
- _stdin = subprocess.PIPE
+ _stdin = 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)
+ _stderr = STDOUT
+ if 'subprocess' in dir():
+ proc = subprocess.Popen(args, bufsize=1, shell=_shell, stdin=_stdin, stdout=PIPE, stderr=_stderr, close_fds=True)
+ child_in = proc.stdin
+ child_out = proc.stdout
+ def do_wait():
+ return proc_wait()
+
+ else:
+ if _shell:
+ args = ["/bin/sh", "-c"].extends(args)
+ if _stderr:
+ (child_in, child_out) = os.popen4(args)
+ else:
+ (child_in, child_out) = os.popen3(args)
+
+ if not stdin:
+ child_in.close()
+
+ def do_wait():
+ return 0
+
if stdin:
- proc.stdin.write(stdin)
- proc.stdin.close()
+ child_in.write(stdin)
+ child_in.close()
+
lines=[]
- for line in proc.stdout:
+ for line in child_out:
if stdout:
lines.append(line)
else:
info(line.rstrip())
- proc.stdout.close()
- return (proc.wait(), ''.join(lines))
+ child_out.close()
+ return (do_wait(), ''.join(lines))
def _spawn(args, stdin=None, stdout=False):
if isinstance(args, types.StringTypes):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-21 19:28:25
|
Revision: 706
http://safekeep.svn.sourceforge.net/safekeep/?rev=706&view=rev
Author: dimi
Date: 2010-11-21 19:28:19 +0000 (Sun, 21 Nov 2010)
Log Message:
-----------
Clean up, fix typo
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-21 19:11:22 UTC (rev 705)
+++ safekeep/trunk/safekeep 2010-11-21 19:28:19 UTC (rev 706)
@@ -131,7 +131,7 @@
else:
if _shell:
- args = ["/bin/sh", "-c"].extends(args)
+ args = ["/bin/sh", "-c"].extend(args)
if _stderr:
(child_in, child_out) = os.popen4(args)
else:
@@ -873,11 +873,12 @@
if nice:
args.extend(['nice', '-n' + str(nice)])
- if ionice and ionice != 'none' and try_to_run('ionice'):
- if ionice == 'idle':
- args.extend(['ionice', '-c3', '-t'])
+ ionice_cmd = 'ionice'
+ if ionice and ionice != 'none' and try_to_run(ionice_cmd):
+ if ionice is 'idle':
+ args.extend([ionice_cmd, '-c3', '-t'])
else:
- args.extend(['ionice', '-c2', '-n' + ionice, '-t'])
+ args.extend([ionice_cmd, '-c2', '-n' + ionice, '-t'])
args.extend(['rdiff-backup'])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-21 19:32:17
|
Revision: 707
http://safekeep.svn.sourceforge.net/safekeep/?rev=707&view=rev
Author: dimi
Date: 2010-11-21 19:32:11 +0000 (Sun, 21 Nov 2010)
Log Message:
-----------
Warn if ionice is not available
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-21 19:28:19 UTC (rev 706)
+++ safekeep/trunk/safekeep 2010-11-21 19:32:11 UTC (rev 707)
@@ -874,11 +874,14 @@
args.extend(['nice', '-n' + str(nice)])
ionice_cmd = 'ionice'
- if ionice and ionice != 'none' and try_to_run(ionice_cmd):
- if ionice is 'idle':
- args.extend([ionice_cmd, '-c3', '-t'])
+ if ionice and ionice != 'none':
+ if try_to_run(ionice_cmd):
+ if ionice is 'idle':
+ args.extend([ionice_cmd, '-c3', '-t'])
+ else:
+ args.extend([ionice_cmd, '-c2', '-n' + ionice, '-t'])
else:
- args.extend([ionice_cmd, '-c2', '-n' + ionice, '-t'])
+ warn('ionice(1) not available, ignoring ionice.adjustment')
args.extend(['rdiff-backup'])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-11-21 20:01:26
|
Revision: 708
http://safekeep.svn.sourceforge.net/safekeep/?rev=708&view=rev
Author: dimi
Date: 2010-11-21 20:01:20 +0000 (Sun, 21 Nov 2010)
Log Message:
-----------
Add working support for reporting exceptions that happen on the client side
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-11-21 19:32:11 UTC (rev 707)
+++ safekeep/trunk/safekeep 2010-11-21 20:01:20 UTC (rev 708)
@@ -82,7 +82,7 @@
print >> sys.stderr, msg.encode('utf-8')
def info_file(file, marker=None):
- info('## File: ' + file)
+ info('# File: ' + file)
errs = 0;
fin = open(file, 'r')
try:
@@ -98,6 +98,9 @@
fin.close()
return errs
+def stacktrace():
+ return "\n" + traceback.format_exc()
+
def debug(msg):
log(msg, 'DBG')
@@ -107,8 +110,11 @@
def warn(msg):
log(msg, 'WARN')
-def error(msg):
- log(msg, 'ERR')
+def error(msg, ex):
+ extra = ""
+ if ex:
+ extra = stacktrace()
+ log(msg + extra, 'ERR')
def do_spawn(args, stdin=None, stdout=False):
debug('Run [' + ' '.join(args) + ']')
@@ -841,7 +847,6 @@
send('ERROR Unknown command: %s' % line)
break
except Exception, e:
- traceback.print_exc(file=sys.stdout)
ex = e
break
finally:
@@ -849,7 +854,7 @@
do_client_cleanup(cfg, bdir)
if ex:
- send('ERROR %s' % (ex or ''))
+ send('TRACEBACK ' + ex + '>>>' + stacktrace().replace('\n', '###'))
######################################################################
# Server implementation
@@ -862,6 +867,10 @@
return line[2:-1].strip()
elif line.startswith('ERROR'):
raise Exception(line[5:].strip())
+ elif line.startswith('TRACEBACK'):
+ i = line.find('>>>')
+ error(line[i+3:].replace('###', '\n'))
+ raise Exception(line[10:i].strip())
elif not line:
raise Exception('client died unexpectedly')
else:
@@ -1069,13 +1078,12 @@
else:
info('Server backup for client %s: OK (%d WARNINGS)' % (id, errs))
- except Exception, e:
+ except Exception, ex:
if cleanup and not cleaned_up:
info('Client-side cleanup for client %s: FAILED' % id)
do_server_rdiff_cleanup(cfg)
else:
- error(e)
- error('Server backup for client %s: FAILED' % id)
+ error('Server backup for client %s: FAILED' % id, ex)
info('------------------------------------------------------------------')
debug('Server backup done')
@@ -1527,7 +1535,7 @@
else:
assert False, 'Unknown mode: %s' % (mode)
except Exception, ex:
- error('ERROR: %s' % (ex or ''))
+ error('ERROR: %s' % (ex or ''), ex)
if email and not noemail:
send_notification(email, smtp)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|