diff options
author | 2014-02-11 19:21:45 +0100 | |
---|---|---|
committer | 2014-02-11 19:21:45 +0100 | |
commit | 709e4466eb1a8d3c19d522bb2539a821b133bd76 (patch) | |
tree | a2511fc6661868e3ab6dfc57992fc70101048aeb | |
parent | Use python2 as interpreter (diff) | |
download | arch-tools-709e4466eb1a8d3c19d522bb2539a821b133bd76.tar.gz arch-tools-709e4466eb1a8d3c19d522bb2539a821b133bd76.tar.bz2 arch-tools-709e4466eb1a8d3c19d522bb2539a821b133bd76.zip |
Fix maintainer-tiemout.py
- adjust search strings for new bug template
- port to new pybugz
-rw-r--r-- | common.py | 17 | ||||
-rwxr-xr-x | maintainer-timeout.py | 65 |
2 files changed, 48 insertions, 34 deletions
@@ -43,6 +43,15 @@ def expand_braces(orig): return list(set(res)) +def detect_cpvs(text): + cpvs = [] + for cpv_string in list(set([text] + expand_braces(text))): + for cpv_candidate in CPV_REGEX.findall(cpv_string): + if portage.db["/"]["porttree"].dbapi.cpv_exists(cpv_candidate): + cpvs.append(cpv_candidate) + return list(set(cpvs)) + + def get_input(prompt): return raw_input(prompt) @@ -63,6 +72,8 @@ def login(bugzilla): print 'Logging in' bugzilla.User.login(params) + return user + class Bug: def __init__(self, xml=None, id_number=None, summary=None, status=None): @@ -91,11 +102,7 @@ class Bug: def detect_cpvs(self): if self.__cpvs_detected: return - for cpv_string in list(set([self.summary()] + expand_braces(self.summary()))): - for cpv_candidate in CPV_REGEX.findall(cpv_string): - if portage.db["/"]["porttree"].dbapi.cpv_exists(cpv_candidate): - self.__cpvs.append(cpv_candidate) - self.__cpvs = list(set(self.__cpvs)) + self.__cpvs = detect_cpvs(self.summary()) self.__cpvs_detected = True def id_number(self): diff --git a/maintainer-timeout.py b/maintainer-timeout.py index ad5593f..ba8c322 100755 --- a/maintainer-timeout.py +++ b/maintainer-timeout.py @@ -7,17 +7,16 @@ import optparse import os.path import sys -sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'third_party', 'pybugz-0.9.3')) - -import bugz.bugzilla +from bugz.bugzilla import BugzillaProxy import portage.versions -from common import Bug, chunks +from common import Bug, chunks, login, detect_cpvs -class MyBugz(bugz.bugzilla.Bugz): - def get_input(self, prompt): - return raw_input(prompt) +def keyword_to_email(keyword): + if keyword == 'arm64': + keyword = 'arm' + return '%s@gentoo.org' % keyword if __name__ == "__main__": @@ -27,48 +26,56 @@ if __name__ == "__main__": if args: parser.error("unrecognized command-line args") - url = 'https://bugs.gentoo.org' - print 'You may be prompted for your Gentoo Bugzilla username and password (%s).' % url - bugzilla = MyBugz(url, forget=True) - bugzilla.auth() + url = 'https://bugs.gentoo.org/xmlrpc.cgi' + print 'You will be prompted for your Gentoo Bugzilla username and password (%s).' % url + bugzilla = BugzillaProxy(url) + user = login(bugzilla) - bugs = [] - raw_bugs = bugzilla.search('please stabilize', reporter=bugzilla.user, status=None) - for chunk in chunks(raw_bugs, 100): - bugs += [Bug(xml) for xml in bugzilla.get([bug['bugid'] for bug in chunk]).findall("bug")] + bugs = bugzilla.Bug.search({'reporter': user, 'summary': ['stabilize', 'stabilization', 'stable'], 'resolution': ''})['bugs'] + comments = bugzilla.Bug.comments({'ids': [bug['id'] for bug in bugs]}) for bug in bugs: # Skip bugs where stabilization seems to be already in progress. arch_found = False for arch in portage.archlist: - if '%s@gentoo.org' % arch in bug.cc(): + if '%s@gentoo.org' % arch in bug['cc']: arch_found = True break if arch_found: continue + # Skip bugs without STABLEREQ keyword. + if 'STABLEREQ' not in bug['keywords']: + continue + # Skip bugs with comments, they may indicate objections or problem reports. - if len(bug.comments()) > 1: + if len(comments['bugs'][str(bug['id'])]['comments']) > 1: continue # Skip too recent bugs. - if datetime.datetime.now() - bug.creation_timestamp() < datetime.timedelta(days=options.days): + creation_time = datetime.datetime.strptime(str(bug['creation_time']), '%Y%m%dT%H:%M:%S') + if datetime.datetime.now() - creation_time < datetime.timedelta(days=options.days): continue - bug.detect_cpvs() - if len(bug.cpvs()) != 1: + cpvs = detect_cpvs(bug['summary']) + if len(cpvs) != 1: continue + target_keywords = set() - cp = portage.versions.cpv_getkey(bug.cpvs()[0]) + cp = portage.versions.cpv_getkey(cpvs[0]) for cpv in portage.portdb.cp_list(cp): for keyword in portage.portdb.aux_get(cpv, ['KEYWORDS'])[0].split(): if '~' not in keyword and '-' not in keyword: target_keywords.add(keyword) - bugzilla.modify( - bug.id_number(), - comment='Maintainer timeout (%d days). Arches please go ahead.' % options.days, - add_cc=['%s@gentoo.org' % k for k in target_keywords], - keywords='STABLEREQ') - print 'Updated bug #%d (%s). Target KEYWORDS: %s ;-)' % ( - bug.id_number(), - bug.summary(), + + params = {} + params['ids'] = [bug['id']] + params['cc'] = {} + params['cc']['add'] = list(set(keyword_to_email(k) for k in target_keywords)) + params['comment'] = {} + params['comment']['body'] = 'Maintainer timeout (%d days). Arches please go ahead.' % options.days + + bugzilla.Bug.update(params) + print 'Updated bug #%s (%s). Target KEYWORDS: %s ;-)' % ( + bug['id'], + bug['summary'], ', '.join(list(target_keywords))) |