Link:
http://rakesh.fedorapeople.org/misc/0002--RomBugzillaReporter.py-New-file...
--
rakesh
From 68eb4bf100f023a0b845bb63c1a950a0f3f81e16 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Tue, 23 Dec 2008 21:41:00 +0530
Subject: [PATCH] * RomBugzillaReporter.py: New file.
---
RomBugzillaReporter.py | 108 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 108 insertions(+), 0 deletions(-)
create mode 100644 RomBugzillaReporter.py
diff --git a/RomBugzillaReporter.py b/RomBugzillaReporter.py
new file mode 100644
index 0000000..087f26c
--- /dev/null
+++ b/RomBugzillaReporter.py
@@ -0,0 +1,108 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Rakesh Pandit <rakesh(a)fedoraproject.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with translate; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import os
+
+from bugzilla import Bugzilla
+from ConfigParser import ConfigParser
+
+import RomReporter
+
+
+class BugzillaBaseException(Exception):
+ """
+ RomBugzillaReporter base class exception.
+ """
+ pass
+
+
+class BugzillaLoginException(BugzillaBaseException):
+ """
+ Bugzilla exception for login failure.
+ """
+
+ def __str__(self):
+ """
+ """
+ return "Login failure. Check authentication credentials in
rom.config."
+
+
+class BugzillaConfigfileException(BugzillaBaseException):
+ """
+ Bugzilla exception for config file absense.
+ """
+
+ def __str__(self):
+ """
+ """
+ return "Config file rom.config not found."
+
+
+class RomBugzillaReporter(RomReporter.RomReporter):
+ """
+ Implements a Bugzilla Reporter.
+ """
+
+ def __init__(self, bug_num):
+ """
+ bugNum: Bugzilla Id
+ """
+ RomReporter.RomReporter.__init__(self)
+ self.bugzilla_url = 'https://bugzilla.redhat.com/xmlrpc.cgi'
+
+ self.bugNum = bug_num
+ self.bugzilla = Bugzilla(url=self.bugzilla_url)
+ self._login()
+ return
+
+ def _login(self):
+ """
+ Login to Bugzilla using credentials on rom.config file.
+ """
+ file_object = None
+ file_name = "rom.config"
+ config_parser = ConfigParser()
+
+ try:
+ if os.path.exists(file_name):
+ file_object = open(file_name)
+ elif os.path.exists("/etc/" + file_name):
+ file_object = open("/etc/" + file_name)
+ else:
+ raise BugzillaConfigfileException
+ except IOError:
+ raise BugzillaConfigfileException
+
+ config_parser.readfp(file_object)
+ username = config_parser.get("Details", "username")
+ password = config_parser.get("Details", "password")
+
+ islogin = self.bugzilla.login(username, password)
+ if not islogin:
+ raise BugzillaLoginException
+ return
+
+ def reportBugzilla(self):
+ """
+ Report to Bugzilla.
+ """
+ bug = self.bugzilla.getbug(self.bugNum)
+ bug.addcomment(self.report)
+ return
+
+# RomBugzillaReporter ends here
--
1.6.0.6
Comments ?