From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RqnCx-0006e3-PF for garchives@archives.gentoo.org; Fri, 27 Jan 2012 14:55:20 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E658EE0942; Fri, 27 Jan 2012 14:55:12 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id A72F2E0942 for ; Fri, 27 Jan 2012 14:55:12 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E7B531B400A for ; Fri, 27 Jan 2012 14:55:11 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 38F0080044 for ; Fri, 27 Jan 2012 14:55:11 +0000 (UTC) From: "Paweł Hajdan" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Paweł Hajdan" Message-ID: <8aff939c6831ac73eb6a6a4a07a6c475e15ed308.phajdan.jr@gentoo> Subject: [gentoo-commits] proj/arch-tools:master commit in: / X-VCS-Repository: proj/arch-tools X-VCS-Files: .gitignore bugzilla-viewer.py common.py maintainer-timeout.py stabilization-candidates.py X-VCS-Directories: / X-VCS-Committer: phajdan.jr X-VCS-Committer-Name: Paweł Hajdan X-VCS-Revision: 8aff939c6831ac73eb6a6a4a07a6c475e15ed308 Date: Fri, 27 Jan 2012 14:55:11 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 01057e8e-b480-4225-97a7-a86f6ffd68eb X-Archives-Hash: e0678790c02119a3bde9d7f367a05cfa commit: 8aff939c6831ac73eb6a6a4a07a6c475e15ed308 Author: Pawel Hajdan, Jr gentoo org> AuthorDate: Fri Jan 27 14:54:19 2012 +0000 Commit: Pawe=C5=82 Hajdan gentoo org> CommitDate: Fri Jan 27 14:54:19 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/arch-tools.gi= t;a=3Dcommit;h=3D8aff939c Begin work on maintainer-timeout script. Extract common parts to common.py Fix bug where only first 100 bug details were retrieved from Bugzilla. --- .gitignore | 1 + bugzilla-viewer.py | 77 ++------------------------------- common.py | 100 +++++++++++++++++++++++++++++++++++++= ++++++ maintainer-timeout.py | 51 ++++++++++++++++++++++ stabilization-candidates.py | 8 +++- 5 files changed, 162 insertions(+), 75 deletions(-) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py index e3cbcac..8a1e131 100755 --- a/bugzilla-viewer.py +++ b/bugzilla-viewer.py @@ -15,32 +15,7 @@ import xml.etree import bugz.bugzilla import portage.versions =20 -CPV_REGEX =3D re.compile("[A-Za-z0-9+_.-]+/[A-Za-z0-9+_-]+-[0-9]+(?:\.[0= -9]+)*[a-z0-9_]*(?:-r[0-9]+)?") - -# Snippet from http://bugs.python.org/issue9584 -def expand_braces(orig): - r =3D r'.*(\{.+?[^\\]\})' - p =3D re.compile(r) - - s =3D orig[:] - res =3D list() - - m =3D p.search(s) - if m is not None: - sub =3D m.group(1) - open_brace =3D s.find(sub) - close_brace =3D open_brace + len(sub) - 1 - if ',' in sub: - for pat in sub.strip('{}').split(','): - res.extend(expand_braces(s[:open_brace] + pat + s[close_brace+1:])) - - else: - res.extend(expand_braces(s[:open_brace] + sub.replace('}', '\\}') + s= [close_brace+1:])) - - else: - res.append(s.replace('\\}', '}')) - - return list(set(res)) +from common import Bug, chunks =20 def unicode_sanitize(text): """Converts a possibly unicode text to a regular string.""" @@ -53,52 +28,6 @@ def unicode_sanitize(text): class TermTooSmall(Exception): pass =20 -class Bug: - def __init__(self, xml=3DNone, id_number=3DNone, summary=3DNone, status= =3DNone): - if xml is not None: - self.__id =3D int(xml.find("bug_id").text) - self.__summary =3D xml.find("short_desc").text - self.__status =3D xml.find("bug_status").text - self.__depends_on =3D [int(dep.text) for dep in xml.findall("dependso= n")] - self.__comments =3D [c.find("who").text + "\n" + c.find("thetext").te= xt for c in xml.findall("long_desc")] - if id_number is not None: - self.__id =3D id_number - if summary is not None: - self.__summary =3D summary - if status is not None: - self.__status =3D status - self.__cpvs_detected =3D False - self.__cpvs =3D [] -=09 - def detect_cpvs(self): - if self.__cpvs_detected: - return - for cpv_string in list(set([self.summary()] + expand_braces(self.summa= ry()))): - 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 =3D list(set(self.__cpvs)) - self.__cpvs_detected =3D True -=09 - def id_number(self): - return self.__id -=09 - def summary(self): - return self.__summary -=09 - def status(self): - return self.__status -=09 - def depends_on(self): - return self.__depends_on -=09 - def comments(self): - return self.__comments -=09 - def cpvs(self): - assert(self.__cpvs_detected) - return self.__cpvs - class BugQueue: def __init__(self): self.__bug_list =3D [] @@ -320,8 +249,10 @@ if __name__ =3D=3D "__main__": } if options.security: criteria['assigned_to'] =3D 'security@gentoo.org' + bugs =3D [] raw_bugs =3D bugzilla.search("", **criteria) - bugs =3D [Bug(xml) for xml in bugzilla.get([bug['bugid'] for bug in raw= _bugs]).findall("bug")] + for chunk in chunks(raw_bugs, 100): + bugs +=3D [Bug(xml) for xml in bugzilla.get([bug['bugid'] for bug in = chunk]).findall("bug")] =20 if not bugs: print 'The bug list is empty. Exiting.' diff --git a/common.py b/common.py new file mode 100644 index 0000000..d6841fb --- /dev/null +++ b/common.py @@ -0,0 +1,100 @@ +# Copyright 2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +import cStringIO +import re + +import portage + + +CPV_REGEX =3D re.compile("[A-Za-z0-9+_.-]+/[A-Za-z0-9+_-]+-[0-9]+(?:\.[0= -9]+)*[a-z0-9_]*(?:-r[0-9]+)?") + + +def chunks(iterable, length): + for i in range(0, len(iterable), length): + yield iterable[i:i + length] + + +# Snippet from http://bugs.python.org/issue9584 +def expand_braces(orig): + r =3D r'.*(\{.+?[^\\]\})' + p =3D re.compile(r) + + s =3D orig[:] + res =3D list() + + m =3D p.search(s) + if m is not None: + sub =3D m.group(1) + open_brace =3D s.find(sub) + close_brace =3D open_brace + len(sub) - 1 + if ',' in sub: + for pat in sub.strip('{}').split(','): + res.extend(expand_braces(s[:open_brace] + pat + s[close_brace+1:])) + + else: + res.extend(expand_braces(s[:open_brace] + sub.replace('}', '\\}') + s= [close_brace+1:])) + + else: + res.append(s.replace('\\}', '}')) + + return list(set(res)) + + +class Bug: + def __init__(self, xml=3DNone, id_number=3DNone, summary=3DNone, status= =3DNone): + if xml is not None: + self.__id =3D int(xml.find("bug_id").text) + self.__summary =3D xml.find("short_desc").text + self.__status =3D xml.find("bug_status").text + self.__depends_on =3D [int(dep.text) for dep in xml.findall("dependso= n")] + self.__comments =3D [c.find("who").text + "\n" + c.find("thetext").te= xt for c in xml.findall("long_desc")] + self.__cc =3D [cc.text for cc in xml.findall("cc")] + + self.__keywords =3D [] + keywords_elem =3D xml.find("keywords") + if keywords_elem is not None and keywords_elem.text: + self.__keywords =3D [k.strip() for k in keywords_elem.text.split(","= )] + if id_number is not None: + self.__id =3D id_number + if summary is not None: + self.__summary =3D summary + if status is not None: + self.__status =3D status + self.__cpvs_detected =3D False + self.__cpvs =3D [] +=09 + def detect_cpvs(self): + if self.__cpvs_detected: + return + for cpv_string in list(set([self.summary()] + expand_braces(self.summa= ry()))): + 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 =3D list(set(self.__cpvs)) + self.__cpvs_detected =3D True +=09 + def id_number(self): + return self.__id +=09 + def summary(self): + return self.__summary +=09 + def status(self): + return self.__status +=09 + def depends_on(self): + return self.__depends_on +=09 + def comments(self): + return self.__comments +=09 + def cc(self): + return self.__cc + + def keywords(self): + return self.__keywords +=09 + def cpvs(self): + assert(self.__cpvs_detected) + return self.__cpvs diff --git a/maintainer-timeout.py b/maintainer-timeout.py new file mode 100755 index 0000000..c75edd6 --- /dev/null +++ b/maintainer-timeout.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +# Copyright 2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +import optparse + +import bugz.bugzilla +import portage.versions + +from common import Bug, chunks + + +class MyBugz(bugz.bugzilla.Bugz): + def get_input(self, prompt): + return raw_input(prompt) + + +if __name__ =3D=3D "__main__": + parser =3D optparse.OptionParser() + (options, args) =3D parser.parse_args() + if args: + parser.error("unrecognized command-line args") + + url =3D 'https://bugs.gentoo.org' + print 'You may be prompted for your Gentoo Bugzilla username and passwo= rd (%s).' % url + bugzilla =3D MyBugz(url, forget=3DTrue) + bugzilla.auth() +=09 + bugs =3D [] + raw_bugs =3D bugzilla.search('please stabilize', reporter=3Dbugzilla.us= er, status=3DNone) + for chunk in chunks(raw_bugs, 100): + bugs +=3D [Bug(xml) for xml in bugzilla.get([bug['bugid'] for bug in = chunk]).findall("bug")] + for bug in bugs: + if 'STABLEREQ' in bug.keywords(): + continue + arch_found =3D False + for arch in portage.archlist: + if '%s@gentoo.org' % arch in bug.cc(): + arch_found =3D True + break + if arch_found: + continue + if len(bug.comments()) > 1: + continue + bug.detect_cpvs() + if len(bug.cpvs()) !=3D 1: + continue + cp =3D portage.versions.cpv_getkey(bug.cpvs()[0]) + for cpv in portage.portdb.cp_list(cp): + print portage.portdb.aux_get(cpv, ['KEYWORDS']) + print (bug.id_number(), bug.summary(), cp) diff --git a/stabilization-candidates.py b/stabilization-candidates.py index 62efa04..1a7211c 100755 --- a/stabilization-candidates.py +++ b/stabilization-candidates.py @@ -115,8 +115,12 @@ if __name__ =3D=3D "__main__": ebuild_name =3D portage.versions.catsplit(best_candidate)[1] + ".ebuil= d" ebuild_path =3D os.path.join(cvs_path, ebuild_name) manifest_path =3D os.path.join(cvs_path, 'Manifest') - original_contents =3D open(ebuild_path).read() - manifest_contents =3D open(manifest_path).read() + try: + original_contents =3D open(ebuild_path).read() + manifest_contents =3D open(manifest_path).read() + except IOError, e: + print e + continue try: for arch in options.arch: subprocess.check_output(["ekeyword", arch, ebuild_name], cwd=3Dcvs_p= ath)