commit:     2fb3bebf42dd93236157c8d26afc91b932ef24c2
Author:     Agostino Sarubbo <ago <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 13 14:48:58 2014 +0000
Commit:     Agostino Sarubbo <ago <AT> gentoo <DOT> org>
CommitDate: Wed Aug 13 14:48:58 2014 +0000
URL:        
http://git.overlays.gentoo.org/gitweb/?p=dev/ago.git;a=commit;h=2fb3bebf

New version of the batch-* script that work with pybugz-0.10

---
 script/batch-ekeyword-only.py     | 17 +++++-------
 script/batch-keyword.py           | 15 ++++-------
 script/batch-stabilize-force.py   | 54 +++++----------------------------------
 script/batch-stabilize-pretend.py | 15 ++++-------
 script/batch-stabilize.py         | 52 ++++---------------------------------
 5 files changed, 28 insertions(+), 125 deletions(-)

diff --git a/script/batch-ekeyword-only.py b/script/batch-ekeyword-only.py
index 4506001..b4fcd14 100755
--- a/script/batch-ekeyword-only.py
+++ b/script/batch-ekeyword-only.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 # Copyright 2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
@@ -12,7 +12,7 @@ import shutil
 import subprocess
 import sys
 
-import bugz.bugzilla
+from bugz.bugzilla import BugzillaProxy
 import portage.versions
 
 BUG_REGEX = re.compile("[Bb]ug #?(\d+)")
@@ -42,10 +42,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 +64,8 @@ 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'
+       bugzilla = BugzillaProxy(url)
        
        with open(options.input_filename, "r") as input_file:
                stabilization_dict = {}
@@ -136,3 +130,6 @@ if __name__ == "__main__":
                                        if run_command(["repoman", "manifest"], 
cvs_path, log_file)[0] != 0:
                                                print '!!! repoman manifest 
failed'
                                                sys.exit(1)
+
+       if os.path.exists('batch-stabilize.state'):
+               os.remove('batch-stabilize.state')

diff --git a/script/batch-keyword.py b/script/batch-keyword.py
index 1c1c126..d99fdb8 100755
--- a/script/batch-keyword.py
+++ b/script/batch-keyword.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 # Copyright 2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
@@ -12,7 +12,7 @@ import shutil
 import subprocess
 import sys
 
-import bugz.bugzilla
+from bugz.bugzilla import BugzillaProxy
 import portage.versions
 
 BUG_REGEX = re.compile("[Bb]ug #?(\d+)")
@@ -42,10 +42,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 +64,8 @@ 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'
+       bugzilla = BugzillaProxy(url)
        
        with open(options.input_filename, "r") as input_file:
                stabilization_dict = {}
@@ -150,5 +144,6 @@ if __name__ == "__main__":
                                                os.chdir(cvs_path)
                                                os.system("repoman full")
                                                sys.exit(1)
+                                               
        if os.path.exists('batch-stabilize.state'):
                os.remove('batch-stabilize.state')

diff --git a/script/batch-stabilize-force.py b/script/batch-stabilize-force.py
index e6432b9..d335545 100755
--- a/script/batch-stabilize-force.py
+++ b/script/batch-stabilize-force.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 # Copyright 2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
@@ -12,7 +12,7 @@ import shutil
 import subprocess
 import sys
 
-import bugz.bugzilla
+from bugz.bugzilla import BugzillaProxy
 import portage.versions
 
 BUG_REGEX = re.compile("[Bb]ug #?(\d+)")
@@ -42,10 +42,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 +64,8 @@ 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'
+       bugzilla = BugzillaProxy(url)
        
        with open(options.input_filename, "r") as input_file:
                stabilization_dict = {}
@@ -146,46 +140,10 @@ if __name__ == "__main__":
                                                done_bugs.append(bug_id)
                                                save_state(done_bugs)
                                                continue
-                                       if run_command(["repoman", "commit", 
"--include-arches", options.arch, "-f", "-m", commit_message], cvs_path, 
log_file)[0] != 0:
+                                       if run_command(["repoman", "commit", 
"-f", "-m", commit_message], cvs_path, log_file)[0] != 0:
                                                os.chdir(cvs_path)
                                                os.system("repoman full")
                                                sys.exit(1)
-                               bug_xml = bugzilla.get(bug_id).find('bug')
-                               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
-
-                               if not has_my_arch:
-                                       print_and_log('Seems that bugzilla has 
already been updated.', log_file)
-                                       done_bugs.append(bug_id)
-                                       save_state(done_bugs)
-                                       continue
-
-                               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='%[email protected]' % 
options.arch)
-                                       print_and_log('Successfully updated bug 
%d.' % bug_id, log_file)
-                               else:
-                                       bugzilla.modify(
-                                               bug_id,
-                                               comment='%s stable. Last arch, 
closing' % options.arch,
-                                               remove_cc='%[email protected]' % 
options.arch,
-                                               status='RESOLVED',
-                                               resolution='FIXED')
-                                       print_and_log('Succesfully updated bug 
%d and closed it.' % bug_id, log_file)
-
-                               done_bugs.append(bug_id)
-                               save_state(done_bugs)
-       
+                                               
        if os.path.exists('batch-stabilize.state'):
                os.remove('batch-stabilize.state')

diff --git a/script/batch-stabilize-pretend.py 
b/script/batch-stabilize-pretend.py
index daafc5a..2e5996b 100755
--- a/script/batch-stabilize-pretend.py
+++ b/script/batch-stabilize-pretend.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 # Copyright 2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
@@ -12,7 +12,7 @@ import shutil
 import subprocess
 import sys
 
-import bugz.bugzilla
+from bugz.bugzilla import BugzillaProxy
 import portage.versions
 
 BUG_REGEX = re.compile("[Bb]ug #?(\d+)")
@@ -42,10 +42,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 +64,8 @@ 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'
+       bugzilla = BugzillaProxy(url)
        
        with open(options.input_filename, "r") as input_file:
                stabilization_dict = {}
@@ -150,5 +144,6 @@ if __name__ == "__main__":
                                                os.chdir(cvs_path)
                                                os.system("repoman full")
                                                sys.exit(1)
+                                               
        if os.path.exists('batch-stabilize.state'):
                os.remove('batch-stabilize.state')

diff --git a/script/batch-stabilize.py b/script/batch-stabilize.py
index 9bdfe8d..f86151f 100755
--- a/script/batch-stabilize.py
+++ b/script/batch-stabilize.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 # Copyright 2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
@@ -12,7 +12,7 @@ import shutil
 import subprocess
 import sys
 
-import bugz.bugzilla
+from bugz.bugzilla import BugzillaProxy
 import portage.versions
 
 BUG_REGEX = re.compile("[Bb]ug #?(\d+)")
@@ -42,10 +42,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 +64,8 @@ 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'
+       bugzilla = BugzillaProxy(url)
        
        with open(options.input_filename, "r") as input_file:
                stabilization_dict = {}
@@ -150,42 +144,6 @@ if __name__ == "__main__":
                                                os.chdir(cvs_path)
                                                os.system("repoman full")
                                                sys.exit(1)
-                               bug_xml = bugzilla.get(bug_id).find('bug')
-                               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
-
-                               if not has_my_arch:
-                                       print_and_log('Seems that bugzilla has 
already been updated.', log_file)
-                                       done_bugs.append(bug_id)
-                                       save_state(done_bugs)
-                                       continue
-
-                               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='%[email protected]' % 
options.arch)
-                                       print_and_log('Successfully updated bug 
%d.' % bug_id, log_file)
-                               else:
-                                       bugzilla.modify(
-                                               bug_id,
-                                               comment='%s stable. Last arch, 
closing' % options.arch,
-                                               remove_cc='%[email protected]' % 
options.arch,
-                                               status='RESOLVED',
-                                               resolution='FIXED')
-                                       print_and_log('Succesfully updated bug 
%d and closed it.' % bug_id, log_file)
-
-                               done_bugs.append(bug_id)
-                               save_state(done_bugs)
-       
+                                               
        if os.path.exists('batch-stabilize.state'):
                os.remove('batch-stabilize.state')

Reply via email to