|
From: <di...@us...> - 2008-07-17 19:00:59
|
Revision: 597
http://safekeep.svn.sourceforge.net/safekeep/?rev=597&view=rev
Author: dimi
Date: 2008-07-17 19:00:36 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
Rework a bit the options processing such that generic rdiff-backup options don't affect the behaviour of the 'special-files' option.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2008-07-17 18:52:09 UTC (rev 596)
+++ safekeep/trunk/safekeep 2008-07-17 19:00:36 UTC (rev 597)
@@ -712,13 +712,12 @@
args.extend(['--force'])
options_append = []
+ special_files = ['--exclude-special-files', '--include-symbolic-links']
for option in cfg['options']:
if 'special-files' in option:
if 'include' in option['special-files']:
- if 'true'.startswith(option['special-files']['include'].lower()):
- options_append.extend(['--include-special-files'])
- else:
- options_append.extend(['--exclude-special-files', '--include-symbolic-links'])
+ if 'true' == option['special-files']['include'].lower():
+ special_files = ['--include-special-files']
# Note if we ever add other backends this section should only be run
# when rback-diff is the current option.
@@ -727,12 +726,9 @@
if 'append' in option['rdiff-backup']:
options_append.extend(option['rdiff-backup']['append'].split(None))
- if options_append:
- args.extend(options_append)
- else:
- args.extend(['--exclude-special-files', '--include-symbolic-links'])
+ args.extend(special_files)
+ args.extend(options_append)
- #args.extend([ '-v', '6'])
for clude in cfg['cludes']:
opt = '--' + clude['type']
if clude['path']:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2008-10-07 04:43:11
|
Revision: 600
http://safekeep.svn.sourceforge.net/safekeep/?rev=600&view=rev
Author: dimi
Date: 2008-10-07 04:41:41 +0000 (Tue, 07 Oct 2008)
Log Message:
-----------
Frank Crawford <fr...@cr...>
Modified default options for special-file exclusions.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2008-10-07 04:40:49 UTC (rev 599)
+++ safekeep/trunk/safekeep 2008-10-07 04:41:41 UTC (rev 600)
@@ -715,7 +715,7 @@
args.extend(['--force'])
options_append = []
- special_files = ['--exclude-special-files', '--include-symbolic-links']
+ special_files = ['--exclude-device-files', '--exclude-sockets', '--exclude-fifos']
for option in cfg['options']:
if 'special-files' in option:
if 'include' in option['special-files']:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2008-10-07 19:55:44
|
Revision: 603
http://safekeep.svn.sourceforge.net/safekeep/?rev=603&view=rev
Author: dimi
Date: 2008-10-07 19:55:31 +0000 (Tue, 07 Oct 2008)
Log Message:
-----------
New release.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2008-10-07 19:54:50 UTC (rev 602)
+++ safekeep/trunk/safekeep 2008-10-07 19:55:31 UTC (rev 603)
@@ -54,7 +54,7 @@
base_dir = None
PROTOCOL = "1.1"
-VERSION = "1.0.4"
+VERSION = "1.0.5"
VEBOSITY_BY_CLASS = {'DBG': 3, 'INFO': 2, 'WARN': 1, 'ERR': 0}
######################################################################
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2008-10-14 22:07:45
|
Revision: 613
http://safekeep.svn.sourceforge.net/safekeep/?rev=613&view=rev
Author: dimi
Date: 2008-10-14 22:07:36 +0000 (Tue, 14 Oct 2008)
Log Message:
-----------
Fix dopey MySQL dump.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2008-10-08 20:25:12 UTC (rev 612)
+++ safekeep/trunk/safekeep 2008-10-14 22:07:36 UTC (rev 613)
@@ -383,9 +383,9 @@
elif type in ('mysql'):
args = ['mysqldump']
if dump['dbuser']:
- args.extend(['-u', dump['dbuser']])
+ args.extend(['-u' + dump['dbuser']])
if dump['dbpasswd']:
- args.extend(['-p', dump['dbpasswd']])
+ args.extend(['-p' + dump['dbpasswd']])
if dump['db']:
args.append(dump['db'])
else:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2008-11-19 14:19:56
|
Revision: 616
http://safekeep.svn.sourceforge.net/safekeep/?rev=616&view=rev
Author: dimi
Date: 2008-11-19 14:19:46 +0000 (Wed, 19 Nov 2008)
Log Message:
-----------
Add -C to the PG dumps.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2008-10-16 16:14:45 UTC (rev 615)
+++ safekeep/trunk/safekeep 2008-11-19 14:19:46 UTC (rev 616)
@@ -374,6 +374,7 @@
if type in ('postgres', 'postgresql', 'pgsql'):
if dump['db']:
args = ['pg_dump']
+ args.extend('-C')
else:
args = ['pg_dumpall']
if dump['dbuser']:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2008-11-19 14:58:22
|
Revision: 617
http://safekeep.svn.sourceforge.net/safekeep/?rev=617&view=rev
Author: dimi
Date: 2008-11-19 14:58:18 +0000 (Wed, 19 Nov 2008)
Log Message:
-----------
Add SSH verbosity control
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2008-11-19 14:19:46 UTC (rev 616)
+++ safekeep/trunk/safekeep 2008-11-19 14:58:18 UTC (rev 617)
@@ -48,6 +48,7 @@
logbuf = []
is_client = False
verbosity_level = 1
+verbosity_ssh = ''
work_user = getpass.getuser()
backup_user = None
home_dir = None
@@ -709,7 +710,7 @@
args = ['rdiff-backup']
if cfg['host']:
- schema = 'ssh -C -i %s %%s rdiff-backup --server' % (cfg['key_data'])
+ schema = 'ssh %s -C -i %s %%s rdiff-backup --server' % (verbosity_ssh, cfg['key_data'])
args.extend(['--remote-schema', schema])
if force:
@@ -799,7 +800,7 @@
do_server_data_cleanup(cfg)
if cfg['host']:
- cmd = 'ssh -T -i %(key_ctrl)s -l %(user)s %(host)s safekeep --client' % cfg
+ cmd = 'ssh %s -T -i %s -l %s %s safekeep --client' % (verbosity_ssh, cfg['key_ctrl'], cfg['user'], cfg['host'])
else:
cmd = 'safekeep --client'
debug('Run [' + cmd + ']')
@@ -1263,7 +1264,10 @@
if not ok: sys.exit(2)
try:
- global is_client, verbosity_level
+ global is_client, verbosity_level, verbosity_ssh
+
+ if verbosity > 0:
+ verbosity_ssh = '-' + verbosity * 'v'
if mode is 'server':
is_client = False
verbosity_level = 1 + verbosity
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2008-11-19 14:59:57
|
Revision: 618
http://safekeep.svn.sourceforge.net/safekeep/?rev=618&view=rev
Author: dimi
Date: 2008-11-19 14:59:50 +0000 (Wed, 19 Nov 2008)
Log Message:
-----------
Do not compress the SSH transport.
This places significantly higher load on the system, and it's
not likely to be useful as it is handled by rdiff-backup anyway.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2008-11-19 14:58:18 UTC (rev 617)
+++ safekeep/trunk/safekeep 2008-11-19 14:59:50 UTC (rev 618)
@@ -710,7 +710,7 @@
args = ['rdiff-backup']
if cfg['host']:
- schema = 'ssh %s -C -i %s %%s rdiff-backup --server' % (verbosity_ssh, cfg['key_data'])
+ schema = 'ssh %s -i %s %%s rdiff-backup --server' % (verbosity_ssh, cfg['key_data'])
args.extend(['--remote-schema', schema])
if force:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2008-11-19 19:19:28
|
Revision: 625
http://safekeep.svn.sourceforge.net/safekeep/?rev=625&view=rev
Author: dimi
Date: 2008-11-19 19:19:22 +0000 (Wed, 19 Nov 2008)
Log Message:
-----------
Frederic Bourqui <fbo...@ya...>
Recover escaped dashes ('-').
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2008-11-19 19:05:57 UTC (rev 624)
+++ safekeep/trunk/safekeep 2008-11-19 19:19:22 UTC (rev 625)
@@ -493,7 +493,7 @@
return mounts
def map_lvm_device(device):
- device = device.replace('/mapper','').replace('-','/')
+ device = device.replace('/mapper','').replace('-','/').replace('//', '-')
return device.split('/')[-2:]
def check_lvm_information(device):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2008-11-19 19:33:35
|
Revision: 627
http://safekeep.svn.sourceforge.net/safekeep/?rev=627&view=rev
Author: dimi
Date: 2008-11-19 19:33:33 +0000 (Wed, 19 Nov 2008)
Log Message:
-----------
Fix a few typos
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2008-11-19 19:21:51 UTC (rev 626)
+++ safekeep/trunk/safekeep 2008-11-19 19:33:33 UTC (rev 627)
@@ -784,7 +784,7 @@
trickle += ' -u ' + limit_ul
if trickle:
- if !try_to_run(trickle_cmd + ' -V'):
+ if not try_to_run(trickle_cmd + ' -V'):
warn('Trickle not available, bandwidth limiting disabled')
trickle = ''
@@ -1301,7 +1301,7 @@
cfgfile = config_file
props = {}
- def get_int(prop):
+ def get_int(p):
v = props.get(p)
if v is not None and v is not '':
return int(v)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2009-01-13 05:12:01
|
Revision: 629
http://safekeep.svn.sourceforge.net/safekeep/?rev=629&view=rev
Author: dimi
Date: 2009-01-13 05:11:57 +0000 (Tue, 13 Jan 2009)
Log Message:
-----------
Frank Crawford <fr...@cr...>
Don't send out empty emails.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2008-11-19 20:42:39 UTC (rev 628)
+++ safekeep/trunk/safekeep 2009-01-13 05:11:57 UTC (rev 629)
@@ -161,8 +161,9 @@
return ret
def send_notification(email, smtp):
+ global logbuf
+ if not logbuf: return
info('Sending email to %s via %s' % (','.join(email), smtp))
- global logbuf
hostname = socket.gethostname()
msg = 'From: SafeKeep@' + hostname + \
'\r\nTo: ' + ', '.join(email) + \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2009-02-01 17:18:43
|
Revision: 630
http://safekeep.svn.sourceforge.net/safekeep/?rev=630&view=rev
Author: dimi
Date: 2009-02-01 17:18:42 +0000 (Sun, 01 Feb 2009)
Log Message:
-----------
Frank Crawford <fr...@cr...>
Avoid errors when dealing with mounts containing spaces.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2009-01-13 05:11:57 UTC (rev 629)
+++ safekeep/trunk/safekeep 2009-02-01 17:18:42 UTC (rev 630)
@@ -486,11 +486,13 @@
cout.close()
cin.close()
mounts = []
+ pattern = re.compile(r"^(\S+) on (.+) type (\S+) \((\S+)\)")
if reverse:
lines.reverse()
for line in lines:
- (device, blah1, mountpoint, blah2, mounttype, mountoptions) = line.split()
- mounts.append([device, mountpoint, mounttype, mountoptions[1:-1]])
+ matches = pattern.match(line)
+ if not matches is None:
+ mounts.append(matches.groups())
return mounts
def map_lvm_device(device):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2009-03-01 06:16:57
|
Revision: 631
http://safekeep.svn.sourceforge.net/safekeep/?rev=631&view=rev
Author: dimi
Date: 2009-03-01 06:16:52 +0000 (Sun, 01 Mar 2009)
Log Message:
-----------
Frank Crawford <fr...@cr...>
Fix serious typo.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2009-02-01 17:18:42 UTC (rev 630)
+++ safekeep/trunk/safekeep 2009-03-01 06:16:52 UTC (rev 631)
@@ -791,7 +791,7 @@
warn('Trickle not available, bandwidth limiting disabled')
trickle = ''
- schema = '% ssh %s -i %s %%s rdiff-backup --server' % (trickle, verbosity_ssh, cfg['key_data'])
+ schema = '%s ssh %s -i %s %%s rdiff-backup --server' % (trickle, verbosity_ssh, cfg['key_data'])
args.extend(['--remote-schema', schema])
if force:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2009-04-30 17:24:47
|
Revision: 646
http://safekeep.svn.sourceforge.net/safekeep/?rev=646&view=rev
Author: dimi
Date: 2009-04-30 17:24:33 +0000 (Thu, 30 Apr 2009)
Log Message:
-----------
Bryan Talbot <bt...@ae...>
Avoid concatenating non-strings to strings.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2009-03-30 06:51:51 UTC (rev 645)
+++ safekeep/trunk/safekeep 2009-04-30 17:24:33 UTC (rev 646)
@@ -823,7 +823,7 @@
args = []
if nice:
- args.extend(['nice', '-n' + nice])
+ args.extend(['nice', '-n' + str(nice)])
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...> - 2009-05-01 06:26:22
|
Revision: 649
http://safekeep.svn.sourceforge.net/safekeep/?rev=649&view=rev
Author: dimi
Date: 2009-05-01 06:26:21 +0000 (Fri, 01 May 2009)
Log Message:
-----------
These may end up being ints afterall
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2009-05-01 06:25:38 UTC (rev 648)
+++ safekeep/trunk/safekeep 2009-05-01 06:26:21 UTC (rev 649)
@@ -841,9 +841,9 @@
if limit_dl or limit_ul:
trickle = trickle_cmd + ' ' + verbosity_trickle
if limit_dl:
- trickle += ' -d ' + limit_dl
+ trickle += ' -d ' + str(limit_dl)
if limit_ul:
- trickle += ' -u ' + limit_ul
+ trickle += ' -u ' + str(limit_ul)
if trickle:
if not try_to_run(trickle_cmd + ' -V'):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2009-05-01 06:28:17
|
Revision: 650
http://safekeep.svn.sourceforge.net/safekeep/?rev=650&view=rev
Author: dimi
Date: 2009-05-01 06:28:16 +0000 (Fri, 01 May 2009)
Log Message:
-----------
Fix typo
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2009-05-01 06:26:21 UTC (rev 649)
+++ safekeep/trunk/safekeep 2009-05-01 06:28:16 UTC (rev 650)
@@ -123,7 +123,7 @@
def try_to_run(cmd):
cmd = cmd.split(' ')[0]
- proc = popen2.Popen4(args)
+ proc = popen2.Popen4(cmd)
proc.tochild.close()
for line in proc.fromchild:
info(line.rstrip())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2009-05-01 06:37:05
|
Revision: 651
http://safekeep.svn.sourceforge.net/safekeep/?rev=651&view=rev
Author: dimi
Date: 2009-05-01 06:37:04 +0000 (Fri, 01 May 2009)
Log Message:
-----------
Fix test
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2009-05-01 06:28:16 UTC (rev 650)
+++ safekeep/trunk/safekeep 2009-05-01 06:37:04 UTC (rev 651)
@@ -130,7 +130,7 @@
proc.fromchild.close()
rc = proc.wait()
- return os.WIFEXITED(rc)
+ return os.WIFEXITED(rc) and os.WEXITSTATUS(rc) == 0
def spawn(args):
if isinstance(args, str) or isinstance(args, unicode):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2009-05-01 06:39:28
|
Revision: 652
http://safekeep.svn.sourceforge.net/safekeep/?rev=652&view=rev
Author: dimi
Date: 2009-05-01 06:39:27 +0000 (Fri, 01 May 2009)
Log Message:
-----------
Don't strip off the parameters
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2009-05-01 06:37:04 UTC (rev 651)
+++ safekeep/trunk/safekeep 2009-05-01 06:39:27 UTC (rev 652)
@@ -122,7 +122,6 @@
log(msg, 'ERR')
def try_to_run(cmd):
- cmd = cmd.split(' ')[0]
proc = popen2.Popen4(cmd)
proc.tochild.close()
for line in proc.fromchild:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2009-05-01 06:43:02
|
Revision: 653
http://safekeep.svn.sourceforge.net/safekeep/?rev=653&view=rev
Author: dimi
Date: 2009-05-01 06:42:53 +0000 (Fri, 01 May 2009)
Log Message:
-----------
Deh, we have to accept 1 as a status too
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2009-05-01 06:39:27 UTC (rev 652)
+++ safekeep/trunk/safekeep 2009-05-01 06:42:53 UTC (rev 653)
@@ -129,7 +129,7 @@
proc.fromchild.close()
rc = proc.wait()
- return os.WIFEXITED(rc) and os.WEXITSTATUS(rc) == 0
+ return os.WIFEXITED(rc) and os.WEXITSTATUS(rc) in (0,1)
def spawn(args):
if isinstance(args, str) or isinstance(args, unicode):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2009-05-20 20:36:24
|
Revision: 654
http://safekeep.svn.sourceforge.net/safekeep/?rev=654&view=rev
Author: dimi
Date: 2009-05-20 20:36:13 +0000 (Wed, 20 May 2009)
Log Message:
-----------
Prep new release
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2009-05-01 06:42:53 UTC (rev 653)
+++ safekeep/trunk/safekeep 2009-05-20 20:36:13 UTC (rev 654)
@@ -58,7 +58,7 @@
default_bandwidth = {}
PROTOCOL = "1.1"
-VERSION = "1.2.0"
+VERSION = "1.2.1"
VEBOSITY_BY_CLASS = {'DBG': 3, 'INFO': 2, 'WARN': 1, 'ERR': 0}
######################################################################
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <di...@us...> - 2009-08-12 18:29:27
|
Revision: 668
http://safekeep.svn.sourceforge.net/safekeep/?rev=668&view=rev
Author: dimi
Date: 2009-08-12 18:29:20 +0000 (Wed, 12 Aug 2009)
Log Message:
-----------
Frank Crawford <fr...@cr...>
* Convert from popen2, etc, to subprocess module, including changes to
process handling
* Remove Python 2.2 compatibility, as subprocess isn't supported
* Fix up the split of do_spawn, spawn and try_to_run to share code
* Split '-u user' into two arguments for mysqldump as required by recent
versions
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2009-08-12 18:22:51 UTC (rev 667)
+++ safekeep/trunk/safekeep 2009-08-12 18:29:20 UTC (rev 668)
@@ -16,29 +16,14 @@
# along with Safekeep. If not, see <http://www.gnu.org/licenses/>.
from __future__ import generators
-import getopt, os, os.path, popen2, re, sys, fnmatch, stat
+import getopt, os, os.path, re, sys, fnmatch, stat
+import subprocess
import commands, tempfile, time, traceback
import getpass, pwd, xml.dom.minidom
import socket, smtplib
-######################################################################
-# Python 2.2 compatibility
-######################################################################
-# There is no guarantee that we'll continue supporting Python 2.2
-# indefinitely, but we make a reasonable effor to do so as long as
-# it doesn't result in major complication/ugliness.
+from subprocess import PIPE, STDOUT
-try:
- True, False
-except NameError:
- True, False = 1, 0
-
-def enumerate(obj):
- i = -1
- for item in obj:
- i += 1
- yield i, item
-
######################################################################
# Global settings
######################################################################
@@ -56,6 +41,7 @@
home_dir = None
base_dir = None
default_bandwidth = {}
+cmd = "<Missing>"
PROTOCOL = "1.1"
VERSION = "1.2.1"
@@ -121,41 +107,62 @@
def error(msg):
log(msg, 'ERR')
-def do_spawn(args):
+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):
+ 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 + ']')
- cmd = args.split(' ')[0]
+ proc = subprocess.Popen(args, bufsize=1, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
else:
- debug('Run [' + ' '.join(args) + ']')
- cmd = args[0]
- proc = popen2.Popen4(args)
- proc.tochild.close()
- for line in proc.fromchild:
+ # 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)
+ proc.stdin.close()
+ for line in proc.stdout:
info(line.rstrip())
- proc.fromchild.close()
+ proc.stdout.close()
return proc.wait()
-def spawn(args):
- rc = do_spawn(args)
- if os.WIFEXITED(rc):
- if os.WEXITSTATUS(rc) == 0:
- ret = None
- else:
- ret = 'exited with non zero status: %d' % os.WEXITSTATUS(rc)
- elif os.WIFSIGNALED(rc):
- ret = 'killed by signal: %d' % os.WTERMSIG(rc)
- elif os.WCOREDUMP(rc):
- ret = 'coredumped'
+def spawn(args, shell=False):
+ global cmd
+ try:
+ rc = do_spawn(args, shell=shell)
+ except OSError, ex:
+ error("OSError: %s: %s" % (cmd, ex))
+
+ if not rc:
+ ret = None
+ elif rc > 0:
+ ret = 'exited with non zero status: %d' % rc
+ elif rc < 0:
+ ret = 'killed by signal: %d' % -rc
else:
ret = 'unknown exit status: %d' + rc
if ret:
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 try_to_run(args, shell=False):
+ try:
+ rc = do_spawn(args, shell=shell)
+ except OSError, ex:
+ 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
@@ -170,8 +177,8 @@
server.sendmail('SafeKeep@' + hostname, email, msg)
server.quit()
else:
- cmd = '/usr/sbin/sendmail -t'
- pin = os.popen(cmd, 'w')
+ cmd = ['/usr/sbin/sendmail', '-t']
+ pin = subprocess.Popen(cmd, stdin=PIPE).stdin
try:
pin.write(msg)
finally:
@@ -472,7 +479,7 @@
elif type in ('mysql'):
args = ['mysqldump']
if dump['dbuser']:
- args.extend(['-u' + dump['dbuser']])
+ args.extend(['-u', dump['dbuser']])
if dump['dbpasswd']:
args.extend(['-p' + dump['dbpasswd']])
if not dump['db']:
@@ -495,7 +502,7 @@
if passwdfile:
environ['PGPASSFILE'] = passwdfile
try:
- ec = spawn(cmd)
+ ec = spawn(cmd, shell=True)
finally:
if passwdfile:
del os.environ['PGPASSFILE']
@@ -515,7 +522,7 @@
(dump['file'], dump['db'], e))
def lvm_snap_information():
- (cin, cout) = os.popen4(['lvs', '--separator', ':', '--noheadings'])
+ (cin, cout) = cmd_run(['lvs', '--separator', ':', '--noheadings'])
lines = cout.readlines()
cout.close()
cin.close()
@@ -528,7 +535,7 @@
return lvms
def mount_information(reverse = False):
- (cin, cout) = os.popen4('mount')
+ (cin, cout) = cmd_run(['mount'])
lines = cout.readlines()
cout.close()
cin.close()
@@ -947,8 +954,7 @@
cmd = 'ssh %s -T -i %s -l %s %s safekeep --client' % (verbosity_ssh, cfg['key_ctrl'], cfg['user'], cfg['host'])
else:
cmd = 'safekeep --client'
- debug('Run [' + cmd + ']')
- (cin, cout) = os.popen4(cmd)
+ (cin, cout) = cmd_run(cmd)
cin.write('ALOHA: %s, %s\n' % (PROTOCOL, VERSION))
cin.flush()
@@ -1085,7 +1091,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 subprocess.call(gencmd, shell=True):
error('%s: Failed to generate key %s. Skipping client.' % (id, privatekeyfile))
break
if not os.path.isfile(publickeyfile):
@@ -1112,7 +1118,7 @@
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 = os.popen(cmd, 'r')
+ out = subprocess.Popen(cmd, shell=True, stdout=PIPE).stdout
authtext = out.read()
if out.close():
warn('%s: Failed to read the authorized_keys file.' % id)
@@ -1134,7 +1140,7 @@
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 = os.popen(cmd, 'w')
+ 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():
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-01-25 19:30:17
|
Revision: 669
http://safekeep.svn.sourceforge.net/safekeep/?rev=669&view=rev
Author: dimi
Date: 2010-01-25 19:30:10 +0000 (Mon, 25 Jan 2010)
Log Message:
-----------
Use string interpolation instead of concatenation
in most places, to avoid errors when the second arg
is not really a string.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2009-08-12 18:29:20 UTC (rev 668)
+++ safekeep/trunk/safekeep 2010-01-25 19:30:10 UTC (rev 669)
@@ -145,7 +145,7 @@
elif rc < 0:
ret = 'killed by signal: %d' % -rc
else:
- ret = 'unknown exit status: %d' + rc
+ ret = 'unknown exit status: %d' % rc
if ret:
error('%s failed: %s' % (cmd, ret));
return ret
@@ -224,7 +224,7 @@
if not type:
raise ConfigException('You need to specify the database type')
if type not in ('postgres', 'postgresql', 'pgsql', 'mysql'):
- raise ConfigException('Invalid database type: ' + type)
+ raise ConfigException('Invalid database type: %s' % type)
db = dump_el.getAttribute('db')
user = dump_el.getAttribute('user')
dbuser = dump_el.getAttribute('dbuser')
@@ -481,7 +481,7 @@
if dump['dbuser']:
args.extend(['-u', dump['dbuser']])
if dump['dbpasswd']:
- args.extend(['-p' + dump['dbpasswd']])
+ args.extend(['-p%s' % dump['dbpasswd']])
if not dump['db']:
args.append('-A')
args.extend(opts)
@@ -508,7 +508,7 @@
del os.environ['PGPASSFILE']
os.remove(passwdfile)
if ec:
- warn('Can not dump the database: ' + dump['db'])
+ warn('Can not dump the database: %s' % dump['db'])
def do_client_dbdump_teardown(cfg):
debug('Tear down DB dumps')
@@ -584,22 +584,22 @@
device = snap['device']
(lvmdev, snapdev, snapmnt, snaptyp) = gather_snap_information(device, bdir)
if not snapmnt:
- warn('Cannot find the mountpoint for: ' + device)
+ warn('Cannot find the mountpoint for: %s' % device)
continue
args = ['lvcreate', '--snapshot', '--size', snap['size'],
'--name', os.path.basename(snapdev), lvmdev]
ec = spawn(args)
if ec:
- warn('Can not snapshot the device: ' + device)
+ warn('Can not snapshot the device: %s' % device)
continue
# no need to mkdir since the mountpoint already exists
args = ['mount', '-t', snaptyp, snapdev, snapmnt]
ec = spawn(args)
if ec:
- warn('Can not mount the snapshot: ' + device)
+ warn('Can not mount the snapshot: %s' % device)
ret = spawn(['lvremove', '--force', snapdev])
if ret:
- warn('Can not tear down snapshot: ' + device)
+ warn('Can not tear down snapshot: %s' % device)
def do_client_snap_teardown(cfg, bdir):
assert is_temp_root(bdir)
@@ -610,14 +610,14 @@
device = snap['device']
(lvmdev, snapdev, snapmnt, snaptyp) = gather_snap_information(device, bdir)
if not snapmnt:
- warn('Can not find the mountpoint for: ' + device)
+ warn('Can not find the mountpoint for: %s' % device)
continue
ret = spawn(['umount', snapmnt])
if ret:
warn('Can not umount the snapshot: %s' % snapmnt)
ret = spawn(['lvremove', '--force', snapdev])
if ret:
- warn('Can not tear down snapshot: ' + device)
+ warn('Can not tear down snapshot: %s' % device)
######################################################################
# Client implementation
@@ -660,7 +660,7 @@
try:
os.rmdir(bdir)
except Exception, e:
- warn('Failed to remove: ' + bdir)
+ warn('Failed to remove: %s' % bdir)
bdir = '/'
else:
do_client_snap(cfg, bdir)
@@ -677,7 +677,7 @@
ret = spawn(['umount', '-l', bdir])
if ret:
- warn('Failed to unmount: ' + bdir)
+ warn('Failed to unmount: %s' % bdir)
else:
try:
os.rmdir(bdir)
@@ -716,12 +716,12 @@
info("Removing rbind directory %s" % mountpoint)
ret = spawn(['umount', '-l', mountpoint])
if ret:
- warn('Failed to unmount: ' + mountpoint)
+ warn('Failed to unmount: %s' % mountpoint)
else:
try:
os.rmdir(mountpoint)
except Exception, e:
- warn('Failed to remove: ' + mountpoint)
+ warn('Failed to remove: %s' % mountpoint)
else:
ret = spawn(['umount', mountpoint])
if ret:
@@ -730,7 +730,7 @@
info("Removing snapshot %s" % device)
ret = spawn(['lvremove', '--force', device])
if ret:
- warn('Can not tear down snapshot: ' + device)
+ warn('Can not tear down snapshot: %s' % device)
scrubbed = True
# Now cleanup any snapshots still hanging around
@@ -741,7 +741,7 @@
info("Removing snapshot %s" % device)
ret = spawn(['lvremove', '--force', device])
if ret:
- warn('Can not tear down snapshot: ' + device)
+ warn('Can not tear down snapshot: %s' % device)
scrubbed = True
# Now cleanup any safekeep directories still hanging around
@@ -755,7 +755,7 @@
try:
os.rmdir(mountpoint)
except Exception, e:
- warn('Failed to remove: ' + mountpoint)
+ warn('Failed to remove: %s' % mountpoint)
if not scrubbed:
info('No cleanup required')
@@ -796,7 +796,7 @@
elif not line:
break
else:
- send('ERROR Unknown command: ' + line)
+ send('ERROR Unknown command: %s' % line)
break
except Exception, e:
traceback.print_exc(file=sys.stdout)
@@ -1459,7 +1459,7 @@
keys_status = True
do_keys(cfgs, args, identity, keys_status, keys_print, keys_deploy)
else:
- assert False, 'Unknown mode: ' + mode
+ assert False, 'Unknown mode: %s' % (mode)
except Exception, ex:
traceback.print_exc(file=sys.stdout)
error('ERROR: %s' % ex)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-02-09 15:30:47
|
Revision: 670
http://safekeep.svn.sourceforge.net/safekeep/?rev=670&view=rev
Author: dimi
Date: 2010-02-09 15:30:39 +0000 (Tue, 09 Feb 2010)
Log Message:
-----------
Use extend consistently. Kudos to
Bertrand Lecervoisier <ber...@la...>
for finding this bug.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-01-25 19:30:10 UTC (rev 669)
+++ safekeep/trunk/safekeep 2010-02-09 15:30:39 UTC (rev 670)
@@ -462,14 +462,14 @@
if type in ('postgres', 'postgresql', 'pgsql'):
if dump['db']:
args = ['pg_dump']
- args.extend('-C')
+ args.extend(['-C'])
else:
args = ['pg_dumpall']
if dump['dbuser']:
args.extend(['-U', dump['dbuser']])
args.extend(opts)
if dump['db']:
- args.append(dump['db'])
+ args.extend([dump['db']])
if dump['dbpasswd']:
(fd, passwdfile) = tempfile.mkstemp()
f = file(fd)
@@ -483,10 +483,10 @@
if dump['dbpasswd']:
args.extend(['-p%s' % dump['dbpasswd']])
if not dump['db']:
- args.append('-A')
+ args.extend(['-A'])
args.extend(opts)
if dump['db']:
- args.append(dump['db'])
+ args.extend([dump['db']])
else:
warn('Invalid database type: ' + type)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-02-09 15:40:26
|
Revision: 671
http://safekeep.svn.sourceforge.net/safekeep/?rev=671&view=rev
Author: dimi
Date: 2010-02-09 15:40:06 +0000 (Tue, 09 Feb 2010)
Log Message:
-----------
Correctly wrap the file descriptor into a file object.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-02-09 15:30:39 UTC (rev 670)
+++ safekeep/trunk/safekeep 2010-02-09 15:40:06 UTC (rev 671)
@@ -472,7 +472,7 @@
args.extend([dump['db']])
if dump['dbpasswd']:
(fd, passwdfile) = tempfile.mkstemp()
- f = file(fd)
+ f = os.fdopen(fd, 'w')
f.write(dump['dbpasswd'])
f.close()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2010-02-09 16:01:17
|
Revision: 673
http://safekeep.svn.sourceforge.net/safekeep/?rev=673&view=rev
Author: dimi
Date: 2010-02-09 16:01:11 +0000 (Tue, 09 Feb 2010)
Log Message:
-----------
Don't barf when printing Unicode strings
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2010-02-09 15:45:01 UTC (rev 672)
+++ safekeep/trunk/safekeep 2010-02-09 16:01:11 UTC (rev 673)
@@ -52,7 +52,7 @@
######################################################################
def send(msg):
- print msg
+ print msg.encode('utf-8')
sys.stdout.flush()
def log(msg, cls=None):
@@ -75,7 +75,7 @@
if is_client:
send(msg)
else:
- print >> sys.stderr, msg
+ print >> sys.stderr, msg.encode('utf-8')
def info_file(file, marker=None):
info('## File: ' + file)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|