FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 05-19-2008, 03:58 PM
Chris Lumens
 
Default Add much better error handling.

---
exception.py | 63 ++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 40 insertions(+), 23 deletions(-)

diff --git a/exception.py b/exception.py
index b6913a4..75aff94 100644
--- a/exception.py
+++ b/exception.py
@@ -283,6 +283,24 @@ def saveToBugzilla(anaconda, exn, dest):
import bugzilla, xmlrpclib
import product, rpmUtils

+ def withBugzillaDo(bz, fn):
+ try:
+ retval = fn(bz)
+ return retval
+ except xmlrpclib.ProtocolError, e:
+ msg = _("Your bug could not be filed due to the following error "
+ "when communicating with bugzilla:

%s" % str(e))
+ except xmlrpclib.Fault, e:
+ msg = _("Your bug could not be filed due to bad information in "
+ "the bug fields. This is most likely an error in "
+ "anaconda:

%s" % str(e))
+ except socket.error, e:
+ msg = _("Your bug could not be filed due to networking problems "
+ "when communicating with bugzilla:

%s" % str(e))
+
+ anaconda.intf.messageWindow(_("Unable To File Bug"), msg)
+ return None
+
if dest[0].strip() == "" or dest[1].strip() == "" or dest[2].strip() == "":
anaconda.intf.messageWindow(_("Invalid Bug Information"),
_("Please provide a valid username, "
@@ -318,30 +336,28 @@ def saveToBugzilla(anaconda, exn, dest):
# Are there any existing bugs with this hash value? If so we will just
# add this traceback to the bug report and put the reporter on the CC
# list. Otherwise, we need to create a new bug.
- try:
- buglist = bz.query({'status_whiteboard': hash})
- except xmlrpclib.ProtocolError, e:
- anaconda.intf.messageWindow(_("Unable To File Bug"),
- _("Your bug could not be filed due to the "
- "following error when communicating with "
- "bugzilla:

%s" % str(e)))
+ buglist = withBugzillaDo(bz, lambda b: b.query({'status_whiteboard': hash}))
+ if buglist is None:
return False

- # FIXME: need to handle all kinds of errors here
if len(buglist) == 0:
- bug = bz.createbug(product=product.productName,
- component="anaconda",
- version=product.productVersion,
- rep_platform=rpmUtils.arch.getBaseArch(),
- bug_severity="medium",
- priority="medium",
- op_sys="Linux",
- bug_file_loc="http://",
- short_desc=dest[2],
- comment="This bug was filed automatically by anaconda.")
+ bug = withBugzillaDo(bz, lambda b: b.createbug(product=product.productName,
+ component="anaconda",
+ version=product.productVersion,
+ rep_platform=rpmUtils.arch.getBaseArch(),
+ bug_severity="medium",
+ priority="medium",
+ op_sys="Linux",
+ bug_file_loc="http://",
+ short_desc=dest[2],
+ comment="This bug was filed automatically by anaconda."))
+ if bug is None:
+ return False
+
bug.setwhiteboard("anaconda_trace_hash:%s" % hash, which="status")
- bz.attachfile(bug.bug_id, exn.tbFile, "Attached traceback automatically from anaconda.",
- contenttype="text/plain")
+ withBugzillaDo(bz, lambda b: b.attachfile(bug.bug_id, exn.tbFile,
+ "Attached traceback automatically from anaconda.",
+ contenttype="text/plain"))

# Tell the user we created a new bug for them and that they should
# go add a descriptive comment.
@@ -355,9 +371,10 @@ def saveToBugzilla(anaconda, exn, dest):
sys.exit(0)
else:
id = buglist[0].bug_id
- bz.attachfile(id, exn.tbFile, "Attached traceback automatically from anaconda.",
- contenttype="text/plain")
- bz._updatecc(id, [dest[0]], "add")
+ withBugzillaDo(bz, lambda b: b.attachfile(id, exn.tbFile,
+ "Attached traceback automatically from anaconda.",
+ contenttype="text/plain"))
+ withBugzillaDo(bz, lambda b: b._updatecc(id, [dest[0]], "add"))

# Tell the user which bug they've been CC'd on and that they should
# go add a descriptive comment.
--
1.5.4.5

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 09:48 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org