From b7e49d1510ae4b0fdeb8079352d02558d4ce73db Mon Sep 17 00:00:00 2001 From: Krytarik Raido Date: Sun, 11 Mar 2018 08:04:04 +0100 Subject: [PATCH] Bugtracker: Make SOAP trackers work on Python 3 too. * Debian, and Mantis. --- Bugtracker/__init__.py | 2 +- Bugtracker/plugin.py | 31 +++++++++++++------------------ 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/Bugtracker/__init__.py b/Bugtracker/__init__.py index ed8b971..ffc4bd4 100644 --- a/Bugtracker/__init__.py +++ b/Bugtracker/__init__.py @@ -24,7 +24,7 @@ import supybot.world as world from imp import reload -__version__ = "3.2.0" +__version__ = "3.3.0" __author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@tuxgarage.com") __contributors__ = { supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Author'], diff --git a/Bugtracker/plugin.py b/Bugtracker/plugin.py index 90ca631..aef9b80 100644 --- a/Bugtracker/plugin.py +++ b/Bugtracker/plugin.py @@ -27,8 +27,7 @@ import supybot.log as supylog import re, os, sys, time, json import xml.dom.minidom as minidom from email.parser import FeedParser -if sys.version_info < (3,0): - from SOAPpy.Client import SOAPProxy +from pysimplesoap.client import SoapClient def registerBugtracker(name, url='', description='', trackertype=''): conf.supybot.plugins.Bugtracker.bugtrackers().add(name) @@ -771,27 +770,24 @@ class Launchpad(IBugtracker): # class Debbugs(IBugtracker): def __init__(self, *args, **kwargs): - if not sys.version_info < (3,0): - # XXX python3 does not have SOAPpy, so just quit here (for now) - return IBugtracker.__init__(self, *args, **kwargs) - self.soap_proxy = SOAPProxy("%s/cgi-bin/soap.cgi" % self.url, namespace="Debbugs/SOAP") + self.soap_client = SoapClient("%s/cgi-bin/soap.cgi" % self.url, namespace="Debbugs/SOAP") def get_bug(self, id): url = "%s/cgi-bin/bugreport.cgi?bug=%d" % (self.url, id) try: - raw = self.soap_proxy.get_status(id) + raw = self.soap_client.get_status(bugs=id) except Exception as e: raise BugtrackerError(self.errget % (self.description, e, url)) - if not raw: + if not hasattr(raw, 'item'): raise BugNotFoundError try: - raw = raw['item']['value'] - if raw['fixed_versions']: + raw = raw.item.value + if str(raw.fixed_versions): status = 'Fixed' else: status = 'Open' - return (id, raw['package'], raw['subject'], raw['severity'], status, '', "%s/%d" % (self.url, id), [], []) + return (id, str(raw.package), str(raw.subject), str(raw.severity), status, '', "%s/%d" % (self.url, id), [], []) except Exception as e: raise BugtrackerError(self.errparse % (self.description, e, url)) @@ -930,11 +926,8 @@ class Gitea(IBugtracker): class Mantis(IBugtracker): def __init__(self, *args, **kwargs): - if not sys.version_info < (3,0): - # XXX python3 does not have SOAPpy, so just quit here (for now) - return IBugtracker.__init__(self, *args, **kwargs) - self.soap_proxy = SOAPProxy("%s/api/soap/mantisconnect.php" % self.url, namespace="http://futureware.biz/mantisconnect") + self.soap_client = SoapClient("%s/api/soap/mantisconnect.php" % self.url, namespace="http://futureware.biz/mantisconnect") def get_tracker(self, url): try: @@ -964,17 +957,19 @@ class Mantis(IBugtracker): def get_bug_old(self, id): # Deprecated url = "%s/view.php?id=%d" % (self.url, id) try: - raw = self.soap_proxy.mc_issue_get('', '', id) + raw = self.soap_client.mc_issue_get(username='', password='', issue_id=id) except Exception as e: + if 'Issue #%d not found' % id in str(e): + raise BugNotFoundError # Often SOAP is not enabled if '.' in self.name: supylog.exception(self.errget % (self.description, e, url)) return raise BugtrackerError(self.errget % (self.description, e, url)) - if not raw: + if not hasattr(raw, 'id'): raise BugNotFoundError try: - return (id, raw['project']['name'], raw['summary'], raw['severity']['name'], raw['resolution']['name'], '', url, [], []) + return (id, str(raw.project.name), str(raw.summary), str(raw.severity.name), str(raw.resolution.name), '', url, [], []) except Exception as e: raise BugtrackerError(self.errparse % (self.description, e, url))