|
From: <fcr...@us...> - 2012-12-29 04:29:52
|
Revision: 827
http://safekeep.svn.sourceforge.net/safekeep/?rev=827&view=rev
Author: fcrawford
Date: 2012-12-29 04:29:43 +0000 (Sat, 29 Dec 2012)
Log Message:
-----------
Handle issues with random characters in log messages.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2012-12-23 08:11:42 UTC (rev 826)
+++ safekeep/trunk/safekeep 2012-12-29 04:29:43 UTC (rev 827)
@@ -92,7 +92,10 @@
return repr(self.value)
def send(msg):
- print msg.encode('utf-8')
+ try:
+ print msg.encode('utf-8', 'backslashreplace')
+ except UnicodeDecodeError:
+ print str(msg).encode('string_escape')
sys.stdout.flush()
def log(msg, cls=None):
@@ -111,11 +114,15 @@
cutoff = VEBOSITY_BY_CLASS.get(cls.upper())
if cutoff is None: cutoff = 3
if is_client or verbosity_level >= cutoff:
- logbuf.append(msg)
+ try:
+ str_msg = msg.encode('utf-8', 'backslashreplace')
+ except UnicodeDecodeError:
+ str_msg = str(msg).encode('string_escape')
+ logbuf.append(str_msg)
if is_client:
- send(msg)
+ send(str_msg)
else:
- print >> sys.stderr, msg.encode('utf-8')
+ print >> sys.stderr, str_msg
def info_file(filename, marker=None, stats=None):
info('# File: ' + filename)
@@ -312,7 +319,7 @@
'Mirror size',
'Total changed') + \
'\r\n',
- '-' * 141 + '\r\n'];
+ '-' * 141 + '\r\n']
for stats in statistics:
result.append(print_stats_table_list_text(stats) + '\r\n' + '-' * 141 + '\r\n')
@@ -330,7 +337,7 @@
'<th>Source size</th>'
'<th>Mirror size</th>'
'<th>Total changed</th>'
- '</tr>'];
+ '</tr>']
for stats in statistics:
result.append(print_stats_table_list_html(stats))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fcr...@us...> - 2012-12-29 08:41:15
|
Revision: 828
http://safekeep.svn.sourceforge.net/safekeep/?rev=828&view=rev
Author: fcrawford
Date: 2012-12-29 08:41:06 +0000 (Sat, 29 Dec 2012)
Log Message:
-----------
Arrange for email to be sent on configuration failures where possible.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2012-12-29 04:29:43 UTC (rev 827)
+++ safekeep/trunk/safekeep 2012-12-29 08:41:06 UTC (rev 828)
@@ -362,6 +362,7 @@
global logbuf
if not logbuf: return
email_to = email.get('to')
+ if not email_to: return
info('Sending email to %s via %s' % (','.join(email_to), email.get('smtp', 'Local')))
hostname = socket.getfqdn()
if 'from' in email:
@@ -1931,7 +1932,7 @@
if 'client.user' in props:
client_user = props['client.user']
for prop in [prop for prop in props if prop.startswith('email.')]:
- if prop == 'email.to':
+ if not noemail and prop == 'email.to':
email['to'] = props[prop].split(',')
elif prop == 'email.format':
email['format'] = props[prop]
@@ -1985,6 +1986,7 @@
error('CONFIG ERROR: %s' % (ex or ''), ex)
else:
error('ERROR: %s' % (ex or ''), ex)
+ send_notification(email, mode)
sys.exit(2)
else:
cfgs = {}
@@ -1999,7 +2001,9 @@
if os.path.isfile(arg):
error('It appears to be a file, configuration files are passed via the -c/--conf switch.')
ok = False
- if not ok: sys.exit(2)
+ if not ok:
+ send_notification(email, mode)
+ sys.exit(2)
try:
global is_client, verbosity_ssh, verbosity_trickle
@@ -2036,8 +2040,7 @@
except Exception, ex:
error('ERROR: %s' % (ex or ''), ex)
- if 'to' in email and not noemail:
- send_notification(email, mode)
+ send_notification(email, mode)
if __name__ == '__main__':
main()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fcr...@us...> - 2012-12-29 09:33:40
|
Revision: 829
http://safekeep.svn.sourceforge.net/safekeep/?rev=829&view=rev
Author: fcrawford
Date: 2012-12-29 09:33:33 +0000 (Sat, 29 Dec 2012)
Log Message:
-----------
Better handling of noemail option.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2012-12-29 08:41:06 UTC (rev 828)
+++ safekeep/trunk/safekeep 2012-12-29 09:33:33 UTC (rev 829)
@@ -1931,19 +1931,22 @@
base_dir = props['base.dir']
if 'client.user' in props:
client_user = props['client.user']
- for prop in [prop for prop in props if prop.startswith('email.')]:
- if not noemail and prop == 'email.to':
- email['to'] = props[prop].split(',')
- elif prop == 'email.format':
- email['format'] = props[prop]
- if email['format'] not in ('text', 'html'):
- error('CONFIG ERROR: invalid email format type: %s' % email['format'])
- sys.exit(2)
- elif prop == 'email.summary':
- if props[prop].lower() in ('true', 'yes', 1):
- email['summary'] = props[prop]
- else:
- email[prop.split('.')[1]] = props[prop]
+ if not noemail:
+ for prop in [prop for prop in props if prop.startswith('email.')]:
+ if not noemail and prop == 'email.to':
+ email['to'] = props[prop].split(',')
+ elif prop == 'email.format':
+ email['format'] = props[prop]
+ if email['format'] not in ('text', 'html'):
+ error('CONFIG ERROR: invalid email format type: %s' % email['format'])
+ sys.exit(2)
+ elif prop == 'email.summary':
+ if props[prop].lower() in ('true', 'yes', 1):
+ email['summary'] = props[prop]
+ else:
+ email[prop.split('.')[1]] = props[prop]
+ else:
+ email = {}
nice_def = get_int('nice.adjustment')
if nice_def is None: nice_def = 10
nice_srv = get_int('nice.adjustment.server') or nice_def
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2012-12-29 13:57:11
|
Revision: 830
http://safekeep.svn.sourceforge.net/safekeep/?rev=830&view=rev
Author: dimi
Date: 2012-12-29 13:57:05 +0000 (Sat, 29 Dec 2012)
Log Message:
-----------
Don't hardcode the config file more than once
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2012-12-29 09:33:33 UTC (rev 829)
+++ safekeep/trunk/safekeep 2012-12-29 13:57:05 UTC (rev 830)
@@ -1828,7 +1828,7 @@
sys.exit(2)
elif o in ('-e', '--email'):
warn('The -e/--email options are deprecated and will be removed in the future')
- warn('Please use the /etc/safekeep/safekeep.conf file instead')
+ warn('Please use the %s instead' % (config_file))
if 'to' in email:
email['to'].append(a)
else:
@@ -1837,7 +1837,7 @@
usage(0)
elif o in ('-s', '--smtp'):
warn('The -s/--smtp options are deprecated and will be removed in the future')
- warn('Please use the /etc/safekeep/safekeep.conf file instead')
+ warn('Please use the %s instead' % (config_file))
email['smtp'] = a
elif o in ('--server', ):
if mode: usage(2)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fcr...@us...> - 2013-01-01 05:53:48
|
Revision: 831
http://safekeep.svn.sourceforge.net/safekeep/?rev=831&view=rev
Author: fcrawford
Date: 2013-01-01 05:53:41 +0000 (Tue, 01 Jan 2013)
Log Message:
-----------
Added Date header in email as requested by Ra?\195?\186l Wegmann <rau...@qr...>
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2012-12-29 13:57:05 UTC (rev 830)
+++ safekeep/trunk/safekeep 2013-01-01 05:53:41 UTC (rev 831)
@@ -371,7 +371,8 @@
email_from = 'SafeKeep@' + hostname
msg = 'From: ' + email_from + '\r\n' + \
'To: ' + ', '.join(email_to) + '\r\n' + \
- 'Subject: SafeKeep results for ' + hostname + '\r\n'
+ 'Subject: SafeKeep results for ' + hostname + '\r\n' + \
+ 'Date: ' + time.strftime("%a, %d %b %Y %H:%M:%S %z") + '\r\n'
if 'format' not in email:
msg += '\r\n' + '\r\n'.join(logbuf) + '\r\n'
else:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fcr...@us...> - 2013-01-01 06:11:46
|
Revision: 832
http://safekeep.svn.sourceforge.net/safekeep/?rev=832&view=rev
Author: fcrawford
Date: 2013-01-01 06:11:39 +0000 (Tue, 01 Jan 2013)
Log Message:
-----------
Protect against simple process names and entries.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2013-01-01 05:53:41 UTC (rev 831)
+++ safekeep/trunk/safekeep 2013-01-01 06:11:39 UTC (rev 832)
@@ -1089,7 +1089,10 @@
proc_file = "/proc/" + pid + "/cmdline"
if pid != current_pid and os.path.exists(proc_file):
fin = open(proc_file, "r")
- (cmd, arg0, args) = fin.read().split('\0', 2)
+ try:
+ (cmd, arg0, args) = fin.read().split('\0', 2)
+ except:
+ arg0 = ''
fin.close()
if os.path.basename(arg0) == "safekeep":
raise Exception('another safekeep process running: pid %s' % pid)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fcr...@us...> - 2013-01-01 07:04:13
|
Revision: 833
http://safekeep.svn.sourceforge.net/safekeep/?rev=833&view=rev
Author: fcrawford
Date: 2013-01-01 07:04:07 +0000 (Tue, 01 Jan 2013)
Log Message:
-----------
Added new PROTOCOL option for passing default options.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2013-01-01 06:11:39 UTC (rev 832)
+++ safekeep/trunk/safekeep 2013-01-01 07:04:07 UTC (rev 833)
@@ -67,6 +67,7 @@
client_user = 'root'
home_dir = None
base_dir = None
+client_defaults = []
current_pid = os.getpid()
default_bandwidth = {}
statistics = []
@@ -75,7 +76,7 @@
# or 'bind' for a bind mount (check mount for details)
default_mountoptions = { 'xfs' : 'ro,nouuid', 'snapshot' : 'ro', 'bind' : 'ro' }
-PROTOCOL = "1.2"
+PROTOCOL = "1.3"
VERSION = "1.4.0"
VEBOSITY_BY_CLASS = {'DBG': 3, 'INFO': 2, 'WARN': 1, 'ERR': 0}
@@ -1194,6 +1195,13 @@
if line.startswith('ALOHA'):
do_client_compat(line.strip().split(':', 1)[1])
send('OK %s, %s' % (PROTOCOL, VERSION))
+ elif line.startswith('DEFAULT'):
+ for opts in line.strip().split(':', 1)[1].split(','):
+ opt, val = opts.strip().split('=')
+ if opt == 'snapshot.size':
+ global default_snapshot
+ default_snapshot = val
+ send('OK')
elif line.startswith('CONFIG'):
cfg = do_client_config(line)
if cfg['script']:
@@ -1409,11 +1417,12 @@
(server_major, server_minor) = PROTOCOL.split('.')
if server_major != client_major:
raise Exception('Incompatible protocols: %s <> %s' % (PROTOCOL, client_protocol))
- elif server_minor > client_minor:
+ elif int(server_minor) > int(client_minor):
warn('Protocol mismatch: %s <> %s' % (PROTOCOL, client_protocol))
+ return (int(server_minor) - int(client_minor))
def do_server(cfgs, ids, nice, ionice, force, cleanup):
- global statistics
+ global statistics, client_defaults
debug("Do server main loop")
output_done = False
for cfg in cfgs.itervalues():
@@ -1462,8 +1471,14 @@
cin.write('ALOHA: %s, %s\n' % (PROTOCOL, VERSION))
cin.flush()
client_versions = do_server_getanswer(cout)
- do_server_compat(client_versions)
+ compat = do_server_compat(client_versions)
+ # This test will need to be improved for later PROTOCOL versions.
+ if compat <= 0 and len(client_defaults):
+ cin.write('DEFAULT: %s\n' % (','.join(client_defaults)))
+ cin.flush()
+ do_server_getanswer(cout)
+
cin.write('CONFIG: %d: %s\n' % (len(cfg['text'].splitlines()), cfg_id))
cin.write(cfg['text'] + '\n')
cin.flush()
@@ -1937,7 +1952,7 @@
client_user = props['client.user']
if not noemail:
for prop in [prop for prop in props if prop.startswith('email.')]:
- if not noemail and prop == 'email.to':
+ if prop == 'email.to':
email['to'] = props[prop].split(',')
elif prop == 'email.format':
email['format'] = props[prop]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2013-01-02 19:31:18
|
Revision: 836
http://safekeep.svn.sourceforge.net/safekeep/?rev=836&view=rev
Author: dimi
Date: 2013-01-02 19:31:12 +0000 (Wed, 02 Jan 2013)
Log Message:
-----------
Better message
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2013-01-01 10:35:18 UTC (rev 835)
+++ safekeep/trunk/safekeep 2013-01-02 19:31:12 UTC (rev 836)
@@ -1425,7 +1425,7 @@
if server_major != client_major:
raise Exception('Incompatible protocols: %s <> %s' % (PROTOCOL, client_protocol))
elif int(server_minor) > int(client_minor):
- warn('Protocol mismatch: %s <> %s' % (PROTOCOL, client_protocol))
+ info('Protocol mismatch, but compatible: %s <> %s' % (PROTOCOL, client_protocol))
return (int(server_minor) - int(client_minor))
def do_server(cfgs, ids, nice, ionice, force, cleanup):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2013-01-02 19:48:28
|
Revision: 837
http://safekeep.svn.sourceforge.net/safekeep/?rev=837&view=rev
Author: dimi
Date: 2013-01-02 19:48:22 +0000 (Wed, 02 Jan 2013)
Log Message:
-----------
Add flexible capability test
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2013-01-02 19:31:12 UTC (rev 836)
+++ safekeep/trunk/safekeep 2013-01-02 19:48:22 UTC (rev 837)
@@ -1418,15 +1418,35 @@
if ret:
warn('Failed to cleanup old data, please fix the problem manually')
+def get_protocol_info(protocol, is_client):
+ (major_s, minor_s) = protocol.strip().split('.')
+ major = int(major_s)
+ minor = int(minor_s)
+
+ caps = []
+ if major == 1:
+ if minor >= 3:
+ caps.append('DEFAULT')
+
+ return {
+ 'version': (major, minor),
+ 'caps': caps
+ }
+
+
def do_server_compat(client_versions):
(client_protocol, client_version) = client_versions.split(',')
- (client_major, client_minor) = client_protocol.strip().split('.')
+ compat = {
+ 'client': get_protocol_info(client_protocol, True),
+ 'server': get_protocol_info(PROTOCOL, False)
+ }
+
(server_major, server_minor) = PROTOCOL.split('.')
- if server_major != client_major:
+ if compat['server']['version'][0] != compat['client']['version'][0]:
raise Exception('Incompatible protocols: %s <> %s' % (PROTOCOL, client_protocol))
- elif int(server_minor) > int(client_minor):
+ elif compat['server']['version'][1] > compat['client']['version'][1]:
info('Protocol mismatch, but compatible: %s <> %s' % (PROTOCOL, client_protocol))
- return (int(server_minor) - int(client_minor))
+ return compat
def do_server(cfgs, ids, nice, ionice, force, cleanup):
global statistics, client_defaults
@@ -1481,7 +1501,7 @@
compat = do_server_compat(client_versions)
# This test will need to be improved for later PROTOCOL versions.
- if compat <= 0 and len(client_defaults):
+ if ('DEFAULT' in compat['client']['caps']) and len(client_defaults):
cin.write('DEFAULT: %s\n' % (','.join(client_defaults)))
cin.flush()
do_server_getanswer(cout)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fcr...@us...> - 2013-01-19 10:28:06
|
Revision: 842
http://safekeep.svn.sourceforge.net/safekeep/?rev=842&view=rev
Author: fcrawford
Date: 2013-01-19 10:27:59 +0000 (Sat, 19 Jan 2013)
Log Message:
-----------
Update version for new release
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2013-01-19 10:10:07 UTC (rev 841)
+++ safekeep/trunk/safekeep 2013-01-19 10:27:59 UTC (rev 842)
@@ -78,7 +78,7 @@
default_mountoptions = { 'xfs' : 'ro,nouuid', 'snapshot' : 'ro', 'bind' : 'ro' }
PROTOCOL = "1.3"
-VERSION = "1.4.0"
+VERSION = "1.4.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: <fcr...@us...> - 2013-02-23 09:40:22
|
Revision: 848
http://safekeep.svn.sourceforge.net/safekeep/?rev=848&view=rev
Author: fcrawford
Date: 2013-02-23 09:40:12 +0000 (Sat, 23 Feb 2013)
Log Message:
-----------
Corrected Python version incompatibility.
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2013-01-19 13:31:12 UTC (rev 847)
+++ safekeep/trunk/safekeep 2013-02-23 09:40:12 UTC (rev 848)
@@ -271,9 +271,9 @@
# Statistics format routines for the "server" type
#
def print_stats_table_server_text(stats):
- result = '|{:<8}|{:<8}'.format(stats['id'], stats['state'])
+ result = '|{0:<8}|{1:<8}'.format(stats['id'], stats['state'])
if (len(stats) > 2):
- result += '|{:>6}|{:<24}|{:<24}|{:>24}|{:>12}|{:>12}|{:>13}|'.format(
+ result += '|{0:>6}|{1:<24}|{2:<24}|{3:>24}|{4:>12}|{5:>12}|{6:>13}|'.format(
stats['Errors'],
stats['StartTime'],
stats['EndTime'],
@@ -312,7 +312,7 @@
def stats_to_table_server_text():
result = ['-' * 141 + '\r\n',
- '|{:<8}|{:<8}|{:<6}|{:<24}|{:<24}|{:<24}|{:<12}|{:<12}|{:<13}|'.format(
+ '|{0:<8}|{1:<8}|{2:<6}|{3:<24}|{4:<24}|{5:<24}|{6:<12}|{7:<12}|{8:<13}|'.format(
'Name',
'State',
'Errors',
@@ -353,9 +353,9 @@
# Statistics format routines for the "list" type
#
def print_stats_table_list_text(stats):
- result = '|{:<8}|{:<8}'.format(stats['id'], stats['state'])
+ result = '|{0:<8}|{1:<8}'.format(stats['id'], stats['state'])
if (len(stats) > 2):
- result += '|{:<24}|{:<24}|{:>10}|'.format(
+ result += '|{0:<24}|{1:<24}|{2:>10}|'.format(
stats['CurrentMirror'],
stats['OldestIncrement'],
stats['Increments'])
@@ -382,7 +382,7 @@
def stats_to_table_list_text():
result = ['-' * 80 + '\r\n',
- '|{:<8}|{:<8}|{:<24}|{:<24}|{:<10}|'.format(
+ '|{0:<8}|{1:<8}|{2:<24}|{3:<24}|{4:<10}|'.format(
'Name',
'State',
'Current Mirror',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fcr...@us...> - 2013-04-21 01:13:38
|
Revision: 849
http://safekeep.svn.sourceforge.net/safekeep/?rev=849&view=rev
Author: fcrawford
Date: 2013-04-21 01:13:29 +0000 (Sun, 21 Apr 2013)
Log Message:
-----------
Corrected issue with safekeep --server --cleanup
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2013-02-23 09:40:12 UTC (rev 848)
+++ safekeep/trunk/safekeep 2013-04-21 01:13:29 UTC (rev 849)
@@ -1528,8 +1528,10 @@
stats['id'] = cfg_id
output_done = True
- cleaned_up = True
+ cleaned_up = not cleanup
try:
+ cin = None
+ cout = None
if cfg['host']:
if not os.path.isfile(cfg['key_ctrl']):
raise Exception('Client %(id)s missing ctrl key %(key_ctrl)s' % cfg)
@@ -1662,8 +1664,8 @@
statistics.append(stats)
# Shutdown client
- cout.close()
- cin.close()
+ if cout: cout.close()
+ if cin: cin.close()
if not cleaned_up:
do_server_rdiff_cleanup(cfg)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|