Squish: Remove unused workaround code

We have not been using this for more than a year.
Instead, we seem to prefer having workaround code inline.

Change-Id: I37066f359eac5eda62c9c9acfcae3b89f980d024
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Robert Loehning
2019-04-03 14:56:30 +02:00
parent ce9a059388
commit fc8dea8830

View File

@@ -59,13 +59,6 @@ JIRA_URL='https://bugreports.qt.io/browse'
class JIRA: class JIRA:
__instance__ = None __instance__ = None
# internal exception to be used inside workaround functions (lack of having return values)
class JiraException(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
# Helper class # Helper class
class Bug: class Bug:
CREATOR = 'QTCREATORBUG' CREATOR = 'QTCREATORBUG'
@@ -93,45 +86,12 @@ class JIRA:
def __setattr__(self, attr, value): def __setattr__(self, attr, value):
return setattr(self.__instance__, attr, value) return setattr(self.__instance__, attr, value)
# function to get an instance of the singleton
@staticmethod
def getInstance():
if '_JIRA__instance__' in JIRA.__dict__:
return JIRA.__instance__
else:
return JIRA.__impl(0, Bug.CREATOR)
# function to check if the given bug is open or not # function to check if the given bug is open or not
@staticmethod @staticmethod
def isBugStillOpen(number, bugType=Bug.CREATOR): def isBugStillOpen(number, bugType=Bug.CREATOR):
tmpJIRA = JIRA(number, bugType) tmpJIRA = JIRA(number, bugType)
return tmpJIRA.isOpen() return tmpJIRA.isOpen()
# function that performs the workaround (function) for the given bug
# if the function needs additional arguments pass them as 3rd parameter
@staticmethod
def performWorkaroundForBug(number, bugType=Bug.CREATOR, *args):
if not JIRA.isBugStillOpen(number, bugType):
test.warning("Bug %s-%d is closed for version %s." %
(bugType, number, JIRA(number, bugType)._fix),
"You should probably remove potential code inside workarounds.py")
functionToCall = JIRA.getInstance().__bugs__.get("%s-%d" % (bugType, number), None)
if functionToCall:
test.warning("Using workaround for %s-%d" % (bugType, number))
try:
functionToCall(*args)
except:
t, v = sys.exc_info()[0:2]
if t == JIRA.JiraException:
raise JIRA.JiraException(v)
else:
test.warning("Exception caught while executing workaround function.",
"%s (%s)" % (str(t), str(v)))
return True
else:
JIRA.getInstance()._exitFatal_(bugType, number)
return False
# implementation of JIRA singleton # implementation of JIRA singleton
class __impl: class __impl:
# constructor of __impl # constructor of __impl
@@ -139,8 +99,6 @@ class JIRA:
self._number = number self._number = number
self._bugType = bugType self._bugType = bugType
self._fix = None self._fix = None
self._localOnly = os.getenv("SYSTEST_JIRA_NO_LOOKUP")=="1"
self.__initBugDict__()
self._fetchResults_ = {} self._fetchResults_ = {}
self.__fetchResolutionFromJira__() self.__fetchResolutionFromJira__()
@@ -169,30 +127,23 @@ class JIRA:
return return
data = None data = None
proxy = os.getenv("SYSTEST_PROXY", None) proxy = os.getenv("SYSTEST_PROXY", None)
if not self._localOnly: try:
try: if proxy:
if proxy: proxy = urllib2.ProxyHandler({'https': proxy})
proxy = urllib2.ProxyHandler({'https': proxy}) opener = urllib2.build_opener(proxy)
opener = urllib2.build_opener(proxy) urllib2.install_opener(opener)
urllib2.install_opener(opener) bugReport = urllib2.urlopen('%s/%s' % (JIRA_URL, bug))
bugReport = urllib2.urlopen('%s/%s' % (JIRA_URL, bug)) data = bugReport.read()
data = bugReport.read() except:
except: data = self.__tryExternalTools__(proxy)
data = self.__tryExternalTools__(proxy) if data == None:
if data == None: test.warning("Sorry, ssl module missing - cannot fetch data via HTTPS",
test.warning("Sorry, ssl module missing - cannot fetch data via HTTPS", "Try to install the ssl module by yourself, or set the python "
"Try to install the ssl module by yourself, or set the python " "path inside SQUISHDIR/etc/paths.ini to use a python version with "
"path inside SQUISHDIR/etc/paths.ini to use a python version with " "ssl support OR install wget or curl to get rid of this warning!")
"ssl support OR install wget or curl to get rid of this warning!")
self._localOnly = True
if data == None: if data == None:
if bug in self.__bugs__: test.fatal("No resolution info for %s" % bug)
test.warning("Using internal dict - bug status could have changed already", self._resolution = 'Done'
"Please check manually!")
self._resolution = None
else:
test.fatal("No workaround function deposited for %s" % bug)
self._resolution = 'Done'
else: else:
data = data.replace("\r", "").replace("\n", "") data = data.replace("\r", "").replace("\n", "")
resPattern = re.compile('<span\s+id="resolution-val".*?>(?P<resolution>.*?)</span>') resPattern = re.compile('<span\s+id="resolution-val".*?>(?P<resolution>.*?)</span>')
@@ -249,14 +200,3 @@ class JIRA:
"%s[...]" % fetched[:200]) "%s[...]" % fetched[:200])
else: else:
test.log("Fetched and cropped data: [...]%s[...]" % fetched[resoInd-20:resoInd+100]) test.log("Fetched and cropped data: [...]%s[...]" % fetched[resoInd-20:resoInd+100])
# this function initializes the bug dict for localOnly usage and
# for later lookup which function to call for which bug
# ALWAYS update this dict when adding a new function for a workaround!
def __initBugDict__(self):
self.__bugs__= {}
# helper function - will be called if no workaround for the requested bug is deposited
def _exitFatal_(self, bugType, number):
test.fatal("No workaround found for bug %s-%d" % (bugType, number))
############### functions that hold workarounds #################################