From 9434dd7a60859bc8b1f72fe28d8733bd0556c385 Mon Sep 17 00:00:00 2001 From: Will Woods Date: Tue, 5 Aug 2008 15:58:19 -0400 Subject: Use Bugzilla32 where applicable --- bugzilla/__init__.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/bugzilla/__init__.py b/bugzilla/__init__.py index 8561921..2e5ee75 100644 --- a/bugzilla/__init__.py +++ b/bugzilla/__init__.py @@ -9,7 +9,7 @@ # option) any later version. See http://www.gnu.org/copyleft/gpl.html for # the full text of the license. -from bugzilla3 import Bugzilla3 +from bugzilla3 import Bugzilla3, Bugzilla32 from rhbugzilla import RHBugzilla import xmlrpclib import logging @@ -17,23 +17,36 @@ log = logging.getLogger("bugzilla") def getBugzillaClassForURL(url): s = xmlrpclib.ServerProxy(url) - # RH Bugzilla method - prodinfo = {} + rhbz = False + bzversion = '' + c = None + + # Check for a RH-only method try: prodinfo = s.bugzilla.getProdInfo() - return RHBugzilla + rhbz = True except xmlrpclib.Fault: pass + # Try to get the bugzilla version string try: r = s.Bugzilla.version() - version = r['version'] - if version.startswith('3.'): - return Bugzilla3 + bzversion = r['version'] except xmlrpclib.Fault: pass - return None + # current preference order: RHBugzilla, Bugzilla3 + # RH BZ 3.2 will have rhbz == True and bzversion == 3.1.x or 3.2.x. + # To prefer Bugzilla32 over RHBugzilla do: if rhbz and (bzversion == '') + if rhbz: + c = RHBugzilla + elif bzversion.startswith('3.'): + if bzversion.startswith('3.0'): + c = Bugzilla3 + else: # 3.1 or higher + c = Bugzilla32 + + return c class Bugzilla(object): '''Magical Bugzilla class that figures out which Bugzilla implementation -- cgit