From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id EE0E5138010 for ; Mon, 8 Oct 2012 16:04:03 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AFA57E030B; Mon, 8 Oct 2012 16:03:21 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 281E8E02FB for ; Mon, 8 Oct 2012 16:03:21 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5A57033C878 for ; Mon, 8 Oct 2012 16:03:20 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id E0E04E5445 for ; Mon, 8 Oct 2012 16:03:18 +0000 (UTC) From: "Paweł Hajdan" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Paweł Hajdan" Message-ID: <1336583970.0b5b0ec58a8551b5fb6ff4386b05a76b7829a0f2.phajdan.jr@gentoo> Subject: [gentoo-commits] proj/arch-tools:master commit in: / X-VCS-Repository: proj/arch-tools X-VCS-Files: batch-stabilize.py X-VCS-Directories: / X-VCS-Committer: phajdan.jr X-VCS-Committer-Name: Paweł Hajdan X-VCS-Revision: 0b5b0ec58a8551b5fb6ff4386b05a76b7829a0f2 X-VCS-Branch: master Date: Mon, 8 Oct 2012 16:03:18 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: a40d13ea-627c-48e0-85df-8dbe5ac66755 X-Archives-Hash: 6aa28f6046b3871b2ea84aef8a71e078 commit: 0b5b0ec58a8551b5fb6ff4386b05a76b7829a0f2 Author: William Hubbs gentoo org> AuthorDate: Sun May 6 18:40:04 2012 +0000 Commit: Paweł Hajdan gentoo org> CommitDate: Wed May 9 17:19:30 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=0b5b0ec5 Convert batch-stabilize.py to new pybugz interface. --- batch-stabilize.py | 59 ++++++++++++++++++++++++++------------------------- 1 files changed, 30 insertions(+), 29 deletions(-) diff --git a/batch-stabilize.py b/batch-stabilize.py index 877e5dc..bede303 100755 --- a/batch-stabilize.py +++ b/batch-stabilize.py @@ -12,7 +12,8 @@ import shutil import subprocess import sys -import bugz.bugzilla +from bugz.bugzilla import BugzillaProxy +from common import login import portage.versions BUG_REGEX = re.compile("[Bb]ug #?(\d+)") @@ -42,10 +43,6 @@ def save_state(done_bugs): with open('batch-stabilize.state', 'w') as state_file: pickle.dump(done_bugs, state_file) -class MyBugz(bugz.bugzilla.Bugz): - def get_input(self, prompt): - return raw_input(prompt) - if __name__ == "__main__": parser = optparse.OptionParser() parser.add_option("--arch", dest="arch", help="Gentoo arch to use, e.g. x86, amd64, ...") @@ -68,10 +65,10 @@ if __name__ == "__main__": with open('batch-stabilize.state', 'r') as state_file: done_bugs = pickle.load(state_file) - url = 'https://bugs.gentoo.org' - print 'You may be prompted for your Gentoo Bugzilla username and password (%s).' % url - bugzilla = MyBugz(url) - 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) + login(bugzilla) with open(options.input_filename, "r") as input_file: stabilization_dict = {} @@ -165,15 +162,18 @@ if __name__ == "__main__": if run_command(["repoman", "commit", "-m", commit_message], cvs_path, log_file)[0] != 0: print '!!! repoman commit failed' sys.exit(1) - bug_xml = bugzilla.get(bug_id).find('bug') + params = {} + params['ids'] = [bug_id] + bug_xml = bugzilla.Bug.get(params)['bugs'][0] has_my_arch = False has_other_arches = False - for cc in bug_xml.findall('cc'): - body, domain = cc.text.split('@', 1) - if domain == 'gentoo.org' and body == options.arch: - has_my_arch = True - if domain == 'gentoo.org' and body in portage.archlist and body != options.arch: - has_other_arches=True + for cc in bug_xml['cc']: + body, domain = cc.split('@', 1) + if domain == 'gentoo.org': + if body == options.arch: + has_my_arch = True + elif body in portage.archlist: + has_other_arches=True if not has_my_arch: print_and_log('Seems that bugzilla has already been updated.', log_file) @@ -184,21 +184,22 @@ if __name__ == "__main__": print_and_log('Posting automated reply in bugzilla...', log_file) # We don't close bugs which still have other arches for obvious reasons, # and security bugs because stabilization is not the last step for them. - if has_other_arches or 'Security' in bug_xml.find('product').text: - bugzilla.modify( - bug_id, - comment='%s stable' % options.arch, - remove_cc='%s@gentoo.org' % options.arch) - print_and_log('Successfully updated bug %d.' % bug_id, log_file) + params = {} + params['ids'] = [bug_id] + params['cc'] = {} + params['cc']['remove'] = ['%s@gentoo.org' % options.arch] + params['comment'] = {} + if has_other_arches or 'Security' in bug_xml['product']: + params['comment']['body'] = '%s stable' % options.arch + log_msg = 'Successfully updated' else: - bugzilla.modify( - bug_id, - comment='%s stable, closing' % options.arch, - remove_cc='%s@gentoo.org' % options.arch, - status='RESOLVED', - resolution='FIXED') - print_and_log('Succesfully updated bug %d and closed it.' % bug_id, log_file) + params['comment']['body'] = '%s stable, closing' % options.arch + params['status'] = 'RESOLVED' + params['resolution'] = 'FIXED' + log_msg = 'Successfully updated and closed' + bugzilla.Bug.update(params) + print_and_log('%s bug %d.' % (log_msg, bug_id), log_file) done_bugs.append(bug_id) save_state(done_bugs)