Mailinglist Archive: opensuse-buildservice (269 mails)

< Previous Next >
[opensuse-buildservice] [PATCH] optionally show tracebacks upon (many) osc errors
  • From: Michael Wolf <maw@xxxxxxxxxx>
  • Date: Fri, 19 Sep 2008 15:10:33 -0500
  • Message-id: <1221855033.10876.35.camel@xxxxxxxxxx>
Yo

Attached is a patch that shows tracebacks upon many osc errors. It's
probably not complete.

The motivation is that when working on plugins (and, I assume, osc
itself), messages you get from the following

except AttributeError, e:
print >>sys.stderr, e
return 1

aren't very helpful, because there's little indication where the problem
lies. But when I add

show-python-tracebacks = true

to my ~/.oscrc, I can see exactly where and how I'm screwing up --
pretty useful.

I have only been running with this patch for about an hour, but it seems
to work pretty well so far.


Michael.

From d49b41bf8675324362338a542f5c045c1e0cc5ea Mon Sep 17 00:00:00 2001
From: Michael Wolf <maw@xxxxxxxxxx>
Date: Fri, 19 Sep 2008 14:09:03 -0500
Subject: [PATCH] Show tracebacks if requested in ~/.oscrc.

---
.../src/clientlib/python/osc/osc/babysitter.py | 27 ++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/buildservice/src/clientlib/python/osc/osc/babysitter.py
b/buildservice/src/clientlib/python/osc/osc/babysitter.py
index 9753940..1014942 100644
--- a/buildservice/src/clientlib/python/osc/osc/babysitter.py
+++ b/buildservice/src/clientlib/python/osc/osc/babysitter.py
@@ -24,6 +24,16 @@ for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM':

def run(prg):

+ def show_traceback():
+ from osc import conf
+ import traceback
+
+ conf.get_config()
+ if conf.config.has_key('show-python-tracebacks'):
+ show_tracebacks = conf.config['show-python-tracebacks'].lower()
+ if show_tracebacks in ['true', '1', 'yes']:
+ traceback.print_exc()
+
try:

try:
@@ -54,30 +64,37 @@ def run(prg):

except oscerr.SignalInterrupt:
print >>sys.stderr, 'killed!'
+ show_traceback()
return 1

except KeyboardInterrupt:
print >>sys.stderr, 'interrupted!'
+ show_traceback()
return 1

except oscerr.UserAbort:
print >>sys.stderr, 'aborted.'
+ show_traceback()
return 1

except oscerr.APIError, e:
print >>sys.stderr, 'BuildService API error:', e.msg
+ show_traceback()
return 1

except oscerr.LinkExpandError, e:
print >>sys.stderr, 'Link cannot be expanded:\n', e
+ show_traceback()
return 1

except oscerr.UnreadableFile, e:
print >>sys.stderr, e.msg
+ show_traceback()
return 1

except (oscerr.NoWorkingCopy, oscerr.WorkingCopyWrongVersion), e:
print >>sys.stderr, e
+ show_traceback()
return 1

except HTTPError, e:
@@ -97,14 +114,17 @@ def run(prg):
msg = msg.split('</summary>')[0]
print >>sys.stderr, msg

+ show_traceback()
return 1

except URLError, e:
print >>sys.stderr, 'Failed to reach a server:', e.reason
+ show_traceback()
return 1

except (oscerr.ConfigError, oscerr.NoConfigfile), e:
print >>sys.stderr, e.msg
+ show_traceback()
return 1

except oscerr.OscIOError, e:
@@ -112,28 +132,35 @@ def run(prg):
if getattr(prg.options, 'debug', None) or \
getattr(prg.conf, 'config', {}).get('debug', None):
print >>sys.stderr, e.e
+ show_traceback()
return 1

except (oscerr.WrongOptions, oscerr.WrongArgs), e:
print >>sys.stderr, e
+ show_traceback()
return 2

except oscerr.WorkingCopyOutdated, e:
print >>sys.stderr, e
+ show_traceback()
return 1

except (oscerr.PackageExists, oscerr.PackageMissing), e:
print >>sys.stderr, e.msg
+ show_traceback()
return 1

except IOError, e:
print >>sys.stderr, e
+ show_traceback()
return 1

except AttributeError, e:
print >>sys.stderr, e
+ show_traceback()
return 1

except RPMError, e:
print >>sys.stderr, e
+ show_traceback()
return 1
--
1.5.6.5

< Previous Next >
Follow Ups