|
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.
|