public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-05-22 13:36 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-05-22 13:36 UTC (permalink / raw
  To: gentoo-commits

commit:     59f26733ad4684cc923bd4b299b5498f8f015b37
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Sun May 22 13:36:34 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Sun May 22 13:36:34 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=59f26733

Cleanup: convert all indentation to tabs.

---
 bugzilla-viewer.py |  292 ++++++++++++++++++++++++++--------------------------
 1 files changed, 146 insertions(+), 146 deletions(-)

diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py
index bf034cc..d1de3c0 100755
--- a/bugzilla-viewer.py
+++ b/bugzilla-viewer.py
@@ -22,163 +22,163 @@ class TermTooSmall(Exception):
 
 # Main class (called with curses.wrapper later).
 class MainWindow:
-    def __init__(self, screen, bugs, bugs_dict, packages_dict, related_bugs, repoman_dict):
-	self.bugs = bugs
-	self.bugs_dict = bugs_dict
-	self.packages_dict = packages_dict
-	self.related_bugs = related_bugs
-	self.repoman_dict = repoman_dict
-	
-        curses.curs_set(0)
-        self.screen = screen
-
-        curses.use_default_colors()
-        self.init_screen()
-
-        c = self.screen.getch()
-        while c not in ( ord("q"), curses.ascii.ESC):
-	    if c == ord("j"):
-	    	self.scroll_bugs_pad(1)
-	    elif c == ord("k"):
-	    	self.scroll_bugs_pad(-1)
-	    elif c == curses.KEY_DOWN:
-	    	self.scroll_contents_pad(1)
-	    elif c == curses.KEY_UP:
-	    	self.scroll_contents_pad(-1)
-            elif c == curses.KEY_RESIZE:
-                self.init_screen()
-
-            c = self.screen.getch()
-
-    def init_screen(self):
-        (self.height, self.width) = self.screen.getmaxyx()
-
-        if self.height < 12 or self.width < 80:
-            raise TermTooSmall()
-
-	self.screen.border()
-	self.screen.vline(1, self.width / 3, curses.ACS_VLINE, self.height - 2)
-	self.screen.refresh()
-
-        self.fill_bugs_pad()
-        self.refresh_bugs_pad()
-
-	self.fill_contents_pad()
-        self.refresh_contents_pad()
-
-    def fill_bugs_pad(self):
-        self.bugs_pad = curses.newpad(len(self.bugs),self.width)
-        self.bugs_pad.erase()
-
-	self.bugs_pad_pos = 0
+	def __init__(self, screen, bugs, bugs_dict, packages_dict, related_bugs, repoman_dict):
+		self.bugs = bugs
+		self.bugs_dict = bugs_dict
+		self.packages_dict = packages_dict
+		self.related_bugs = related_bugs
+		self.repoman_dict = repoman_dict
+
+		curses.curs_set(0)
+		self.screen = screen
+
+		curses.use_default_colors()
+		self.init_screen()
+
+		c = self.screen.getch()
+		while c not in (ord("q"), curses.ascii.ESC):
+			if c == ord("j"):
+				self.scroll_bugs_pad(1)
+			elif c == ord("k"):
+				self.scroll_bugs_pad(-1)
+			elif c == curses.KEY_DOWN:
+				self.scroll_contents_pad(1)
+			elif c == curses.KEY_UP:
+				self.scroll_contents_pad(-1)
+			elif c == curses.KEY_RESIZE:
+				self.init_screen()
+
+			c = self.screen.getch()
+
+	def init_screen(self):
+		(self.height, self.width) = self.screen.getmaxyx()
+
+		if self.height < 12 or self.width < 80:
+			raise TermTooSmall()
+
+		self.screen.border()
+		self.screen.vline(1, self.width / 3, curses.ACS_VLINE, self.height - 2)
+		self.screen.refresh()
+
+		self.fill_bugs_pad()
+		self.refresh_bugs_pad()
+
+		self.fill_contents_pad()
+		self.refresh_contents_pad()
+
+	def fill_bugs_pad(self):
+		self.bugs_pad = curses.newpad(len(self.bugs),self.width)
+		self.bugs_pad.erase()
 
-        for i in range(len(self.bugs)):
-            self.bugs_pad.addstr(i, 0,
-                                 "  " + self.bugs[i].find('bug_id').text + " " + self.bugs[i].find('short_desc').text)
-
-    def scroll_bugs_pad(self, amount):
-	height = len(self.bugs)
-
-    	self.bugs_pad_pos += amount
-	if self.bugs_pad_pos < 0:
 		self.bugs_pad_pos = 0
-	if self.bugs_pad_pos >= height:
-		self.bugs_pad_pos = height - 1
-	self.refresh_bugs_pad()
-
-	self.fill_contents_pad()
-	self.refresh_contents_pad()
-
-    def refresh_bugs_pad(self):
-    	(height, width) = self.bugs_pad.getmaxyx()
-    	for i in range(height):
-		self.bugs_pad.addch(i, 0, " ")
-	self.bugs_pad.addch(self.bugs_pad_pos, 0, "*")
-	pos = min(height - self.height + 2, max(0, self.bugs_pad_pos - (self.height / 2)))
-        self.bugs_pad.refresh(
-		pos, 0,
-		1, 1,
-		self.height - 2, self.width / 3 - 1)
-
-    def fill_contents_pad(self):
-	width = 2 * self.width / 3
-
-	bug = self.bugs[self.bugs_pad_pos]
-
-	output = []
-	output += textwrap.wrap(bug.find("short_desc").text, width=width-2)
-	output.append("-" * (width - 2))
-
-	cpvs = self.packages_dict[bug.find("bug_id").text]
-	if cpvs:
-		output += textwrap.wrap("Found package cpvs:", width=width-2)
-		for cpv in cpvs:
-			output += textwrap.wrap(cpv, width=width-2)
-		output.append("-" * (width - 2))
 
-	deps = bug.findall("dependson")
-	if deps:
-		output += textwrap.wrap("Depends on:", width=width-2)
-		for dep in deps:
-			dep_bug = self.bugs_dict[dep.text]
-			desc = dep.text + " " + dep_bug.find("bug_status").text + " " + dep_bug.find("short_desc").text
-			output += textwrap.wrap(desc, width=width-2)
+		for i in range(len(self.bugs)):
+			self.bugs_pad.addstr(i, 0,
+				"  " + self.bugs[i].find('bug_id').text + " " + self.bugs[i].find('short_desc').text)
+
+	def scroll_bugs_pad(self, amount):
+		height = len(self.bugs)
+
+		self.bugs_pad_pos += amount
+		if self.bugs_pad_pos < 0:
+			self.bugs_pad_pos = 0
+		if self.bugs_pad_pos >= height:
+			self.bugs_pad_pos = height - 1
+		self.refresh_bugs_pad()
+
+		self.fill_contents_pad()
+		self.refresh_contents_pad()
+
+	def refresh_bugs_pad(self):
+		(height, width) = self.bugs_pad.getmaxyx()
+		for i in range(height):
+			self.bugs_pad.addch(i, 0, " ")
+		self.bugs_pad.addch(self.bugs_pad_pos, 0, "*")
+		pos = min(height - self.height + 2, max(0, self.bugs_pad_pos - (self.height / 2)))
+		self.bugs_pad.refresh(
+			pos, 0,
+			1, 1,
+			self.height - 2, self.width / 3 - 1)
+
+	def fill_contents_pad(self):
+		width = 2 * self.width / 3
+
+		bug = self.bugs[self.bugs_pad_pos]
+
+		output = []
+		output += textwrap.wrap(bug.find("short_desc").text, width=width-2)
 		output.append("-" * (width - 2))
+
+		cpvs = self.packages_dict[bug.find("bug_id").text]
+		if cpvs:
+			output += textwrap.wrap("Found package cpvs:", width=width-2)
+			for cpv in cpvs:
+				output += textwrap.wrap(cpv, width=width-2)
+			output.append("-" * (width - 2))
+
+		deps = bug.findall("dependson")
+		if deps:
+			output += textwrap.wrap("Depends on:", width=width-2)
+			for dep in deps:
+				dep_bug = self.bugs_dict[dep.text]
+				desc = dep.text + " " + dep_bug.find("bug_status").text + " " + dep_bug.find("short_desc").text
+				output += textwrap.wrap(desc, width=width-2)
+			output.append("-" * (width - 2))
 	
-	related = self.related_bugs[bug.find("bug_id").text]
-	if related:
-		output += textwrap.wrap("Related bugs:", width=width-2)
-		for related_bug in related:
-			if related_bug['bugid'] == bug.find("bug_id").text:
-				continue
-			desc = related_bug['bugid'] + " " + related_bug['desc']
-			output += textwrap.wrap(desc, width=width-2)
-		output.append("-" * (width - 2))
+		related = self.related_bugs[bug.find("bug_id").text]
+		if related:
+			output += textwrap.wrap("Related bugs:", width=width-2)
+			for related_bug in related:
+				if related_bug['bugid'] == bug.find("bug_id").text:
+					continue
+				desc = related_bug['bugid'] + " " + related_bug['desc']
+				output += textwrap.wrap(desc, width=width-2)
+			output.append("-" * (width - 2))
 	
-	if bug.find("bug_id").text in repoman_dict and repoman_dict[bug.find("bug_id").text]:
-		output += textwrap.wrap("Repoman output:", width=width-2)
-		lines = repoman_dict[bug.find("bug_id").text].split("\n")
-		for line in lines:
-			output += textwrap.wrap(line, width=width-2)
-		output.append("-" * (width - 2))
+		if bug.find("bug_id").text in repoman_dict and repoman_dict[bug.find("bug_id").text]:
+			output += textwrap.wrap("Repoman output:", width=width-2)
+			lines = repoman_dict[bug.find("bug_id").text].split("\n")
+			for line in lines:
+				output += textwrap.wrap(line, width=width-2)
+			output.append("-" * (width - 2))
 	
-	for elem in bug.findall("long_desc"):
-		output += textwrap.wrap("%s:" % elem.find("who").text, width=width-2)
-		lines = elem.find("thetext").text.split("\n")
-		for line in lines:
-			output += textwrap.wrap(line, width=width-2)
-		output.append("-" * (width - 2))
-
-	self.contents_pad_length = len(output)
-
-        self.contents_pad = curses.newpad(max(self.contents_pad_length, self.height), width)
-        self.contents_pad.erase()
+		for elem in bug.findall("long_desc"):
+			output += textwrap.wrap("%s:" % elem.find("who").text, width=width-2)
+			lines = elem.find("thetext").text.split("\n")
+			for line in lines:
+				output += textwrap.wrap(line, width=width-2)
+			output.append("-" * (width - 2))
 
-	self.contents_pad_pos = 0
+		self.contents_pad_length = len(output)
 
-        for i in range(len(output)):
-		if type(output[i]) == unicode:
-			real_output = output[i]
-		else:
-			real_output = unicode(output[i], errors='replace')
-		self.contents_pad.addstr(i, 0, real_output.encode("utf-8"))
+		self.contents_pad = curses.newpad(max(self.contents_pad_length, self.height), width)
+		self.contents_pad.erase()
 
-    def scroll_contents_pad(self, amount):
-	height = self.contents_pad_length - self.height + 5
-
-    	self.contents_pad_pos += amount
-	if self.contents_pad_pos < 0:
 		self.contents_pad_pos = 0
-	if self.contents_pad_pos >= height:
-		self.contents_pad_pos = height - 1
-	self.refresh_contents_pad()
-
-    def refresh_contents_pad(self):
-        self.contents_pad.refresh(
-		self.contents_pad_pos, 0,
-		1, self.width / 3 + 1,
-		self.height - 2, self.width - 2)
-	self.screen.refresh()
+
+		for i in range(len(output)):
+			if type(output[i]) == unicode:
+				real_output = output[i]
+			else:
+				real_output = unicode(output[i], errors='replace')
+			self.contents_pad.addstr(i, 0, real_output.encode("utf-8"))
+
+	def scroll_contents_pad(self, amount):
+		height = self.contents_pad_length - self.height + 5
+
+		self.contents_pad_pos += amount
+		if self.contents_pad_pos < 0:
+			self.contents_pad_pos = 0
+		if self.contents_pad_pos >= height:
+			self.contents_pad_pos = height - 1
+		self.refresh_contents_pad()
+
+	def refresh_contents_pad(self):
+		self.contents_pad.refresh(
+			self.contents_pad_pos, 0,
+			1, self.width / 3 + 1,
+			self.height - 2, self.width - 2)
+		self.screen.refresh()
 
 if __name__ == "__main__":
 	parser = optparse.OptionParser()



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-05-22 15:16 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-05-22 15:16 UTC (permalink / raw
  To: gentoo-commits

commit:     c113ff742b3910ef257dd3b4479020d6a8865919
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Sun May 22 15:16:03 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Sun May 22 15:16:03 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=c113ff74

Cleanup: use a Bug class instead of raw XML processing all over the place.

---
 bugzilla-viewer.py |   76 ++++++++++++++++++++++++++++++++-------------------
 1 files changed, 48 insertions(+), 28 deletions(-)

diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py
index d1de3c0..e160a96 100755
--- a/bugzilla-viewer.py
+++ b/bugzilla-viewer.py
@@ -20,6 +20,29 @@ CPV_REGEX = re.compile("[A-Za-z0-9+_.-]+/[A-Za-z0-9+_-]+-[0-9]+(?:\.[0-9]+)*[a-z
 class TermTooSmall(Exception):
 	pass
 
+class Bug:
+	def __init__(self, xml):
+		self.__id = int(xml.find("bug_id").text)
+		self.__summary = xml.find("short_desc").text
+		self.__status = xml.find("bug_status").text
+		self.__depends_on = [int(dep.text) for dep in xml.findall("dependson")]
+		self.__comments = [c.find("who").text + "\n" + c.find("thetext").text for c in xml.findall("long_desc")]
+	
+	def id_number(self):
+		return self.__id
+	
+	def summary(self):
+		return self.__summary
+	
+	def status(self):
+		return self.__status
+	
+	def depends_on(self):
+		return self.__depends_on
+	
+	def comments(self):
+		return self.__comments
+
 # Main class (called with curses.wrapper later).
 class MainWindow:
 	def __init__(self, screen, bugs, bugs_dict, packages_dict, related_bugs, repoman_dict):
@@ -74,7 +97,7 @@ class MainWindow:
 
 		for i in range(len(self.bugs)):
 			self.bugs_pad.addstr(i, 0,
-				"  " + self.bugs[i].find('bug_id').text + " " + self.bugs[i].find('short_desc').text)
+				"  %d %s" % (self.bugs[i].id_number(), self.bugs[i].summary()))
 
 	def scroll_bugs_pad(self, amount):
 		height = len(self.bugs)
@@ -106,46 +129,43 @@ class MainWindow:
 		bug = self.bugs[self.bugs_pad_pos]
 
 		output = []
-		output += textwrap.wrap(bug.find("short_desc").text, width=width-2)
+		output += textwrap.wrap(bug.summary(), width=width-2)
 		output.append("-" * (width - 2))
 
-		cpvs = self.packages_dict[bug.find("bug_id").text]
+		cpvs = self.packages_dict[bug.id_number()]
 		if cpvs:
 			output += textwrap.wrap("Found package cpvs:", width=width-2)
 			for cpv in cpvs:
 				output += textwrap.wrap(cpv, width=width-2)
 			output.append("-" * (width - 2))
 
-		deps = bug.findall("dependson")
+		deps = [self.bugs_dict[dep_id] for dep_id in bug.depends_on()]
 		if deps:
 			output += textwrap.wrap("Depends on:", width=width-2)
 			for dep in deps:
-				dep_bug = self.bugs_dict[dep.text]
-				desc = dep.text + " " + dep_bug.find("bug_status").text + " " + dep_bug.find("short_desc").text
+				desc = "%d %s %s" % (dep.id_number(), dep.status(), dep.summary())
 				output += textwrap.wrap(desc, width=width-2)
 			output.append("-" * (width - 2))
 	
-		related = self.related_bugs[bug.find("bug_id").text]
+		related = self.related_bugs[bug.id_number()]
 		if related:
 			output += textwrap.wrap("Related bugs:", width=width-2)
 			for related_bug in related:
-				if related_bug['bugid'] == bug.find("bug_id").text:
+				if str(related_bug['bugid']) == str(bug.id_number()):
 					continue
 				desc = related_bug['bugid'] + " " + related_bug['desc']
 				output += textwrap.wrap(desc, width=width-2)
 			output.append("-" * (width - 2))
 	
-		if bug.find("bug_id").text in repoman_dict and repoman_dict[bug.find("bug_id").text]:
+		if bug.id_number() in repoman_dict and repoman_dict[bug.id_number()]:
 			output += textwrap.wrap("Repoman output:", width=width-2)
-			lines = repoman_dict[bug.find("bug_id").text].split("\n")
+			lines = repoman_dict[bug.id_number()].split("\n")
 			for line in lines:
 				output += textwrap.wrap(line, width=width-2)
 			output.append("-" * (width - 2))
 	
-		for elem in bug.findall("long_desc"):
-			output += textwrap.wrap("%s:" % elem.find("who").text, width=width-2)
-			lines = elem.find("thetext").text.split("\n")
-			for line in lines:
+		for comment in bug.comments():
+			for line in comment.split("\n"):
 				output += textwrap.wrap(line, width=width-2)
 			output.append("-" * (width - 2))
 
@@ -196,7 +216,7 @@ if __name__ == "__main__":
 
 	print "Searching for arch bugs..."
 	raw_bugs = bugzilla.search("", cc="%s@gentoo.org" % options.arch, keywords="STABLEREQ")
-	bugs = bugzilla.get([bug['bugid'] for bug in raw_bugs]).findall("bug")
+	bugs = [Bug(xml) for xml in bugzilla.get([bug['bugid'] for bug in raw_bugs]).findall("bug")]
 
 	dep_bug_ids = []
 
@@ -205,17 +225,17 @@ if __name__ == "__main__":
 	related_bugs = {}
 	repoman_dict = {}
 	for bug in bugs:
-		print "Processing bug %s: %s" % (bug.find("bug_id").text, bug.find("short_desc").text)
-		bugs_dict[bug.find("bug_id").text] = bug
-		packages_dict[bug.find("bug_id").text] = []
-		related_bugs[bug.find("bug_id").text] = []
-		repoman_dict[bug.find("bug_id").text] = ""
-		for cpv_candidate in CPV_REGEX.findall(bug.find("short_desc").text):
+		print "Processing bug %d: %s" % (bug.id_number(), bug.summary())
+		bugs_dict[bug.id_number()] = bug
+		packages_dict[bug.id_number()] = []
+		related_bugs[bug.id_number()] = []
+		repoman_dict[bug.id_number()] = ""
+		for cpv_candidate in CPV_REGEX.findall(bug.summary()):
 			if portage.db["/"]["porttree"].dbapi.cpv_exists(cpv_candidate):
-				packages_dict[bug.find("bug_id").text].append(cpv_candidate)
+				packages_dict[bug.id_number()].append(cpv_candidate)
 				pv = portage.versions.cpv_getkey(cpv_candidate)
 				if options.verbose:
-					related_bugs[bug.find("bug_id").text] += bugzilla.search(pv)
+					related_bugs[bug.id_number()] += bugzilla.search(pv)
 
 				if options.repo:
 					cvs_path = os.path.join(options.repo, pv)
@@ -226,11 +246,11 @@ if __name__ == "__main__":
 						original_contents = open(ebuild_path).read()
 						manifest_contents = open(manifest_path).read()
 						try:
-							output = repoman_dict[bug.find("bug_id").text]
+							output = repoman_dict[bug.id_number()]
 							output += subprocess.Popen(["ekeyword", options.arch, ebuild_name], cwd=cvs_path, stdout=subprocess.PIPE).communicate()[0]
 							subprocess.check_call(["repoman", "manifest"], cwd=cvs_path)
 							output += subprocess.Popen(["repoman", "full"], cwd=cvs_path, stdout=subprocess.PIPE).communicate()[0]
-							repoman_dict[bug.find("bug_id").text] = output
+							repoman_dict[bug.id_number()] = output
 						finally:
 							f = open(ebuild_path, "w")
 							f.write(original_contents)
@@ -238,12 +258,12 @@ if __name__ == "__main__":
 							f = open(manifest_path, "w")
 							f.write(manifest_contents)
 							f.close()
-		dep_bug_ids += [dep.text for dep in bug.findall("dependson")]
+		dep_bug_ids += bug.depends_on()
 
 	dep_bug_ids = list(set(dep_bug_ids))
-	dep_bugs = bugzilla.get(dep_bug_ids).findall("bug")
+	dep_bugs = [Bug(xml) for xml in bugzilla.get(dep_bug_ids).findall("bug")]
 	for bug in dep_bugs:
-		bugs_dict[bug.find("bug_id").text] = bug
+		bugs_dict[bug.id_number()] = bug
 
 	try:
 		curses.wrapper(MainWindow, bugs=bugs, bugs_dict=bugs_dict, packages_dict=packages_dict, related_bugs=related_bugs, repoman_dict=repoman_dict)



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-05-22 15:31 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-05-22 15:31 UTC (permalink / raw
  To: gentoo-commits

commit:     39fcde8e77f44c1df8d966d6c147abfcc6cb747b
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Sun May 22 15:31:44 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Sun May 22 15:31:44 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=39fcde8e

Bugfix: we need to pass status=None to pybugz, otherwise it returns completely different set of bugs.

---
 bugzilla-viewer.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py
index e160a96..72ae93e 100755
--- a/bugzilla-viewer.py
+++ b/bugzilla-viewer.py
@@ -215,7 +215,7 @@ if __name__ == "__main__":
 	bugzilla = bugz.bugzilla.Bugz('http://bugs.gentoo.org', skip_auth=True)
 
 	print "Searching for arch bugs..."
-	raw_bugs = bugzilla.search("", cc="%s@gentoo.org" % options.arch, keywords="STABLEREQ")
+	raw_bugs = bugzilla.search("", cc="%s@gentoo.org" % options.arch, keywords="STABLEREQ", status=None)
 	bugs = [Bug(xml) for xml in bugzilla.get([bug['bugid'] for bug in raw_bugs]).findall("bug")]
 
 	dep_bug_ids = []
@@ -235,7 +235,7 @@ if __name__ == "__main__":
 				packages_dict[bug.id_number()].append(cpv_candidate)
 				pv = portage.versions.cpv_getkey(cpv_candidate)
 				if options.verbose:
-					related_bugs[bug.id_number()] += bugzilla.search(pv)
+					related_bugs[bug.id_number()] += bugzilla.search(pv, status=None)
 
 				if options.repo:
 					cvs_path = os.path.join(options.repo, pv)



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-05-25 10:32 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-05-25 10:32 UTC (permalink / raw
  To: gentoo-commits

commit:     e7192b0daf2c87a6e8be4ecda48e66cc5f8f34ac
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Wed May 25 10:32:03 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Wed May 25 10:32:03 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=e7192b0d

Write stabilization list to a file.

---
 bugzilla-viewer.py |  129 +++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 93 insertions(+), 36 deletions(-)

diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py
index 72ae93e..b62eaf4 100755
--- a/bugzilla-viewer.py
+++ b/bugzilla-viewer.py
@@ -27,6 +27,16 @@ class Bug:
 		self.__status = xml.find("bug_status").text
 		self.__depends_on = [int(dep.text) for dep in xml.findall("dependson")]
 		self.__comments = [c.find("who").text + "\n" + c.find("thetext").text for c in xml.findall("long_desc")]
+		self.__cpvs_detected = False
+		self.__cpvs = []
+	
+	def detect_cpvs(self):
+		if self.__cpvs_detected:
+			return
+		for cpv_candidate in CPV_REGEX.findall(self.summary()):
+			if portage.db["/"]["porttree"].dbapi.cpv_exists(cpv_candidate):
+				self.__cpvs.append(cpv_candidate)
+		self.__cpvs_detected = True
 	
 	def id_number(self):
 		return self.__id
@@ -42,15 +52,41 @@ class Bug:
 	
 	def comments(self):
 		return self.__comments
+	
+	def cpvs(self):
+		assert(self.__cpvs_detected)
+		return self.__cpvs
+
+class BugQueue:
+	def __init__(self):
+		self.__bug_list = []
+		self.__bug_set = set()
+	
+	def add_bug(self, bug):
+		if self.has_bug(bug):
+			return
+		self.__bug_list.append(bug)
+		self.__bug_set.add(bug.id_number())
+	
+	def has_bug(self, bug):
+		return bug.id_number() in self.__bug_set
+	
+	def generate_stabilization_list(self):
+		result = []
+		for bug in self.__bug_list:
+			result.append("# Bug %d: %s" % (bug.id_number(), bug.summary()))
+			for cpv in bug.cpvs():
+				result.append("=" + cpv)
+		return "\n".join(result)
 
 # Main class (called with curses.wrapper later).
 class MainWindow:
-	def __init__(self, screen, bugs, bugs_dict, packages_dict, related_bugs, repoman_dict):
+	def __init__(self, screen, bugs, bugs_dict, related_bugs, repoman_dict, bug_queue):
 		self.bugs = bugs
 		self.bugs_dict = bugs_dict
-		self.packages_dict = packages_dict
 		self.related_bugs = related_bugs
 		self.repoman_dict = repoman_dict
+		self.bug_queue = bug_queue
 
 		curses.curs_set(0)
 		self.screen = screen
@@ -70,6 +106,8 @@ class MainWindow:
 				self.scroll_contents_pad(-1)
 			elif c == curses.KEY_RESIZE:
 				self.init_screen()
+			elif c == ord("a"):
+				self.add_bug_to_queue()
 
 			c = self.screen.getch()
 
@@ -97,7 +135,7 @@ class MainWindow:
 
 		for i in range(len(self.bugs)):
 			self.bugs_pad.addstr(i, 0,
-				"  %d %s" % (self.bugs[i].id_number(), self.bugs[i].summary()))
+				"    %d %s" % (self.bugs[i].id_number(), self.bugs[i].summary()))
 
 	def scroll_bugs_pad(self, amount):
 		height = len(self.bugs)
@@ -115,7 +153,9 @@ class MainWindow:
 	def refresh_bugs_pad(self):
 		(height, width) = self.bugs_pad.getmaxyx()
 		for i in range(height):
-			self.bugs_pad.addch(i, 0, " ")
+			self.bugs_pad.addstr(i, 0, "   ")
+			if self.bug_queue.has_bug(self.bugs[i]):
+				self.bugs_pad.addch(i, 2, "+")
 		self.bugs_pad.addch(self.bugs_pad_pos, 0, "*")
 		pos = min(height - self.height + 2, max(0, self.bugs_pad_pos - (self.height / 2)))
 		self.bugs_pad.refresh(
@@ -132,11 +172,12 @@ class MainWindow:
 		output += textwrap.wrap(bug.summary(), width=width-2)
 		output.append("-" * (width - 2))
 
-		cpvs = self.packages_dict[bug.id_number()]
+		cpvs = bug.cpvs()
 		if cpvs:
 			output += textwrap.wrap("Found package cpvs:", width=width-2)
 			for cpv in cpvs:
 				output += textwrap.wrap(cpv, width=width-2)
+			output += textwrap.wrap("Press 'a' to add them to the stabilization queue.", width=width-2)
 			output.append("-" * (width - 2))
 
 		deps = [self.bugs_dict[dep_id] for dep_id in bug.depends_on()]
@@ -199,10 +240,21 @@ class MainWindow:
 			1, self.width / 3 + 1,
 			self.height - 2, self.width - 2)
 		self.screen.refresh()
+	
+	def add_bug_to_queue(self):
+		bug = self.bugs[self.bugs_pad_pos]
+
+		# For now we only support auto-detected CPVs.
+		if not bug.cpvs():
+			return
+
+		self.bug_queue.add_bug(bug)
+		self.refresh_bugs_pad()
 
 if __name__ == "__main__":
 	parser = optparse.OptionParser()
 	parser.add_option("--arch", dest="arch", help="Gentoo arch to use, e.g. x86, amd64, ...")
+	parser.add_option("-o", "--output", dest="output_filename", default="package.keywords", help="Output filename for generated package.keywords file [default=%default]")
 	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
 	parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False, help="Include more output, e.g. related bugs")
 
@@ -212,6 +264,8 @@ if __name__ == "__main__":
 	if args:
 		parser.error("unrecognized command-line args")
 
+	bug_queue = BugQueue()
+
 	bugzilla = bugz.bugzilla.Bugz('http://bugs.gentoo.org', skip_auth=True)
 
 	print "Searching for arch bugs..."
@@ -221,43 +275,40 @@ if __name__ == "__main__":
 	dep_bug_ids = []
 
 	bugs_dict = {}
-	packages_dict = {}
 	related_bugs = {}
 	repoman_dict = {}
 	for bug in bugs:
 		print "Processing bug %d: %s" % (bug.id_number(), bug.summary())
 		bugs_dict[bug.id_number()] = bug
-		packages_dict[bug.id_number()] = []
 		related_bugs[bug.id_number()] = []
 		repoman_dict[bug.id_number()] = ""
-		for cpv_candidate in CPV_REGEX.findall(bug.summary()):
-			if portage.db["/"]["porttree"].dbapi.cpv_exists(cpv_candidate):
-				packages_dict[bug.id_number()].append(cpv_candidate)
-				pv = portage.versions.cpv_getkey(cpv_candidate)
-				if options.verbose:
-					related_bugs[bug.id_number()] += bugzilla.search(pv, status=None)
-
-				if options.repo:
-					cvs_path = os.path.join(options.repo, pv)
-					ebuild_name = portage.versions.catsplit(cpv_candidate)[1] + ".ebuild"
-					ebuild_path = os.path.join(cvs_path, ebuild_name)
-					manifest_path = os.path.join(cvs_path, 'Manifest')
-					if os.path.exists(ebuild_path):
-						original_contents = open(ebuild_path).read()
-						manifest_contents = open(manifest_path).read()
-						try:
-							output = repoman_dict[bug.id_number()]
-							output += subprocess.Popen(["ekeyword", options.arch, ebuild_name], cwd=cvs_path, stdout=subprocess.PIPE).communicate()[0]
-							subprocess.check_call(["repoman", "manifest"], cwd=cvs_path)
-							output += subprocess.Popen(["repoman", "full"], cwd=cvs_path, stdout=subprocess.PIPE).communicate()[0]
-							repoman_dict[bug.id_number()] = output
-						finally:
-							f = open(ebuild_path, "w")
-							f.write(original_contents)
-							f.close()
-							f = open(manifest_path, "w")
-							f.write(manifest_contents)
-							f.close()
+		bug.detect_cpvs()
+		for cpv in bug.cpvs():
+			pv = portage.versions.cpv_getkey(cpv)
+			if options.verbose:
+				related_bugs[bug.id_number()] += bugzilla.search(pv, status=None)
+
+			if options.repo:
+				cvs_path = os.path.join(options.repo, pv)
+				ebuild_name = portage.versions.catsplit(cpv_candidate)[1] + ".ebuild"
+				ebuild_path = os.path.join(cvs_path, ebuild_name)
+				manifest_path = os.path.join(cvs_path, 'Manifest')
+				if os.path.exists(ebuild_path):
+					original_contents = open(ebuild_path).read()
+					manifest_contents = open(manifest_path).read()
+					try:
+						output = repoman_dict[bug.id_number()]
+						output += subprocess.Popen(["ekeyword", options.arch, ebuild_name], cwd=cvs_path, stdout=subprocess.PIPE).communicate()[0]
+						subprocess.check_call(["repoman", "manifest"], cwd=cvs_path)
+						output += subprocess.Popen(["repoman", "full"], cwd=cvs_path, stdout=subprocess.PIPE).communicate()[0]
+						repoman_dict[bug.id_number()] = output
+					finally:
+						f = open(ebuild_path, "w")
+						f.write(original_contents)
+						f.close()
+						f = open(manifest_path, "w")
+						f.write(manifest_contents)
+						f.close()
 		dep_bug_ids += bug.depends_on()
 
 	dep_bug_ids = list(set(dep_bug_ids))
@@ -266,7 +317,13 @@ if __name__ == "__main__":
 		bugs_dict[bug.id_number()] = bug
 
 	try:
-		curses.wrapper(MainWindow, bugs=bugs, bugs_dict=bugs_dict, packages_dict=packages_dict, related_bugs=related_bugs, repoman_dict=repoman_dict)
+		curses.wrapper(MainWindow, bugs=bugs, bugs_dict=bugs_dict, related_bugs=related_bugs, repoman_dict=repoman_dict, bug_queue=bug_queue)
 	except TermTooSmall:
 		print "Your terminal window is too small, please try to enlarge it"
 		sys.exit(1)
+	
+	stabilization_list = bug_queue.generate_stabilization_list()
+	if stabilization_list:
+		with open(options.output_filename, "w") as f:
+			f.write(stabilization_list)
+			print "Writing stabilization list to %s" % options.output_filename



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-05-25 19:51 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-05-25 19:51 UTC (permalink / raw
  To: gentoo-commits

commit:     90ea2095b43b3bb025d121d40f7892c7d077d488
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Wed May 25 19:51:34 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Wed May 25 19:51:34 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=90ea2095

Bugfix: wrong variable name used for repoman output.

---
 bugzilla-viewer.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py
index b62eaf4..686a3aa 100755
--- a/bugzilla-viewer.py
+++ b/bugzilla-viewer.py
@@ -290,7 +290,7 @@ if __name__ == "__main__":
 
 			if options.repo:
 				cvs_path = os.path.join(options.repo, pv)
-				ebuild_name = portage.versions.catsplit(cpv_candidate)[1] + ".ebuild"
+				ebuild_name = portage.versions.catsplit(cpv)[1] + ".ebuild"
 				ebuild_path = os.path.join(cvs_path, ebuild_name)
 				manifest_path = os.path.join(cvs_path, 'Manifest')
 				if os.path.exists(ebuild_path):



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-06-02 15:38 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-06-02 15:38 UTC (permalink / raw
  To: gentoo-commits

commit:     5cd96f04deb82e55aa60f91a2340240c076771d8
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Thu Jun  2 15:37:54 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Thu Jun  2 15:37:54 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=5cd96f04

Make sure to unicode-sanitize all strings passed to ncurses to prevent runtime exceptions.

---
 bugzilla-viewer.py |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py
index 686a3aa..e62ac98 100755
--- a/bugzilla-viewer.py
+++ b/bugzilla-viewer.py
@@ -17,6 +17,14 @@ import portage.versions
 
 CPV_REGEX = re.compile("[A-Za-z0-9+_.-]+/[A-Za-z0-9+_-]+-[0-9]+(?:\.[0-9]+)*[a-z0-9_]*(?:-r[0-9]+)?")
 
+def unicode_sanitize(text):
+	"""Converts a possibly unicode text to a regular string."""
+	if type(text) == unicode:
+		real_output = text
+	else:
+		real_output = unicode(text, errors='replace')
+	return real_output.encode("utf-8")
+
 class TermTooSmall(Exception):
 	pass
 
@@ -135,7 +143,7 @@ class MainWindow:
 
 		for i in range(len(self.bugs)):
 			self.bugs_pad.addstr(i, 0,
-				"    %d %s" % (self.bugs[i].id_number(), self.bugs[i].summary()))
+				unicode_sanitize("    %d %s" % (self.bugs[i].id_number(), self.bugs[i].summary())))
 
 	def scroll_bugs_pad(self, amount):
 		height = len(self.bugs)
@@ -218,11 +226,7 @@ class MainWindow:
 		self.contents_pad_pos = 0
 
 		for i in range(len(output)):
-			if type(output[i]) == unicode:
-				real_output = output[i]
-			else:
-				real_output = unicode(output[i], errors='replace')
-			self.contents_pad.addstr(i, 0, real_output.encode("utf-8"))
+			self.contents_pad.addstr(i, 0, unicode_sanitize(output[i]))
 
 	def scroll_contents_pad(self, amount):
 		height = self.contents_pad_length - self.height + 5



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-06-02 15:41 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-06-02 15:41 UTC (permalink / raw
  To: gentoo-commits

commit:     67fb002b35cfd56ee6d07838b55ec3723518198d
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Thu Jun  2 15:41:38 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Thu Jun  2 15:41:38 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=67fb002b

Gracefully handle empty bug queue.

---
 bugzilla-viewer.py |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py
index e62ac98..d04e6db 100755
--- a/bugzilla-viewer.py
+++ b/bugzilla-viewer.py
@@ -276,6 +276,10 @@ if __name__ == "__main__":
 	raw_bugs = bugzilla.search("", cc="%s@gentoo.org" % options.arch, keywords="STABLEREQ", status=None)
 	bugs = [Bug(xml) for xml in bugzilla.get([bug['bugid'] for bug in raw_bugs]).findall("bug")]
 
+	if not bugs:
+		print 'The bug list is empty. Exiting.'
+		sys.exit(0)
+
 	dep_bug_ids = []
 
 	bugs_dict = {}



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-06-05 16:16 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-06-05 16:16 UTC (permalink / raw
  To: gentoo-commits

commit:     03dcfcf90388c8bb1e9fb8ecd58c96f9d74301bd
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  5 16:16:30 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Sun Jun  5 16:16:30 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=03dcfcf9

Fix an off-by-two error in contents pad scrolling routine.

---
 bugzilla-viewer.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py
index d04e6db..0891979 100755
--- a/bugzilla-viewer.py
+++ b/bugzilla-viewer.py
@@ -229,7 +229,7 @@ class MainWindow:
 			self.contents_pad.addstr(i, 0, unicode_sanitize(output[i]))
 
 	def scroll_contents_pad(self, amount):
-		height = self.contents_pad_length - self.height + 5
+		height = self.contents_pad_length - self.height + 3
 
 		self.contents_pad_pos += amount
 		if self.contents_pad_pos < 0:



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-08-07  3:26 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-08-07  3:26 UTC (permalink / raw
  To: gentoo-commits

commit:     e8ad6147da9fec953419799d136dff1f05d378ea
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Sun Aug  7 03:26:10 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Sun Aug  7 03:26:10 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=e8ad6147

Add batch stabilization tool.

---
 batch-stabilize.py |  117 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 117 insertions(+), 0 deletions(-)

diff --git a/batch-stabilize.py b/batch-stabilize.py
new file mode 100755
index 0000000..8414f44
--- /dev/null
+++ b/batch-stabilize.py
@@ -0,0 +1,117 @@
+#!/usr/bin/env python
+# Copyright 2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import itertools
+import optparse
+import os
+import re
+import subprocess
+import sys
+
+import portage.versions
+
+BUG_REGEX = re.compile("[Bb]ug #?(\d+)")
+
+def print_and_log(message, log):
+	try:
+		print message
+		log.write(message)
+	finally:
+		log.flush()
+
+def run_command(args, cwd, log):
+	try:
+		log.write("Running %r in %s...\n" % (args, cwd))
+		cmd  = subprocess.Popen(args, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+		output = cmd.communicate()[0]
+		log.write("Finished with exit code %d\n" % cmd.returncode)
+		log.write(output)
+		return (cmd.returncode, output)
+	finally:
+		log.flush()
+
+if __name__ == "__main__":
+	parser = optparse.OptionParser()
+	parser.add_option("--arch", dest="arch", help="Gentoo arch to use, e.g. x86, amd64, ...")
+	parser.add_option("-i", "--input", dest="input_filename", default="package.keywords", help="Input filename for generated package.keywords file [default=%default]")
+	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
+	parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False)
+
+	(options, args) = parser.parse_args()
+	if not options.arch:
+		parser.error("--arch option is required")
+	if not options.input_filename:
+		parser.error("--input option is required")
+	if not options.repo:
+		parser.error("--repo option is required")
+	if args:
+		parser.error("unrecognized command-line args")
+	
+	with open(options.input_filename, "r") as input_file:
+		stabilization_list = []
+		bug_id = -1
+		for line in input_file:
+			if line == "\n":
+				continue
+
+			if line.startswith("#"):
+				match = BUG_REGEX.search(line, re.IGNORECASE)
+				if not match:
+					print 'Ignoring comment line [%s]...' % line
+					continue
+				else:
+					bug_id = int(match.group(1))
+				continue
+
+			if bug_id == -1:
+				print 'Could not recognize bug id'
+				sys.exit(1)
+
+			if not line.endswith("\n"):
+				line += "\n"
+			cpv = line[1:-1]
+			p = portage.versions.catsplit(cpv)[1]
+			pn = portage.versions.pkgsplit(cpv)[0]
+			ebuild_name = p + ".ebuild"
+			stabilization_list.append((pn, ebuild_name, bug_id))
+
+		# Sanity check.
+		success = True
+		for pn, ebuild_name, bug_id in stabilization_list:
+			ebuild_path = os.path.join(options.repo, pn, ebuild_name)
+			if not os.path.exists(ebuild_path):
+				print '%s: file does not exist' % ebuild_path
+				success = False
+		if not success:
+			print 'Sanity check failed. Please make sure your CVS repo is up to date (cvs up).'
+			sys.exit(1)
+
+		with open('batch-stabilize.log', 'w') as log_file:
+			for pn, ebuild_name, bug_id in stabilization_list:
+				commit_message = "%s stable wrt bug #%d" % (options.arch, bug_id)
+				cvs_path = os.path.join(options.repo, pn)
+				print_and_log('Working in %s...' % cvs_path, log_file)
+				if run_command(["cvs", "up"], cvs_path, log_file)[0] != 0:
+					print '!!! cvs up failed'
+					sys.exit(1)
+				if run_command(["ekeyword", options.arch, ebuild_name], cvs_path, log_file)[0] != 0:
+					print '!!! ekeyword failed'
+					sys.exit(1)
+				return_code, output = run_command(["cvs", "diff"], cvs_path, log_file)
+				# It seems that cvs diff returns 1 if there are differences.
+				if return_code == 0 and not output:
+					print_and_log('Seems already keyworded, skipping.', log_file)
+					continue
+				if run_command(["echangelog", commit_message], cvs_path, log_file)[0] != 0:
+					print '!!! ekeyword failed'
+					sys.exit(1)
+				if run_command(["repoman", "manifest"], cvs_path, log_file)[0] != 0:
+					print '!!! repoman manifest failed'
+					sys.exit(1)
+				if run_command(["repoman", "full"], cvs_path, log_file)[0] != 0:
+					print '!!! repoman full failed'
+					sys.exit(1)
+				if run_command(["repoman", "commit", "-m", commit_message], cvs_path, log_file)[0] != 0:
+					print '!!! repoman full failed'
+					sys.exit(1)



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-09-19  3:09 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-09-19  3:09 UTC (permalink / raw
  To: gentoo-commits

commit:     07e7a0eb8cf5656bb7b15f9a9b78eda6101910ac
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Mon Sep 19 03:08:25 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Mon Sep 19 03:08:25 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=07e7a0eb

Add a tool to find reverse dependencies.

---
 reverse-dependencies.py |   78 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/reverse-dependencies.py b/reverse-dependencies.py
new file mode 100755
index 0000000..88d79aa
--- /dev/null
+++ b/reverse-dependencies.py
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+# Copyright 2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import optparse
+import os
+import types
+
+os.environ["PORTDIR_OVERLAY"] = ""
+
+import portage
+
+def process_deps(deps, use=None):
+	if not use:
+		use = []
+	result = []
+	for index, x in enumerate(deps):
+		if type(x) == types.ListType:
+			continue
+		elif x == "||":  # Any-of.
+			result.extend(process_deps(deps[index + 1], use))
+		elif x[-1] == "?":  # Use-conditional.
+			result.extend(process_deps(deps[index + 1], use + [x[:-1]]))
+		elif x[0] == "!":  # Blocker.
+			result.append((portage.dep_getkey(x), True, use))
+		else:
+			result.append((portage.dep_getkey(x), False, use))
+	return result
+
+if __name__ == "__main__":
+	parser = optparse.OptionParser()
+	parser.add_option("-i", "--input", dest="input_filename", default="package.keywords", help="Input filename for generated package.keywords file [default=%default]")
+	parser.add_option("-o", "--output", dest="output_filename", default="package.rdeps", help="Output filename for generated package.rdeps file [default=%default]")
+	parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False)
+
+	(options, args) = parser.parse_args()
+	if not options.input_filename:
+		parser.error("--input option is required")
+	if not options.output_filename:
+		parser.error("--output option is required")
+	if args:
+		parser.error("unrecognized command-line args")
+
+	reverse_deps = {}
+	for pkg in portage.portdb.cp_all():
+		deps = []
+		for match in portage.portdb.match(pkg):
+			deps.extend(process_deps(portage.dep.paren_reduce(portage.portdb.aux_get(match, ['DEPEND', 'RDEPEND', 'PDEPEND'])[0])))
+		for cp, blocker, use in deps:
+			if blocker:
+				continue
+			if cp not in reverse_deps:
+				reverse_deps[cp] = {}
+			if pkg not in reverse_deps[cp]:
+				reverse_deps[cp][pkg] = []
+			if use not in reverse_deps[cp][pkg]:
+				reverse_deps[cp][pkg].append(use)
+
+	with open(options.input_filename, "r") as input_file:
+		with open(options.output_filename, "w") as output_file:
+			for line in input_file:
+				if line == "\n" or line.startswith("#"):
+					continue
+
+				if not line.endswith("\n"):
+					line += "\n"
+				cpv = line[1:-1]
+				pn = portage.versions.pkgsplit(cpv)[0]
+				if pn in reverse_deps:
+					output_file.write("# Reverse dependencies for %s\n" % pn)
+					for cp, use_combinations in reverse_deps[pn].items():
+						if use_combinations != [[]]:
+							output_file.write("# One of the following USE flag combinations is required:\n")
+							for use_combination in use_combinations:
+								output_file.write("#\t%s\n" % ",".join(use_combination))
+						output_file.write("%s\n" % cp)
+				elif options.verbose:
+					print 'No reverse dependencies for %s' % pn



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-10-04 21:46 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-10-04 21:46 UTC (permalink / raw
  To: gentoo-commits

commit:     a6ed12cee737b66c730f8a93769f242154ee3ec1
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Tue Oct  4 21:45:38 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Tue Oct  4 21:45:38 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=a6ed12ce

Update Bugzilla when stabilizing packages.

---
 batch-stabilize.py |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/batch-stabilize.py b/batch-stabilize.py
index 8414f44..912d26b 100755
--- a/batch-stabilize.py
+++ b/batch-stabilize.py
@@ -9,6 +9,7 @@ import re
 import subprocess
 import sys
 
+import bugz.bugzilla
 import portage.versions
 
 BUG_REGEX = re.compile("[Bb]ug #?(\d+)")
@@ -31,6 +32,10 @@ def run_command(args, cwd, log):
 	finally:
 		log.flush()
 
+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, ...")
@@ -47,6 +52,11 @@ if __name__ == "__main__":
 		parser.error("--repo option is required")
 	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)
+	bugzilla.auth()
 	
 	with open(options.input_filename, "r") as input_file:
 		stabilization_list = []
@@ -115,3 +125,26 @@ if __name__ == "__main__":
 				if run_command(["repoman", "commit", "-m", commit_message], cvs_path, log_file)[0] != 0:
 					print '!!! repoman full failed'
 					sys.exit(1)
+				log_file.write('Posting automated reply in bugzilla...\n')
+				bug_xml = bugzilla.get(bug_id).find('bug')
+				has_other_arches = False
+				for cc in bug_xml.findall('cc'):
+					body, domain = cc.text.split('@', 1)
+					if domain == 'gentoo.org' and body in portage.archlist and body != options.arch:
+						has_other_arches=True
+				# 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)
+					log_file.write('Successfully updated bug %d.\n' % bug_id)
+				else:
+					bugzilla.modify(
+						bug_id,
+						comment='%s stable, closing' % options.arch,
+						remove_cc='%s@gentoo.org' % options.arch,
+						status='RESOLVED',
+						resolution='FIXED')
+					log_file.write('Succesfully updated bug %d and closed it.\n' % bug_id)



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-10-13 21:59 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-10-13 21:59 UTC (permalink / raw
  To: gentoo-commits

commit:     cb1eac2e87e24b35de97afff8e6332eacccb57e5
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 13 21:58:45 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Thu Oct 13 21:58:45 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=cb1eac2e

Fix a crash when dependent bug is not accessible.

---
 bugzilla-viewer.py |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py
index 0891979..c45530a 100755
--- a/bugzilla-viewer.py
+++ b/bugzilla-viewer.py
@@ -29,12 +29,19 @@ class TermTooSmall(Exception):
 	pass
 
 class Bug:
-	def __init__(self, xml):
-		self.__id = int(xml.find("bug_id").text)
-		self.__summary = xml.find("short_desc").text
-		self.__status = xml.find("bug_status").text
-		self.__depends_on = [int(dep.text) for dep in xml.findall("dependson")]
-		self.__comments = [c.find("who").text + "\n" + c.find("thetext").text for c in xml.findall("long_desc")]
+	def __init__(self, xml=None, id_number=None, summary=None, status=None):
+		if xml is not None:
+			self.__id = int(xml.find("bug_id").text)
+			self.__summary = xml.find("short_desc").text
+			self.__status = xml.find("bug_status").text
+			self.__depends_on = [int(dep.text) for dep in xml.findall("dependson")]
+			self.__comments = [c.find("who").text + "\n" + c.find("thetext").text for c in xml.findall("long_desc")]
+		if id_number is not None:
+			self.__id = id_number
+		if summary is not None:
+			self.__summary = summary
+		if status is not None:
+			self.__status = status
 		self.__cpvs_detected = False
 		self.__cpvs = []
 	
@@ -118,6 +125,11 @@ class MainWindow:
 				self.add_bug_to_queue()
 
 			c = self.screen.getch()
+	
+	def bug_for_id(self, bug_id):
+		if bug_id in self.bugs_dict:
+			return self.bugs_dict[bug_id]
+		return Bug(id_number=bug_id, summary='(summary unavailable)', status='UNKNOWN')
 
 	def init_screen(self):
 		(self.height, self.width) = self.screen.getmaxyx()
@@ -188,7 +200,7 @@ class MainWindow:
 			output += textwrap.wrap("Press 'a' to add them to the stabilization queue.", width=width-2)
 			output.append("-" * (width - 2))
 
-		deps = [self.bugs_dict[dep_id] for dep_id in bug.depends_on()]
+		deps = [self.bug_for_id(dep_id) for dep_id in bug.depends_on()]
 		if deps:
 			output += textwrap.wrap("Depends on:", width=width-2)
 			for dep in deps:



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-10-16  3:51 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-10-16  3:51 UTC (permalink / raw
  To: gentoo-commits

commit:     2b5642259eb7ca590ce34579b979fbdd6116af94
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 16 03:49:45 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Sun Oct 16 03:49:45 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=2b564225

Improve batch stabilization:

- only update bugzilla once per bug
- keyword all packages for each bug first, then commit
  (in case packages stabilized in single bug depend on each other,
   so that we don't need to worry about their order)
- cosmetic logging improvements

---
 batch-stabilize.py |   87 ++++++++++++++++++++++++++++++----------------------
 1 files changed, 50 insertions(+), 37 deletions(-)

diff --git a/batch-stabilize.py b/batch-stabilize.py
index 912d26b..b76bac7 100755
--- a/batch-stabilize.py
+++ b/batch-stabilize.py
@@ -17,7 +17,7 @@ BUG_REGEX = re.compile("[Bb]ug #?(\d+)")
 def print_and_log(message, log):
 	try:
 		print message
-		log.write(message)
+		log.write(message + '\n')
 	finally:
 		log.flush()
 
@@ -59,7 +59,7 @@ if __name__ == "__main__":
 	bugzilla.auth()
 	
 	with open(options.input_filename, "r") as input_file:
-		stabilization_list = []
+		stabilization_dict = {}
 		bug_id = -1
 		for line in input_file:
 			if line == "\n":
@@ -84,54 +84,67 @@ if __name__ == "__main__":
 			p = portage.versions.catsplit(cpv)[1]
 			pn = portage.versions.pkgsplit(cpv)[0]
 			ebuild_name = p + ".ebuild"
-			stabilization_list.append((pn, ebuild_name, bug_id))
+			if bug_id not in stabilization_dict:
+				stabilization_dict[bug_id] = []
+			stabilization_dict[bug_id].append((pn, ebuild_name))
 
 		# Sanity check.
 		success = True
-		for pn, ebuild_name, bug_id in stabilization_list:
-			ebuild_path = os.path.join(options.repo, pn, ebuild_name)
-			if not os.path.exists(ebuild_path):
-				print '%s: file does not exist' % ebuild_path
-				success = False
+		for bug_id in stabilization_dict:
+			for (pn, ebuild_name) in stabilization_dict[bug_id]:
+				ebuild_path = os.path.join(options.repo, pn, ebuild_name)
+				if not os.path.exists(ebuild_path):
+					print '%s: file does not exist' % ebuild_path
+					success = False
 		if not success:
 			print 'Sanity check failed. Please make sure your CVS repo is up to date (cvs up).'
 			sys.exit(1)
 
 		with open('batch-stabilize.log', 'w') as log_file:
-			for pn, ebuild_name, bug_id in stabilization_list:
+			for bug_id in stabilization_dict:
+				print_and_log('Working on bug %d...' % bug_id, log_file)
 				commit_message = "%s stable wrt bug #%d" % (options.arch, bug_id)
-				cvs_path = os.path.join(options.repo, pn)
-				print_and_log('Working in %s...' % cvs_path, log_file)
-				if run_command(["cvs", "up"], cvs_path, log_file)[0] != 0:
-					print '!!! cvs up failed'
-					sys.exit(1)
-				if run_command(["ekeyword", options.arch, ebuild_name], cvs_path, log_file)[0] != 0:
-					print '!!! ekeyword failed'
-					sys.exit(1)
-				return_code, output = run_command(["cvs", "diff"], cvs_path, log_file)
-				# It seems that cvs diff returns 1 if there are differences.
-				if return_code == 0 and not output:
-					print_and_log('Seems already keyworded, skipping.', log_file)
-					continue
-				if run_command(["echangelog", commit_message], cvs_path, log_file)[0] != 0:
-					print '!!! ekeyword failed'
-					sys.exit(1)
-				if run_command(["repoman", "manifest"], cvs_path, log_file)[0] != 0:
-					print '!!! repoman manifest failed'
-					sys.exit(1)
-				if run_command(["repoman", "full"], cvs_path, log_file)[0] != 0:
-					print '!!! repoman full failed'
-					sys.exit(1)
-				if run_command(["repoman", "commit", "-m", commit_message], cvs_path, log_file)[0] != 0:
-					print '!!! repoman full failed'
-					sys.exit(1)
-				log_file.write('Posting automated reply in bugzilla...\n')
+				for (pn, ebuild_name) in stabilization_dict[bug_id]:
+					cvs_path = os.path.join(options.repo, pn)
+					print_and_log('Working in %s...' % cvs_path, log_file)
+					if run_command(["cvs", "up"], cvs_path, log_file)[0] != 0:
+						print '!!! cvs up failed'
+						sys.exit(1)
+					if run_command(["ekeyword", options.arch, ebuild_name], cvs_path, log_file)[0] != 0:
+						print '!!! ekeyword failed'
+						sys.exit(1)
+				for (pn, ebuild_name) in stabilization_dict[bug_id]:
+					cvs_path = os.path.join(options.repo, pn)
+					print_and_log('Working in %s...' % cvs_path, log_file)
+					return_code, output = run_command(["cvs", "diff"], cvs_path, log_file)
+					# It seems that cvs diff returns 1 if there are differences.
+					if return_code == 0 and not output:
+						print_and_log('Seems already keyworded, skipping.', log_file)
+						continue
+					if run_command(["echangelog", commit_message], cvs_path, log_file)[0] != 0:
+						print '!!! echangelog failed'
+						sys.exit(1)
+					if run_command(["repoman", "manifest"], cvs_path, log_file)[0] != 0:
+						print '!!! repoman manifest failed'
+						sys.exit(1)
+					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')
+				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)
+					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:
@@ -139,7 +152,7 @@ if __name__ == "__main__":
 						bug_id,
 						comment='%s stable' % options.arch,
 						remove_cc='%s@gentoo.org' % options.arch)
-					log_file.write('Successfully updated bug %d.\n' % bug_id)
+					print_and_log('Successfully updated bug %d.' % bug_id, log_file)
 				else:
 					bugzilla.modify(
 						bug_id,
@@ -147,4 +160,4 @@ if __name__ == "__main__":
 						remove_cc='%s@gentoo.org' % options.arch,
 						status='RESOLVED',
 						resolution='FIXED')
-					log_file.write('Succesfully updated bug %d and closed it.\n' % bug_id)
+					print_and_log('Succesfully updated bug %d and closed it.' % bug_id, log_file)



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-10-18 14:05 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-10-18 14:05 UTC (permalink / raw
  To: gentoo-commits

commit:     c8fd3c42664821fabdc7af7c976f197a4c5551c6
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 18 14:00:13 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Tue Oct 18 14:00:13 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=c8fd3c42

Implement limit option for reverse dependencies.

---
 reverse-dependencies.py |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/reverse-dependencies.py b/reverse-dependencies.py
index 88d79aa..4f87139 100755
--- a/reverse-dependencies.py
+++ b/reverse-dependencies.py
@@ -4,6 +4,7 @@
 
 import optparse
 import os
+import random
 import types
 
 os.environ["PORTDIR_OVERLAY"] = ""
@@ -31,6 +32,7 @@ if __name__ == "__main__":
 	parser = optparse.OptionParser()
 	parser.add_option("-i", "--input", dest="input_filename", default="package.keywords", help="Input filename for generated package.keywords file [default=%default]")
 	parser.add_option("-o", "--output", dest="output_filename", default="package.rdeps", help="Output filename for generated package.rdeps file [default=%default]")
+	parser.add_option("-l", "--limit", dest="limit", type="int", default=-1, help="Limit of reverse dependencies per package. Default is no limit.")
 	parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False)
 
 	(options, args) = parser.parse_args()
@@ -68,7 +70,12 @@ if __name__ == "__main__":
 				pn = portage.versions.pkgsplit(cpv)[0]
 				if pn in reverse_deps:
 					output_file.write("# Reverse dependencies for %s\n" % pn)
-					for cp, use_combinations in reverse_deps[pn].items():
+					if options.limit == -1:
+						cps = reverse_deps[pn]
+					else:
+						cps = random.sample(reverse_deps[pn], min(options.limit, len(reverse_deps[pn])))
+					for cp in cps:
+						use_combinations = reverse_deps[pn][cp]
 						if use_combinations != [[]]:
 							output_file.write("# One of the following USE flag combinations is required:\n")
 							for use_combination in use_combinations:



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-10-21 15:15 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-10-21 15:15 UTC (permalink / raw
  To: gentoo-commits

commit:     9b8ef056ffe123fdd90e5c156f8c6ce532376db9
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 21 15:14:28 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Fri Oct 21 15:14:28 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=9b8ef056

Fix bugs:

- open log in append mode to avoid losing logs on retry
- delete old ChangeLogs to avoid adding the same entry multiple times
- re-Manifest after ekeyword to avoid manifest error on dependent
  packages

---
 batch-stabilize.py |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/batch-stabilize.py b/batch-stabilize.py
index b76bac7..0289c42 100755
--- a/batch-stabilize.py
+++ b/batch-stabilize.py
@@ -100,19 +100,29 @@ if __name__ == "__main__":
 			print 'Sanity check failed. Please make sure your CVS repo is up to date (cvs up).'
 			sys.exit(1)
 
-		with open('batch-stabilize.log', 'w') as log_file:
+		with open('batch-stabilize.log', 'a') as log_file:
 			for bug_id in stabilization_dict:
 				print_and_log('Working on bug %d...' % bug_id, log_file)
 				commit_message = "%s stable wrt bug #%d" % (options.arch, bug_id)
 				for (pn, ebuild_name) in stabilization_dict[bug_id]:
 					cvs_path = os.path.join(options.repo, pn)
 					print_and_log('Working in %s...' % cvs_path, log_file)
+
+					# Remove existing changelog to avoid adding duplicate entries.
+					try:
+						os.remove(os.path.join(cvs_path, 'ChangeLog'))
+					except OSError:
+						pass
+
 					if run_command(["cvs", "up"], cvs_path, log_file)[0] != 0:
 						print '!!! cvs up failed'
 						sys.exit(1)
 					if run_command(["ekeyword", options.arch, ebuild_name], cvs_path, log_file)[0] != 0:
 						print '!!! ekeyword failed'
 						sys.exit(1)
+					if run_command(["repoman", "manifest"], cvs_path, log_file)[0] != 0:
+						print '!!! repoman manifest failed'
+						sys.exit(1)
 				for (pn, ebuild_name) in stabilization_dict[bug_id]:
 					cvs_path = os.path.join(options.repo, pn)
 					print_and_log('Working in %s...' % cvs_path, log_file)



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-10-22  8:18 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-10-22  8:18 UTC (permalink / raw
  To: gentoo-commits

commit:     ec0907549e7827f7b32988dff21eaee40b7e45ab
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 22 08:17:12 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Sat Oct 22 08:17:12 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=ec090754

Improvements for the bugzilla viewer:

- do brace expansion on the bug summary
- make sure every entry for package.keywords ends with a newline
- add an option to query only for security bugs

---
 bugzilla-viewer.py |   49 ++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py
index c45530a..48b253e 100755
--- a/bugzilla-viewer.py
+++ b/bugzilla-viewer.py
@@ -17,6 +17,31 @@ import portage.versions
 
 CPV_REGEX = 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 = r'.*(\{.+?[^\\]\})'
+	p = re.compile(r)
+
+	s = orig[:]
+	res = list()
+
+	m = p.search(s)
+	if m is not None:
+		sub = m.group(1)
+		open_brace = s.find(sub)
+		close_brace = 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))
+
 def unicode_sanitize(text):
 	"""Converts a possibly unicode text to a regular string."""
 	if type(text) == unicode:
@@ -48,9 +73,11 @@ class Bug:
 	def detect_cpvs(self):
 		if self.__cpvs_detected:
 			return
-		for cpv_candidate in CPV_REGEX.findall(self.summary()):
-			if portage.db["/"]["porttree"].dbapi.cpv_exists(cpv_candidate):
-				self.__cpvs.append(cpv_candidate)
+		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_detected = True
 	
 	def id_number(self):
@@ -89,10 +116,10 @@ class BugQueue:
 	def generate_stabilization_list(self):
 		result = []
 		for bug in self.__bug_list:
-			result.append("# Bug %d: %s" % (bug.id_number(), bug.summary()))
+			result.append("# Bug %d: %s\n" % (bug.id_number(), bug.summary()))
 			for cpv in bug.cpvs():
-				result.append("=" + cpv)
-		return "\n".join(result)
+				result.append("=" + cpv + "\n")
+		return ''.join(result)
 
 # Main class (called with curses.wrapper later).
 class MainWindow:
@@ -273,6 +300,7 @@ if __name__ == "__main__":
 	parser.add_option("-o", "--output", dest="output_filename", default="package.keywords", help="Output filename for generated package.keywords file [default=%default]")
 	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
 	parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False, help="Include more output, e.g. related bugs")
+	parser.add_option("--security", dest="security", action="store_true", default=False, help="Restrict search to security bugs.")
 
 	(options, args) = parser.parse_args()
 	if not options.arch:
@@ -285,7 +313,14 @@ if __name__ == "__main__":
 	bugzilla = bugz.bugzilla.Bugz('http://bugs.gentoo.org', skip_auth=True)
 
 	print "Searching for arch bugs..."
-	raw_bugs = bugzilla.search("", cc="%s@gentoo.org" % options.arch, keywords="STABLEREQ", status=None)
+	criteria = {
+		'cc': '%s@gentoo.org' % options.arch,
+		'keywords': 'STABLEREQ',
+		'status': None
+	}
+	if options.security:
+		criteria['assigned_to'] = 'security@gentoo.org'
+	raw_bugs = bugzilla.search("", **criteria)
 	bugs = [Bug(xml) for xml in bugzilla.get([bug['bugid'] for bug in raw_bugs]).findall("bug")]
 
 	if not bugs:



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-11-03 11:00 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-11-03 11:00 UTC (permalink / raw
  To: gentoo-commits

commit:     575e47390093480f4b90e795bb2930fa6d85bb56
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Thu Nov  3 11:00:23 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Thu Nov  3 11:00:23 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=575e4739

Fix bugs resulting in ncurses-induced "crashes".

---
 bugzilla-viewer.py |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py
index 48b253e..45584a5 100755
--- a/bugzilla-viewer.py
+++ b/bugzilla-viewer.py
@@ -160,12 +160,14 @@ class MainWindow:
 
 	def init_screen(self):
 		(self.height, self.width) = self.screen.getmaxyx()
+		self.bugs_pad_width = self.width / 3 - 1
+		self.contents_pad_width = self.width - self.bugs_pad_width - 1
 
 		if self.height < 12 or self.width < 80:
 			raise TermTooSmall()
 
 		self.screen.border()
-		self.screen.vline(1, self.width / 3, curses.ACS_VLINE, self.height - 2)
+		self.screen.vline(1, self.bugs_pad_width + 1, curses.ACS_VLINE, self.height - 2)
 		self.screen.refresh()
 
 		self.fill_bugs_pad()
@@ -208,58 +210,56 @@ class MainWindow:
 		self.bugs_pad.refresh(
 			pos, 0,
 			1, 1,
-			self.height - 2, self.width / 3 - 1)
+			self.height - 2, self.bugs_pad_width)
 
 	def fill_contents_pad(self):
-		width = 2 * self.width / 3
-
 		bug = self.bugs[self.bugs_pad_pos]
 
 		output = []
-		output += textwrap.wrap(bug.summary(), width=width-2)
-		output.append("-" * (width - 2))
+		output += textwrap.wrap(bug.summary(), width=self.contents_pad_width-2)
+		output.append("-" * (self.contents_pad_width - 2))
 
 		cpvs = bug.cpvs()
 		if cpvs:
-			output += textwrap.wrap("Found package cpvs:", width=width-2)
+			output += textwrap.wrap("Found package cpvs:", width=self.contents_pad_width-2)
 			for cpv in cpvs:
-				output += textwrap.wrap(cpv, width=width-2)
-			output += textwrap.wrap("Press 'a' to add them to the stabilization queue.", width=width-2)
-			output.append("-" * (width - 2))
+				output += textwrap.wrap(cpv, width=self.contents_pad_width-2)
+			output += textwrap.wrap("Press 'a' to add them to the stabilization queue.", width=self.contents_pad_width-2)
+			output.append("-" * (self.contents_pad_width - 2))
 
 		deps = [self.bug_for_id(dep_id) for dep_id in bug.depends_on()]
 		if deps:
-			output += textwrap.wrap("Depends on:", width=width-2)
+			output += textwrap.wrap("Depends on:", width=self.contents_pad_width-2)
 			for dep in deps:
 				desc = "%d %s %s" % (dep.id_number(), dep.status(), dep.summary())
-				output += textwrap.wrap(desc, width=width-2)
-			output.append("-" * (width - 2))
+				output += textwrap.wrap(desc, width=self.contents_pad_width-2)
+			output.append("-" * (self.contents_pad_width - 2))
 	
 		related = self.related_bugs[bug.id_number()]
 		if related:
-			output += textwrap.wrap("Related bugs:", width=width-2)
+			output += textwrap.wrap("Related bugs:", width=self.contents_pad_width-2)
 			for related_bug in related:
 				if str(related_bug['bugid']) == str(bug.id_number()):
 					continue
 				desc = related_bug['bugid'] + " " + related_bug['desc']
-				output += textwrap.wrap(desc, width=width-2)
-			output.append("-" * (width - 2))
+				output += textwrap.wrap(desc, width=self.contents_pad_width-2)
+			output.append("-" * (self.contents_pad_width - 2))
 	
 		if bug.id_number() in repoman_dict and repoman_dict[bug.id_number()]:
-			output += textwrap.wrap("Repoman output:", width=width-2)
+			output += textwrap.wrap("Repoman output:", width=self.contents_pad_width-2)
 			lines = repoman_dict[bug.id_number()].split("\n")
 			for line in lines:
-				output += textwrap.wrap(line, width=width-2)
-			output.append("-" * (width - 2))
+				output += textwrap.wrap(line, width=self.contents_pad_width-2)
+			output.append("-" * (self.contents_pad_width - 2))
 	
 		for comment in bug.comments():
 			for line in comment.split("\n"):
-				output += textwrap.wrap(line, width=width-2)
-			output.append("-" * (width - 2))
+				output += textwrap.wrap(line, width=self.contents_pad_width-2)
+			output.append("-" * (self.contents_pad_width - 2))
 
 		self.contents_pad_length = len(output)
 
-		self.contents_pad = curses.newpad(max(self.contents_pad_length, self.height), width)
+		self.contents_pad = curses.newpad(max(self.contents_pad_length, self.height), self.contents_pad_width)
 		self.contents_pad.erase()
 
 		self.contents_pad_pos = 0
@@ -280,7 +280,7 @@ class MainWindow:
 	def refresh_contents_pad(self):
 		self.contents_pad.refresh(
 			self.contents_pad_pos, 0,
-			1, self.width / 3 + 1,
+			1, self.bugs_pad_width + 2,
 			self.height - 2, self.width - 2)
 		self.screen.refresh()
 	



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-11-21  8:34 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-11-21  8:34 UTC (permalink / raw
  To: gentoo-commits

commit:     6f2f2e0dde5c8a1f593fe523e8e72b6eeff5cbb9
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 21 08:34:19 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Mon Nov 21 08:34:19 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=6f2f2e0d

Automated finding candidates for stabilization.

---
 stabilization-candidates.py |  122 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 122 insertions(+), 0 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
new file mode 100755
index 0000000..5d0c3f8
--- /dev/null
+++ b/stabilization-candidates.py
@@ -0,0 +1,122 @@
+#!/usr/bin/env python
+# Copyright 2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import datetime
+import optparse
+import os.path
+import re
+import subprocess
+
+import bugz.bugzilla
+from portage.package.ebuild.getmaskingstatus import getmaskingstatus
+from portage.xml.metadata import MetaDataXML
+import portage.versions
+
+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", action="append", help="Gentoo arch to use, e.g. x86, amd64, ... Can be passed multiple times.")
+	parser.add_option("--days", dest="days", type=int, default=30, help="Number of days in the tree after stabilization is possible.")
+	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
+	parser.add_option("--category", dest="category", help="Portage category filter (default is all categories)")
+
+	(options, args) = parser.parse_args()
+	if not options.arch:
+		parser.error("--arch option is required")
+	if not options.repo:
+		parser.error("--repo option is required")
+	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)
+	bugzilla.auth()
+	
+	now = datetime.datetime.now()
+	for cp in portage.portdb.cp_all():
+		if options.category and not cp.startswith(options.category + "/"):
+			continue
+		best_stable = portage.versions.best(portage.portdb.match(cp))
+		if not best_stable:
+			continue
+		candidates = []
+		for cpv in portage.portdb.cp_list(cp):
+			# Only consider higher versions than best stable.
+			if portage.versions.pkgcmp(portage.versions.pkgsplit(cpv), portage.versions.pkgsplit(best_stable)) != 1:
+				continue
+
+			# Eliminate alpha, beta, pre, rc, and so on packages.
+			is_unstable = False
+			for suffix in portage.versions.endversion_keys:
+				if ("_" + suffix) in portage.versions.pkgsplit(cpv)[1]:
+					is_unstable = True
+					break
+			if is_unstable:
+				continue
+
+			# Eliminate hard masked packages among others.
+			if getmaskingstatus(cpv) not in [[u'~%s keyword' % arch] for arch in options.arch]:
+				continue
+
+			pv = portage.versions.catsplit(cpv)[1]
+			with open(os.path.join(options.repo, cp, 'ChangeLog')) as changelog_file:
+				regex = '\*%s \((.*)\)' % re.escape(pv)
+				match = re.search(regex, changelog_file.read())
+				if not match:
+					continue
+				changelog_date = datetime.datetime.strptime(match.group(1), '%d %b %Y')
+				if now - changelog_date < datetime.timedelta(days=options.days):
+					continue
+
+			candidates.append(cpv)
+		if not candidates:
+			continue
+		candidates.sort(key=portage.versions.cpv_sort_key())
+		print '\t\tWorking on %s. Candidates: %s' % (cp, ', '.join(candidates))
+		candidates.reverse()
+		best_candidate = None
+		cvs_path = os.path.join(options.repo, cp)
+		for candidate in candidates:
+			ebuild_name = portage.versions.catsplit(candidate)[1] + ".ebuild"
+			ebuild_path = os.path.join(cvs_path, ebuild_name)
+			manifest_path = os.path.join(cvs_path, 'Manifest')
+			original_contents = open(ebuild_path).read()
+			manifest_contents = open(manifest_path).read()
+			try:
+				for arch in options.arch:
+					subprocess.check_output(["ekeyword", arch, ebuild_name], cwd=cvs_path)
+				subprocess.check_output(["repoman", "manifest"], cwd=cvs_path)
+				subprocess.check_output(["repoman", "full"], cwd=cvs_path)
+			except subprocess.CalledProcessError:
+				continue
+			finally:
+				f = open(ebuild_path, "w")
+				f.write(original_contents)
+				f.close()
+				f = open(manifest_path, "w")
+				f.write(manifest_contents)
+				f.close()
+			best_candidate = candidate
+			break
+		if best_candidate:
+			# Do not risk trying to stabilize a package with known bugs.
+			bugs = bugzilla.search(cp, status=None)
+			if bugs:
+				continue
+
+			# Protection against filing a stabilization bug twice.
+			bugs = bugzilla.search(best_candidate)
+			if bugs:
+				continue
+
+			metadata = MetaDataXML(os.path.join(cvs_path, 'metadata.xml'), '/usr/portage/metadata/herds.xml')
+
+			# Spam protection (strip @ and domain name).
+			maintainer_string = re.sub('@[^\s]*', '', metadata.format_maintainer_string())
+
+			print (cp, best_stable, best_candidate, maintainer_string)



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-11-23  8:59 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-11-23  8:59 UTC (permalink / raw
  To: gentoo-commits

commit:     2730e673145944ab74b0e3967b0377cd504556d3
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 23 08:58:32 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Wed Nov 23 08:58:32 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=2730e673

Ignore ruby for now.

---
 stabilization-candidates.py |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 696ad9c..55c3da1 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -45,6 +45,11 @@ if __name__ == "__main__":
 	for cp in portage.portdb.cp_all():
 		if options.category and not cp.startswith(options.category + "/"):
 			continue
+
+		# Ignore ruby for now, bug #391645.
+		if 'ruby' in cp:
+			continue
+
 		best_stable = portage.versions.best(portage.portdb.match(cp))
 		if not best_stable:
 			continue



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-11-23  8:59 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-11-23  8:59 UTC (permalink / raw
  To: gentoo-commits

commit:     5a195bce432416b7486ec481d7dbb241c80fc412
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 23 08:57:03 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Wed Nov 23 08:57:03 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=5a195bce

Automatically file stabilization bugs.

---
 stabilization-candidates.py |   43 ++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 5d0c3f8..696ad9c 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -5,8 +5,10 @@
 import datetime
 import optparse
 import os.path
+import random
 import re
 import subprocess
+import urllib
 
 import bugz.bugzilla
 from portage.package.ebuild.getmaskingstatus import getmaskingstatus
@@ -21,6 +23,7 @@ if __name__ == "__main__":
 	parser = optparse.OptionParser()
 	parser.add_option("--arch", dest="arch", action="append", help="Gentoo arch to use, e.g. x86, amd64, ... Can be passed multiple times.")
 	parser.add_option("--days", dest="days", type=int, default=30, help="Number of days in the tree after stabilization is possible.")
+	parser.add_option("-l", "--limit", dest="limit", type="int", default=-1, help="Limit of filed bugs. Default is no limit.")
 	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
 	parser.add_option("--category", dest="category", help="Portage category filter (default is all categories)")
 
@@ -37,6 +40,7 @@ if __name__ == "__main__":
 	bugzilla = MyBugz(url)
 	bugzilla.auth()
 	
+	final_candidates = []
 	now = datetime.datetime.now()
 	for cp in portage.portdb.cp_all():
 		if options.category and not cp.startswith(options.category + "/"):
@@ -44,6 +48,7 @@ if __name__ == "__main__":
 		best_stable = portage.versions.best(portage.portdb.match(cp))
 		if not best_stable:
 			continue
+		print 'Working on %s...' % cp
 		candidates = []
 		for cpv in portage.portdb.cp_list(cp):
 			# Only consider higher versions than best stable.
@@ -58,6 +63,12 @@ if __name__ == "__main__":
 					break
 			if is_unstable:
 				continue
+			
+			# Eliminate 'live' packages. Obviously have some false positives,
+			# but it'd be much worse to miss something. There are variations
+			# like -r9999 or .9999 in the tree.
+			if '99' in cpv:
+				continue
 
 			# Eliminate hard masked packages among others.
 			if getmaskingstatus(cpv) not in [[u'~%s keyword' % arch] for arch in options.arch]:
@@ -77,7 +88,6 @@ if __name__ == "__main__":
 		if not candidates:
 			continue
 		candidates.sort(key=portage.versions.cpv_sort_key())
-		print '\t\tWorking on %s. Candidates: %s' % (cp, ', '.join(candidates))
 		candidates.reverse()
 		best_candidate = None
 		cvs_path = os.path.join(options.repo, cp)
@@ -115,8 +125,31 @@ if __name__ == "__main__":
 				continue
 
 			metadata = MetaDataXML(os.path.join(cvs_path, 'metadata.xml'), '/usr/portage/metadata/herds.xml')
+			maintainer_split = metadata.format_maintainer_string().split(' ', 1)
+			maintainer = maintainer_split[0]
+			if len(maintainer_split) > 1:
+				other_maintainers = maintainer_split[1].split(',')
+			else:
+				other_maintainers = []
+			url = 'http://packages.gentoo.org/package/%s?arches=linux' % urllib.quote(cp)
+			final_candidates.append((best_candidate, url, maintainer, other_maintainers))
 
-			# Spam protection (strip @ and domain name).
-			maintainer_string = re.sub('@[^\s]*', '', metadata.format_maintainer_string())
-
-			print (cp, best_stable, best_candidate, maintainer_string)
+	if options.limit != -1:
+		final_candidates = random.sample(final_candidates, min(options.limit, len(final_candidates)))
+	for x in final_candidates:
+		best_candidate, url, maintainer, other_maintainers = x
+		description = ('Is it OK to stabilize =%s ?\n\n' % best_candidate +
+		               'If so, please CC arches and add STABLEREQ keyword.\n\n' +
+			       'Stabilization of this package has been repoman-checked on the following arches: %s' % ', '.join(options.arch))
+		bug_id = bugzilla.post('Gentoo Linux',
+		                       'Keywording and Stabilization',
+				       'Please stabilize =%s' % best_candidate,
+				       description,
+				       url=url,
+				       assigned_to=maintainer,
+				       cc=other_maintainers,
+				       severity='enhancement')
+		if bug_id == 0:
+			print 'Submitting bug for %s failed. :-(' % best_candidate
+		else:
+			print 'Submitted bug #%d for %s. ;-)' % (bug_id, best_candidate)



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-11-30 17:38 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-11-30 17:38 UTC (permalink / raw
  To: gentoo-commits

commit:     b41b45df8693af1b00b59f8ad64ce4d4e1815cbf
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 30 17:37:53 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Wed Nov 30 17:37:53 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=b41b45df

Do not file bugs by default, and only stabilze latest version in ~arch.

---
 stabilization-candidates.py |  118 +++++++++++++++++++++++--------------------
 1 files changed, 63 insertions(+), 55 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 55c3da1..8feee30 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -26,6 +26,7 @@ if __name__ == "__main__":
 	parser.add_option("-l", "--limit", dest="limit", type="int", default=-1, help="Limit of filed bugs. Default is no limit.")
 	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
 	parser.add_option("--category", dest="category", help="Portage category filter (default is all categories)")
+	parser.add_option("--file-bugs", dest="file_bugs", action="store_true", default=False, help="File stabilization bugs for detected candidates. Otherwise (default) the candidates are just displayed.")
 
 	(options, args) = parser.parse_args()
 	if not options.arch:
@@ -92,69 +93,76 @@ if __name__ == "__main__":
 			candidates.append(cpv)
 		if not candidates:
 			continue
+
 		candidates.sort(key=portage.versions.cpv_sort_key())
 		candidates.reverse()
-		best_candidate = None
+
+		# Only consider the best version in ~arch for stabilization.
+		# It's usually better tested, and often maintainers refuse
+		# to stabilize anything else, e.g. bug #391607.
+		best_candidate = candidates[0]
+
 		cvs_path = os.path.join(options.repo, cp)
-		for candidate in candidates:
-			ebuild_name = portage.versions.catsplit(candidate)[1] + ".ebuild"
-			ebuild_path = os.path.join(cvs_path, ebuild_name)
-			manifest_path = os.path.join(cvs_path, 'Manifest')
-			original_contents = open(ebuild_path).read()
-			manifest_contents = open(manifest_path).read()
-			try:
-				for arch in options.arch:
-					subprocess.check_output(["ekeyword", arch, ebuild_name], cwd=cvs_path)
-				subprocess.check_output(["repoman", "manifest"], cwd=cvs_path)
-				subprocess.check_output(["repoman", "full"], cwd=cvs_path)
-			except subprocess.CalledProcessError:
-				continue
-			finally:
-				f = open(ebuild_path, "w")
-				f.write(original_contents)
-				f.close()
-				f = open(manifest_path, "w")
-				f.write(manifest_contents)
-				f.close()
-			best_candidate = candidate
-			break
-		if best_candidate:
-			# Do not risk trying to stabilize a package with known bugs.
-			bugs = bugzilla.search(cp, status=None)
-			if bugs:
-				continue
+		ebuild_name = portage.versions.catsplit(best_candidate)[1] + ".ebuild"
+		ebuild_path = os.path.join(cvs_path, ebuild_name)
+		manifest_path = os.path.join(cvs_path, 'Manifest')
+		original_contents = open(ebuild_path).read()
+		manifest_contents = open(manifest_path).read()
+		try:
+			for arch in options.arch:
+				subprocess.check_output(["ekeyword", arch, ebuild_name], cwd=cvs_path)
+			subprocess.check_output(["repoman", "manifest"], cwd=cvs_path)
+			subprocess.check_output(["repoman", "full"], cwd=cvs_path)
+		except subprocess.CalledProcessError:
+			continue
+		finally:
+			f = open(ebuild_path, "w")
+			f.write(original_contents)
+			f.close()
+			f = open(manifest_path, "w")
+			f.write(manifest_contents)
+			f.close()
 
-			# Protection against filing a stabilization bug twice.
-			bugs = bugzilla.search(best_candidate)
-			if bugs:
-				continue
+		# Do not risk trying to stabilize a package with known bugs.
+		bugs = bugzilla.search(cp, status=None)
+		if bugs:
+			continue
 
-			metadata = MetaDataXML(os.path.join(cvs_path, 'metadata.xml'), '/usr/portage/metadata/herds.xml')
-			maintainer_split = metadata.format_maintainer_string().split(' ', 1)
-			maintainer = maintainer_split[0]
-			if len(maintainer_split) > 1:
-				other_maintainers = maintainer_split[1].split(',')
-			else:
-				other_maintainers = []
-			url = 'http://packages.gentoo.org/package/%s?arches=linux' % urllib.quote(cp)
-			final_candidates.append((best_candidate, url, maintainer, other_maintainers))
+		# Protection against filing a stabilization bug twice.
+		bugs = bugzilla.search(best_candidate)
+		if bugs:
+			continue
+
+		metadata = MetaDataXML(os.path.join(cvs_path, 'metadata.xml'), '/usr/portage/metadata/herds.xml')
+		maintainer_split = metadata.format_maintainer_string().split(' ', 1)
+		maintainer = maintainer_split[0]
+		if len(maintainer_split) > 1:
+			other_maintainers = maintainer_split[1].split(',')
+		else:
+			other_maintainers = []
+		url = 'http://packages.gentoo.org/package/%s?arches=linux' % urllib.quote(cp)
+		final_candidates.append((best_candidate, url, maintainer, other_maintainers))
 
 	if options.limit != -1:
 		final_candidates = random.sample(final_candidates, min(options.limit, len(final_candidates)))
 	for x in final_candidates:
 		best_candidate, url, maintainer, other_maintainers = x
-		description = ('Is it OK to stabilize =%s ?\n\n' % best_candidate +
-		               'If so, please CC arches and add STABLEREQ keyword.\n\n' +
-			       'Stabilization of this package has been repoman-checked on the following arches: %s' % ', '.join(options.arch))
-		bug_id = bugzilla.post('Gentoo Linux',
-		                       'Keywording and Stabilization',
-				       'Please stabilize =%s' % best_candidate,
-				       description,
-				       url=url,
-				       assigned_to=maintainer,
-				       cc=other_maintainers,
-				       severity='enhancement')
-		if bug_id == 0:
-			print 'Submitting bug for %s failed. :-(' % best_candidate
+
+		if options.file_bugs:
+			description = ('Is it OK to stabilize =%s ?\n\n' % best_candidate +
+				       'If so, please CC arches and add STABLEREQ keyword.\n\n' +
+				       'Stabilization of this package has been repoman-checked on the following arches: %s' % ', '.join(options.arch))
+			bug_id = bugzilla.post('Gentoo Linux',
+					       'Keywording and Stabilization',
+					       'Please stabilize =%s' % best_candidate,
+					       description,
+					       url=url,
+					       assigned_to=maintainer,
+					       cc=other_maintainers,
+					       severity='enhancement')
+			if bug_id == 0:
+				print 'Submitting bug for %s failed. :-(' % best_candidate
+			else:
+				print 'Submitted bug #%d for %s. ;-)' % (bug_id, best_candidate)
 		else:
-			print 'Submitted bug #%d for %s. ;-)' % (bug_id, best_candidate)
+			print (best_candidate, maintainer, other_maintainers)



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-12-01 18:47 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-12-01 18:47 UTC (permalink / raw
  To: gentoo-commits

commit:     19044e7c148d10a58c47476582925fbab10b574b
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Thu Dec  1 18:47:26 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Thu Dec  1 18:47:26 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=19044e7c

Check KEYWORDS for all requested arches.

---
 stabilization-candidates.py |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index d2e539c..44cbe75 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -102,6 +102,15 @@ if __name__ == "__main__":
 			if now - changelog_date < datetime.timedelta(days=options.days):
 				continue
 
+		keywords = portage.db["/"]["porttree"].dbapi.aux_get(best_candidate, ['KEYWORDS'])[0]
+		missing_arch = False
+		for arch in options.arch:
+			if arch not in keywords:
+				missing_arch = True
+				break
+		if missing_arch:
+			continue
+
 		cvs_path = os.path.join(options.repo, cp)
 		ebuild_name = portage.versions.catsplit(best_candidate)[1] + ".ebuild"
 		ebuild_path = os.path.join(cvs_path, ebuild_name)



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-12-01 18:47 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-12-01 18:47 UTC (permalink / raw
  To: gentoo-commits

commit:     ed362d1d47dd71a7deb1610cd1178305522339ac
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Thu Dec  1 18:46:56 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Thu Dec  1 18:46:56 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=ed362d1d

Really only consider latest version in ~arch.

---
 stabilization-candidates.py |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 8feee30..d2e539c 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -80,16 +80,6 @@ if __name__ == "__main__":
 			if getmaskingstatus(cpv) not in [[u'~%s keyword' % arch] for arch in options.arch]:
 				continue
 
-			pv = portage.versions.catsplit(cpv)[1]
-			with open(os.path.join(options.repo, cp, 'ChangeLog')) as changelog_file:
-				regex = '\*%s \((.*)\)' % re.escape(pv)
-				match = re.search(regex, changelog_file.read())
-				if not match:
-					continue
-				changelog_date = datetime.datetime.strptime(match.group(1), '%d %b %Y')
-				if now - changelog_date < datetime.timedelta(days=options.days):
-					continue
-
 			candidates.append(cpv)
 		if not candidates:
 			continue
@@ -97,11 +87,21 @@ if __name__ == "__main__":
 		candidates.sort(key=portage.versions.cpv_sort_key())
 		candidates.reverse()
 
-		# Only consider the best version in ~arch for stabilization.
+		# Only consider the best version for stabilization.
 		# It's usually better tested, and often maintainers refuse
 		# to stabilize anything else, e.g. bug #391607.
 		best_candidate = candidates[0]
 
+		pv = portage.versions.catsplit(best_candidate)[1]
+		with open(os.path.join(options.repo, cp, 'ChangeLog')) as changelog_file:
+			regex = '\*%s \((.*)\)' % re.escape(pv)
+			match = re.search(regex, changelog_file.read())
+			if not match:
+				continue
+			changelog_date = datetime.datetime.strptime(match.group(1), '%d %b %Y')
+			if now - changelog_date < datetime.timedelta(days=options.days):
+				continue
+
 		cvs_path = os.path.join(options.repo, cp)
 		ebuild_name = portage.versions.catsplit(best_candidate)[1] + ".ebuild"
 		ebuild_path = os.path.join(cvs_path, ebuild_name)



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-12-01 18:56 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-12-01 18:56 UTC (permalink / raw
  To: gentoo-commits

commit:     3905490ccb9f80f8a846e2d3cba60479a075b9cf
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Thu Dec  1 18:55:51 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Thu Dec  1 18:55:51 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=3905490c

Add an --exclude option instead of hardcoding ruby exclusion.

---
 stabilization-candidates.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 44cbe75..62efa04 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -26,6 +26,7 @@ if __name__ == "__main__":
 	parser.add_option("-l", "--limit", dest="limit", type="int", default=-1, help="Limit of filed bugs. Default is no limit.")
 	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
 	parser.add_option("--category", dest="category", help="Portage category filter (default is all categories)")
+	parser.add_option("--exclude", dest="exclude", help="Regular expression for excluded packages.")
 	parser.add_option("--file-bugs", dest="file_bugs", action="store_true", default=False, help="File stabilization bugs for detected candidates. Otherwise (default) the candidates are just displayed.")
 
 	(options, args) = parser.parse_args()
@@ -47,8 +48,7 @@ if __name__ == "__main__":
 		if options.category and not cp.startswith(options.category + "/"):
 			continue
 
-		# Ignore ruby for now, bug #391645.
-		if 'ruby' in cp:
+		if options.exclude and re.match(options.exclude, cp):
 			continue
 
 		best_stable = portage.versions.best(portage.portdb.match(cp))



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-12-06 11:14 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-12-06 11:14 UTC (permalink / raw
  To: gentoo-commits

commit:     2dacce21a7418c147ab830e3f8e99ad682e3a51b
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Tue Dec  6 11:13:59 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Tue Dec  6 11:13:59 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=2dacce21

When repoman manifest fails, do not crash entire script.

---
 bugzilla-viewer.py |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py
index 45584a5..ce0b2eb 100755
--- a/bugzilla-viewer.py
+++ b/bugzilla-viewer.py
@@ -353,9 +353,10 @@ if __name__ == "__main__":
 					manifest_contents = open(manifest_path).read()
 					try:
 						output = repoman_dict[bug.id_number()]
-						output += subprocess.Popen(["ekeyword", options.arch, ebuild_name], cwd=cvs_path, stdout=subprocess.PIPE).communicate()[0]
-						subprocess.check_call(["repoman", "manifest"], cwd=cvs_path)
-						output += subprocess.Popen(["repoman", "full"], cwd=cvs_path, stdout=subprocess.PIPE).communicate()[0]
+						output += subprocess.Popen(["ekeyword", options.arch, ebuild_name], cwd=cvs_path, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
+						# repoman manifest may fail if files are unfetchable. It shouldn't abort this script.
+						output += subprocess.Popen(["repoman", "manifest"], cwd=cvs_path, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
+						output += subprocess.Popen(["repoman", "full"], cwd=cvs_path, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
 						repoman_dict[bug.id_number()] = output
 					finally:
 						f = open(ebuild_path, "w")



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2011-12-14  7:23 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2011-12-14  7:23 UTC (permalink / raw
  To: gentoo-commits

commit:     05c2a91bc08d694c8d004126e2b99a610a67759b
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 14 07:23:10 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Wed Dec 14 07:23:10 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=05c2a91b

Properly handle simultaneous stabilization of multiple packages
in a single bug.

---
 bugzilla-viewer.py |   44 ++++++++++++++++++++++++--------------------
 1 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py
index ce0b2eb..e3cbcac 100755
--- a/bugzilla-viewer.py
+++ b/bugzilla-viewer.py
@@ -342,29 +342,33 @@ if __name__ == "__main__":
 			pv = portage.versions.cpv_getkey(cpv)
 			if options.verbose:
 				related_bugs[bug.id_number()] += bugzilla.search(pv, status=None)
-
-			if options.repo:
-				cvs_path = os.path.join(options.repo, pv)
-				ebuild_name = portage.versions.catsplit(cpv)[1] + ".ebuild"
-				ebuild_path = os.path.join(cvs_path, ebuild_name)
-				manifest_path = os.path.join(cvs_path, 'Manifest')
-				if os.path.exists(ebuild_path):
-					original_contents = open(ebuild_path).read()
-					manifest_contents = open(manifest_path).read()
-					try:
-						output = repoman_dict[bug.id_number()]
+		if options.repo:
+			to_restore = {}
+			try:
+				output = repoman_dict[bug.id_number()]
+				for cpv in bug.cpvs():
+					pv = portage.versions.cpv_getkey(cpv)
+					cvs_path = os.path.join(options.repo, pv)
+					ebuild_name = portage.versions.catsplit(cpv)[1] + ".ebuild"
+					ebuild_path = os.path.join(cvs_path, ebuild_name)
+					manifest_path = os.path.join(cvs_path, 'Manifest')
+					if os.path.exists(ebuild_path):
+						if ebuild_path not in to_restore:
+							to_restore[ebuild_path] = open(ebuild_path).read()
+						if manifest_path not in to_restore:
+							to_restore[manifest_path] = open(manifest_path).read()
 						output += subprocess.Popen(["ekeyword", options.arch, ebuild_name], cwd=cvs_path, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
 						# repoman manifest may fail if files are unfetchable. It shouldn't abort this script.
 						output += subprocess.Popen(["repoman", "manifest"], cwd=cvs_path, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
-						output += subprocess.Popen(["repoman", "full"], cwd=cvs_path, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
-						repoman_dict[bug.id_number()] = output
-					finally:
-						f = open(ebuild_path, "w")
-						f.write(original_contents)
-						f.close()
-						f = open(manifest_path, "w")
-						f.write(manifest_contents)
-						f.close()
+				pvs = list(set([portage.versions.cpv_getkey(cpv) for cpv in bug.cpvs()]))
+				for pv in pvs:
+					cvs_path = os.path.join(options.repo, pv)
+					output += subprocess.Popen(["repoman", "full"], cwd=cvs_path, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
+				repoman_dict[bug.id_number()] = output
+			finally:
+				for path in to_restore:
+					with open(path, "w") as f:
+						f.write(to_restore[path])
 		dep_bug_ids += bug.depends_on()
 
 	dep_bug_ids = list(set(dep_bug_ids))



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2012-01-21 17:05 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-01-21 17:05 UTC (permalink / raw
  To: gentoo-commits

commit:     ec5a1892fb2d15238a303ccf0ef153cd817d140b
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 21 17:05:00 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Sat Jan 21 17:05:00 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=ec5a1892

Fix bugs related to empty lines handling.

---
 batch-stabilize.py |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/batch-stabilize.py b/batch-stabilize.py
index 0289c42..e2c4976 100755
--- a/batch-stabilize.py
+++ b/batch-stabilize.py
@@ -62,7 +62,10 @@ if __name__ == "__main__":
 		stabilization_dict = {}
 		bug_id = -1
 		for line in input_file:
-			if line == "\n":
+			line = line.strip()
+
+			# Skip empty/whitespace lines.
+			if not line:
 				continue
 
 			if line.startswith("#"):
@@ -78,9 +81,9 @@ if __name__ == "__main__":
 				print 'Could not recognize bug id'
 				sys.exit(1)
 
-			if not line.endswith("\n"):
-				line += "\n"
-			cpv = line[1:-1]
+			# Drop the leading '='.
+			cpv = line[1:]
+
 			p = portage.versions.catsplit(cpv)[1]
 			pn = portage.versions.pkgsplit(cpv)[0]
 			ebuild_name = p + ".ebuild"



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2012-01-27 14:55 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-01-27 14:55 UTC (permalink / raw
  To: gentoo-commits

commit:     8aff939c6831ac73eb6a6a4a07a6c475e15ed308
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 27 14:54:19 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Fri Jan 27 14:54:19 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=8aff939c

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
 
-CPV_REGEX = 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 = r'.*(\{.+?[^\\]\})'
-	p = re.compile(r)
-
-	s = orig[:]
-	res = list()
-
-	m = p.search(s)
-	if m is not None:
-		sub = m.group(1)
-		open_brace = s.find(sub)
-		close_brace = 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
 
 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
 
-class Bug:
-	def __init__(self, xml=None, id_number=None, summary=None, status=None):
-		if xml is not None:
-			self.__id = int(xml.find("bug_id").text)
-			self.__summary = xml.find("short_desc").text
-			self.__status = xml.find("bug_status").text
-			self.__depends_on = [int(dep.text) for dep in xml.findall("dependson")]
-			self.__comments = [c.find("who").text + "\n" + c.find("thetext").text for c in xml.findall("long_desc")]
-		if id_number is not None:
-			self.__id = id_number
-		if summary is not None:
-			self.__summary = summary
-		if status is not None:
-			self.__status = status
-		self.__cpvs_detected = False
-		self.__cpvs = []
-	
-	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_detected = True
-	
-	def id_number(self):
-		return self.__id
-	
-	def summary(self):
-		return self.__summary
-	
-	def status(self):
-		return self.__status
-	
-	def depends_on(self):
-		return self.__depends_on
-	
-	def comments(self):
-		return self.__comments
-	
-	def cpvs(self):
-		assert(self.__cpvs_detected)
-		return self.__cpvs
-
 class BugQueue:
 	def __init__(self):
 		self.__bug_list = []
@@ -320,8 +249,10 @@ if __name__ == "__main__":
 	}
 	if options.security:
 		criteria['assigned_to'] = 'security@gentoo.org'
+	bugs = []
 	raw_bugs = bugzilla.search("", **criteria)
-	bugs = [Bug(xml) for xml in bugzilla.get([bug['bugid'] for bug in raw_bugs]).findall("bug")]
+	for chunk in chunks(raw_bugs, 100):
+		bugs +=  [Bug(xml) for xml in bugzilla.get([bug['bugid'] for bug in chunk]).findall("bug")]
 
 	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 = 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 = r'.*(\{.+?[^\\]\})'
+	p = re.compile(r)
+
+	s = orig[:]
+	res = list()
+
+	m = p.search(s)
+	if m is not None:
+		sub = m.group(1)
+		open_brace = s.find(sub)
+		close_brace = 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=None, id_number=None, summary=None, status=None):
+		if xml is not None:
+			self.__id = int(xml.find("bug_id").text)
+			self.__summary = xml.find("short_desc").text
+			self.__status = xml.find("bug_status").text
+			self.__depends_on = [int(dep.text) for dep in xml.findall("dependson")]
+			self.__comments = [c.find("who").text + "\n" + c.find("thetext").text for c in xml.findall("long_desc")]
+			self.__cc = [cc.text for cc in xml.findall("cc")]
+
+			self.__keywords = []
+			keywords_elem = xml.find("keywords")
+			if keywords_elem is not None and keywords_elem.text:
+				self.__keywords = [k.strip() for k in keywords_elem.text.split(",")]
+		if id_number is not None:
+			self.__id = id_number
+		if summary is not None:
+			self.__summary = summary
+		if status is not None:
+			self.__status = status
+		self.__cpvs_detected = False
+		self.__cpvs = []
+	
+	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_detected = True
+	
+	def id_number(self):
+		return self.__id
+	
+	def summary(self):
+		return self.__summary
+	
+	def status(self):
+		return self.__status
+	
+	def depends_on(self):
+		return self.__depends_on
+	
+	def comments(self):
+		return self.__comments
+	
+	def cc(self):
+		return self.__cc
+
+	def keywords(self):
+		return self.__keywords
+	
+	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__ == "__main__":
+	parser = optparse.OptionParser()
+	(options, args) = parser.parse_args()
+	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()
+	
+	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")]
+	for bug in bugs:
+		if 'STABLEREQ' in bug.keywords():
+			continue
+		arch_found = False
+		for arch in portage.archlist:
+			if '%s@gentoo.org' % arch in bug.cc():
+				arch_found = True
+				break
+		if arch_found:
+			continue
+		if len(bug.comments()) > 1:
+			continue
+		bug.detect_cpvs()
+		if len(bug.cpvs()) != 1:
+			continue
+		cp = 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__ == "__main__":
 		ebuild_name = portage.versions.catsplit(best_candidate)[1] + ".ebuild"
 		ebuild_path = os.path.join(cvs_path, ebuild_name)
 		manifest_path = os.path.join(cvs_path, 'Manifest')
-		original_contents = open(ebuild_path).read()
-		manifest_contents = open(manifest_path).read()
+		try:
+			original_contents = open(ebuild_path).read()
+			manifest_contents = open(manifest_path).read()
+		except IOError, e:
+			print e
+			continue
 		try:
 			for arch in options.arch:
 				subprocess.check_output(["ekeyword", arch, ebuild_name], cwd=cvs_path)



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2012-02-02 16:48 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-02-02 16:48 UTC (permalink / raw
  To: gentoo-commits

commit:     e6c4d9a4da903a2c4d1f190089bed7e365d28f39
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Thu Feb  2 16:47:36 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Thu Feb  2 16:47:36 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=e6c4d9a4

Working implementation of maintainer-timeout.

---
 common.py             |    5 +++++
 maintainer-timeout.py |   25 +++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/common.py b/common.py
index d6841fb..ad25ad8 100644
--- a/common.py
+++ b/common.py
@@ -2,6 +2,7 @@
 # Distributed under the terms of the GNU General Public License v2
 
 import cStringIO
+import datetime
 import re
 
 import portage
@@ -50,6 +51,7 @@ class Bug:
 			self.__depends_on = [int(dep.text) for dep in xml.findall("dependson")]
 			self.__comments = [c.find("who").text + "\n" + c.find("thetext").text for c in xml.findall("long_desc")]
 			self.__cc = [cc.text for cc in xml.findall("cc")]
+			self.__creation_timestamp = datetime.datetime.strptime(xml.find('creation_ts').text, '%Y-%m-%d %H:%M:%S +0000')
 
 			self.__keywords = []
 			keywords_elem = xml.find("keywords")
@@ -92,6 +94,9 @@ class Bug:
 	def cc(self):
 		return self.__cc
 
+	def creation_timestamp(self):
+		return self.__creation_timestamp
+
 	def keywords(self):
 		return self.__keywords
 	

diff --git a/maintainer-timeout.py b/maintainer-timeout.py
index c75edd6..ee096c4 100755
--- a/maintainer-timeout.py
+++ b/maintainer-timeout.py
@@ -2,6 +2,7 @@
 # Copyright 2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+import datetime
 import optparse
 
 import bugz.bugzilla
@@ -17,6 +18,7 @@ class MyBugz(bugz.bugzilla.Bugz):
 
 if __name__ == "__main__":
 	parser = optparse.OptionParser()
+	parser.add_option("--days", dest="days", type=int, default=30, help="Number of days after maintainer timeout occurs.")
 	(options, args) = parser.parse_args()
 	if args:
 		parser.error("unrecognized command-line args")
@@ -31,6 +33,7 @@ if __name__ == "__main__":
 	for chunk in chunks(raw_bugs, 100):
 		bugs +=  [Bug(xml) for xml in bugzilla.get([bug['bugid'] for bug in chunk]).findall("bug")]
 	for bug in bugs:
+		# Skip bugs where stabilization seems to be already in progress.
 		if 'STABLEREQ' in bug.keywords():
 			continue
 		arch_found = False
@@ -40,12 +43,30 @@ if __name__ == "__main__":
 				break
 		if arch_found:
 			continue
+
+		# Skip bugs with comments, they may indicate objections or problem reports.
 		if len(bug.comments()) > 1:
 			continue
+
+		# Skip too recent bugs.
+		if datetime.datetime.now() - bug.creation_timestamp() < datetime.timedelta(days=options.days):
+			continue
+
 		bug.detect_cpvs()
 		if len(bug.cpvs()) != 1:
 			continue
+		target_keywords = set()
 		cp = 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)
+			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(),
+			', '.join(list(target_keywords)))



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2012-03-09 11:49 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-03-09 11:49 UTC (permalink / raw
  To: gentoo-commits

commit:     b95113ab4b205b9de68b13ec8f30a8f6c5f1415e
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Fri Mar  9 07:31:36 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Fri Mar  9 07:31:36 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=b95113ab

Improved handling of CVS conflicts.

---
 batch-stabilize.py |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/batch-stabilize.py b/batch-stabilize.py
index e2c4976..db869bb 100755
--- a/batch-stabilize.py
+++ b/batch-stabilize.py
@@ -2,10 +2,12 @@
 # Copyright 2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+import glob
 import itertools
 import optparse
 import os
 import re
+import shutil
 import subprocess
 import sys
 
@@ -23,7 +25,10 @@ def print_and_log(message, log):
 
 def run_command(args, cwd, log):
 	try:
-		log.write("Running %r in %s...\n" % (args, cwd))
+		message = "Running %r in %s...\n" % (args, cwd)
+		sys.stdout.write(message)
+		log.write(message)
+
 		cmd  = subprocess.Popen(args, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 		output = cmd.communicate()[0]
 		log.write("Finished with exit code %d\n" % cmd.returncode)
@@ -111,13 +116,15 @@ if __name__ == "__main__":
 					cvs_path = os.path.join(options.repo, pn)
 					print_and_log('Working in %s...' % cvs_path, log_file)
 
-					# Remove existing changelog to avoid adding duplicate entries.
-					try:
-						os.remove(os.path.join(cvs_path, 'ChangeLog'))
-					except OSError:
-						pass
+					# Remove whole directory to prevent problems with conflicts.
+					if os.path.exists(cvs_path):
+						try:
+							shutil.rmtree(cvs_path)
+						except OSError:
+							print '!!! rmtree %s failed' % cvs_path
+							sys.exit(1)
 
-					if run_command(["cvs", "up"], cvs_path, log_file)[0] != 0:
+					if run_command(["cvs", "up", pn], options.repo, log_file)[0] != 0:
 						print '!!! cvs up failed'
 						sys.exit(1)
 					if run_command(["ekeyword", options.arch, ebuild_name], cvs_path, log_file)[0] != 0:



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2012-03-09 11:49 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-03-09 11:49 UTC (permalink / raw
  To: gentoo-commits

commit:     4a2ba0432b825af79fd4348689d3ae9033450b88
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Fri Mar  9 11:49:10 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Fri Mar  9 11:49:10 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=4a2ba043

Avoid duplicating work: remember which bugs have been done.

---
 batch-stabilize.py |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/batch-stabilize.py b/batch-stabilize.py
index db869bb..877e5dc 100755
--- a/batch-stabilize.py
+++ b/batch-stabilize.py
@@ -6,6 +6,7 @@ import glob
 import itertools
 import optparse
 import os
+import pickle
 import re
 import shutil
 import subprocess
@@ -37,6 +38,10 @@ def run_command(args, cwd, log):
 	finally:
 		log.flush()
 
+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)
@@ -58,6 +63,11 @@ if __name__ == "__main__":
 	if args:
 		parser.error("unrecognized command-line args")
 
+	done_bugs = []
+	if os.path.exists('batch-stabilize.state'):
+		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)
@@ -110,6 +120,10 @@ if __name__ == "__main__":
 
 		with open('batch-stabilize.log', 'a') as log_file:
 			for bug_id in stabilization_dict:
+				if bug_id in done_bugs:
+					print_and_log('Skipping bug #%d because it is marked as done.' % bug_id, log_file)
+					continue
+
 				print_and_log('Working on bug %d...' % bug_id, log_file)
 				commit_message = "%s stable wrt bug #%d" % (options.arch, bug_id)
 				for (pn, ebuild_name) in stabilization_dict[bug_id]:
@@ -140,10 +154,11 @@ if __name__ == "__main__":
 					# It seems that cvs diff returns 1 if there are differences.
 					if return_code == 0 and not output:
 						print_and_log('Seems already keyworded, skipping.', log_file)
+						done_bugs.append(bug_id)
+						save_state(done_bugs)
 						continue
 					if run_command(["echangelog", commit_message], cvs_path, log_file)[0] != 0:
-						print '!!! echangelog failed'
-						sys.exit(1)
+						print_and_log('echangelog failed, maybe just the Manifest is being updated; continuing', log_file)
 					if run_command(["repoman", "manifest"], cvs_path, log_file)[0] != 0:
 						print '!!! repoman manifest failed'
 						sys.exit(1)
@@ -162,6 +177,8 @@ if __name__ == "__main__":
 
 				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)
@@ -181,3 +198,9 @@ if __name__ == "__main__":
 						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')



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2012-03-27 15:26 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-03-27 15:26 UTC (permalink / raw
  To: gentoo-commits

commit:     588a007bdde5dcb943557d4448a2c317a075763a
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 27 15:26:09 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Tue Mar 27 15:26:09 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=588a007b

Also consider STABLEREQ bugs for maintainer timeout.

Someone cleverly added STABLEREQ keyword to those bugs.

---
 maintainer-timeout.py |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/maintainer-timeout.py b/maintainer-timeout.py
index ee096c4..c825f5d 100755
--- a/maintainer-timeout.py
+++ b/maintainer-timeout.py
@@ -34,8 +34,6 @@ if __name__ == "__main__":
 		bugs +=  [Bug(xml) for xml in bugzilla.get([bug['bugid'] for bug in chunk]).findall("bug")]
 	for bug in bugs:
 		# Skip bugs where stabilization seems to be already in progress.
-		if 'STABLEREQ' in bug.keywords():
-			continue
 		arch_found = False
 		for arch in portage.archlist:
 			if '%s@gentoo.org' % arch in bug.cc():



^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2012-10-08 16:03 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-10-08 16:03 UTC (permalink / raw
  To: gentoo-commits

commit:     0b5b0ec58a8551b5fb6ff4386b05a76b7829a0f2
Author:     William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Sun May  6 18:40:04 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> 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)
 	


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2012-10-08 16:03 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-10-08 16:03 UTC (permalink / raw
  To: gentoo-commits

commit:     702f27541b77cfd3878284851dc055872cfab905
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 28 07:44:27 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Sat Apr 28 07:44:27 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=702f2754

Remove --limit option

This will make it possible to file bugs
as packages are considered, not in one batch
at the end.

---
 stabilization-candidates.py |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index d4c82b9..3b2b72e 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -21,7 +21,6 @@ if __name__ == "__main__":
 	parser = optparse.OptionParser()
 	parser.add_option("--arch", dest="arch", action="append", help="Gentoo arch to use, e.g. x86, amd64, ... Can be passed multiple times.")
 	parser.add_option("--days", dest="days", type=int, default=30, help="Number of days in the tree after stabilization is possible.")
-	parser.add_option("-l", "--limit", dest="limit", type="int", default=-1, help="Limit of filed bugs. Default is no limit.")
 	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
 	parser.add_option("--category", dest="category", help="Portage category filter (default is all categories)")
 	parser.add_option("--exclude", dest="exclude", help="Regular expression for excluded packages.")
@@ -157,8 +156,6 @@ if __name__ == "__main__":
 		url = 'http://packages.gentoo.org/package/%s?arches=linux' % urllib.quote(cp)
 		final_candidates.append((best_candidate, url, maintainer, other_maintainers))
 
-	if options.limit != -1:
-		final_candidates = random.sample(final_candidates, min(options.limit, len(final_candidates)))
 	for x in final_candidates:
 		best_candidate, url, maintainer, other_maintainers = x
 


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2012-10-08 16:03 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-10-08 16:03 UTC (permalink / raw
  To: gentoo-commits

commit:     a6b515fc6fd3bf1800797ec9b75ae2dcd9eca565
Author:     William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 19 14:00:06 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Thu Apr 19 14:00:06 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=a6b515fc



---
 stabilization-candidates.py |   48 +++++++++++++++++++++---------------------
 1 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 1a7211c..d4c82b9 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -10,14 +10,12 @@ import re
 import subprocess
 import urllib
 
-import bugz.bugzilla
+from bugz.bugzilla import BugzillaProxy
 from portage.package.ebuild.getmaskingstatus import getmaskingstatus
 from portage.xml.metadata import MetaDataXML
 import portage.versions
 
-class MyBugz(bugz.bugzilla.Bugz):
-	def get_input(self, prompt):
-		return raw_input(prompt)
+from common import login
 
 if __name__ == "__main__":
 	parser = optparse.OptionParser()
@@ -37,10 +35,10 @@ 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)
-	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)
 	
 	final_candidates = []
 	now = datetime.datetime.now()
@@ -137,13 +135,16 @@ if __name__ == "__main__":
 			f.close()
 
 		# Do not risk trying to stabilize a package with known bugs.
-		bugs = bugzilla.search(cp, status=None)
-		if bugs:
+		params = {}
+		params['summary'] = [cp];
+		bugs = bugzilla.Bug.search(params)
+		if len(bugs['bugs']):
 			continue
 
 		# Protection against filing a stabilization bug twice.
-		bugs = bugzilla.search(best_candidate)
-		if bugs:
+		params['summary'] = [best_candidate]
+		bugs = bugzilla.Bug.search(params)
+		if len(bugs['bugs']):
 			continue
 
 		metadata = MetaDataXML(os.path.join(cvs_path, 'metadata.xml'), '/usr/portage/metadata/herds.xml')
@@ -165,17 +166,16 @@ if __name__ == "__main__":
 			description = ('Is it OK to stabilize =%s ?\n\n' % best_candidate +
 				       'If so, please CC arches and add STABLEREQ keyword.\n\n' +
 				       'Stabilization of this package has been repoman-checked on the following arches: %s' % ', '.join(options.arch))
-			bug_id = bugzilla.post('Gentoo Linux',
-					       'Keywording and Stabilization',
-					       'Please stabilize =%s' % best_candidate,
-					       description,
-					       url=url,
-					       assigned_to=maintainer,
-					       cc=other_maintainers,
-					       severity='enhancement')
-			if bug_id == 0:
-				print 'Submitting bug for %s failed. :-(' % best_candidate
-			else:
-				print 'Submitted bug #%d for %s. ;-)' % (bug_id, best_candidate)
+			params['product'] = 'Gentoo Linux'
+			params['version'] = 'unspecified'
+			params['component'] = 'Keywording and Stabilization'
+			params['summary'] = 'Please stabilize =%s' % best_candidate
+			params['description'] = description
+			params['url'] = url
+			params['assigned_to'] = maintainer
+			params['cc'] = other_maintainers
+			params['severity'] = 'enhancement'
+			bug_id = bugzilla.Bug.create(params)['id']
+			print 'Submitted bug #%d for %s. ;-)' % (bug_id, best_candidate)
 		else:
 			print (best_candidate, maintainer, other_maintainers)


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2012-10-08 16:03 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-10-08 16:03 UTC (permalink / raw
  To: gentoo-commits

commit:     535da2a53b24e20444b09f89a6055f89784cfce3
Author:     William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 19 13:58:09 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Thu Apr 19 13:58:09 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=535da2a5

The new python interface to bugzilla does not handle logging in and out
at the lower level; this is now part of the command line interface. As a
result, we need to prompt for a username and password and log in
ourselves.  This will be used in the updated arch testing tools.

---
 common.py |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/common.py b/common.py
index ad25ad8..16abf70 100644
--- a/common.py
+++ b/common.py
@@ -3,6 +3,7 @@
 
 import cStringIO
 import datetime
+import getpass
 import re
 
 import portage
@@ -42,6 +43,27 @@ def expand_braces(orig):
 	return list(set(res))
 
 
+def get_input(prompt):
+	return raw_input(prompt)
+
+
+def login(bugzilla):
+	"""Authenticate a session.
+	"""
+	# prompt for username
+	user = get_input('Bugzilla Username: ')
+
+	# prompt for password
+	password = getpass.getpass()
+
+	# perform login
+	params = {}
+	params['login'] = user
+	params['password'] = password
+	print 'Logging in'
+	bugzilla.User.login(params)
+
+
 class Bug:
 	def __init__(self, xml=None, id_number=None, summary=None, status=None):
 		if xml is not None:


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2012-10-08 16:03 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-10-08 16:03 UTC (permalink / raw
  To: gentoo-commits

commit:     f63c885b61c46482781e22fb6f117f110eada79d
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Wed Aug  1 07:15:43 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Wed Aug  1 07:15:43 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=f63c885b

Add default exclusion regex to the script

This makes it harder to forget exclusions people
asked for.

---
 stabilization-candidates.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index a5724ff..bf7825e 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -24,7 +24,7 @@ if __name__ == "__main__":
 	parser.add_option("--days", dest="days", type=int, default=30, help="Number of days in the tree after stabilization is possible.")
 	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
 	parser.add_option("--category", dest="category", help="Portage category filter (default is all categories)")
-	parser.add_option("--exclude", dest="exclude", help="Regular expression for excluded packages.")
+	parser.add_option("--exclude", dest="exclude", default=".*(kde|sci|lisp|perl-core|virtual|gnome|ruby).*", help="Regular expression for excluded packages.")
 	parser.add_option("--file-bugs", dest="file_bugs", action="store_true", default=False, help="File stabilization bugs for detected candidates. Otherwise (default) the candidates are just displayed.")
 
 	(options, args) = parser.parse_args()


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
  2012-06-04  9:18 [gentoo-commits] proj/arch-tools:new-pybugz " Paweł Hajdan
@ 2012-10-08 16:03 ` Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-10-08 16:03 UTC (permalink / raw
  To: gentoo-commits

commit:     b619bbaa42d55cb7eb424cecd9b3f0d4a8318917
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Mon Jun  4 09:17:52 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Mon Jun  4 09:17:52 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=b619bbaa

Improve stabilization-candidates (misc updates)

---
 stabilization-candidates.py |   52 ++++++++++++++++++++++++------------------
 1 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 7989a84..77a9a74 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -8,6 +8,7 @@ import os.path
 import random
 import re
 import subprocess
+import xmlrpclib
 import urllib
 
 from bugz.bugzilla import BugzillaProxy
@@ -91,16 +92,20 @@ if __name__ == "__main__":
 		best_candidate = candidates[0]
 
 		pv = portage.versions.catsplit(best_candidate)[1]
-		with open(os.path.join(options.repo, cp, 'ChangeLog')) as changelog_file:
-			regex = '\*%s \((.*)\)' % re.escape(pv)
-			match = re.search(regex, changelog_file.read())
-			if not match:
-				print 'error parsing ChangeLog'
-				continue
-			changelog_date = datetime.datetime.strptime(match.group(1), '%d %b %Y')
-			if now - changelog_date < datetime.timedelta(days=options.days):
-				print 'not old enough'
-				continue
+		try:
+			with open(os.path.join(options.repo, cp, 'ChangeLog')) as changelog_file:
+				regex = '\*%s \((.*)\)' % re.escape(pv)
+				match = re.search(regex, changelog_file.read())
+				if not match:
+					print 'error parsing ChangeLog'
+					continue
+				changelog_date = datetime.datetime.strptime(match.group(1), '%d %b %Y')
+				if now - changelog_date < datetime.timedelta(days=options.days):
+					print 'not old enough'
+					continue
+		except IOError, e:
+			print e
+			continue
 
 		keywords = portage.db["/"]["porttree"].dbapi.aux_get(best_candidate, ['KEYWORDS'])[0]
 		missing_arch = False
@@ -113,18 +118,15 @@ if __name__ == "__main__":
 			continue
 
 		# Do not risk trying to stabilize a package with known bugs.
-		params = {}
-		params['summary'] = [cp];
-		bugs = bugzilla.Bug.search(params)
-		if len(bugs['bugs']):
+		bugs = [x for x in bugzilla.Bug.search({'summary': cp})['bugs'] if x['is_open'] and x['severity'] not in ['enhancement', 'QA']]
+		if bugs:
 			print 'has bugs'
 			continue
 
 		# Protection against filing a stabilization bug twice.
-		params['summary'] = [best_candidate]
-		bugs = bugzilla.Bug.search(params)
-		if len(bugs['bugs']):
-			print 'version has closed bugs'
+		bugs = bugzilla.Bug.search({'summary': best_candidate})['bugs']
+		if bugs:
+			print 'version has bugs'
 			continue
 
 		cvs_path = os.path.join(options.repo, cp)
@@ -164,8 +166,10 @@ if __name__ == "__main__":
 
 		if options.file_bugs:
 			description = ('Is it OK to stabilize =%s ?\n\n' % best_candidate +
-				       'If so, please CC arches and add STABLEREQ keyword.\n\n' +
-				       'Stabilization of this package has been repoman-checked on the following arches: %s' % ', '.join(options.arch))
+				       'If so, please CC all arches which have stable keywords\n\n' +
+				       'for older versions of this package and add STABLEREQ keyword\n\n' +
+				       'to the bug.')
+			params = {}
 			params['product'] = 'Gentoo Linux'
 			params['version'] = 'unspecified'
 			params['component'] = 'Keywording and Stabilization'
@@ -175,7 +179,11 @@ if __name__ == "__main__":
 			params['assigned_to'] = maintainer
 			params['cc'] = other_maintainers
 			params['severity'] = 'enhancement'
-			bug_id = bugzilla.Bug.create(params)['id']
-			print 'Submitted bug #%d for %s. ;-)' % (bug_id, best_candidate)
+			try:
+				bug_id = bugzilla.Bug.create(params)['id']
+				print 'Submitted bug #%d for %s. ;-)' % (bug_id, best_candidate)
+			except xmlrpclib.Fault, f:
+				print f
+				print 'Failed to submit bug for %s. :-(' % best_candidate
 		else:
 			print (best_candidate, maintainer, other_maintainers)


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2012-10-08 16:03 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-10-08 16:03 UTC (permalink / raw
  To: gentoo-commits

commit:     64ebf043ef6bd7481b3701a6e69735ca618fd2f9
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Wed Aug  1 07:11:49 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Wed Aug  1 07:11:49 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=64ebf043

Fix an exception when best_version was not a string

---
 stabilization-candidates.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 77a9a74..a5724ff 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -89,7 +89,7 @@ if __name__ == "__main__":
 		# Only consider the best version for stabilization.
 		# It's usually better tested, and often maintainers refuse
 		# to stabilize anything else, e.g. bug #391607.
-		best_candidate = candidates[0]
+		best_candidate = str(candidates[0])
 
 		pv = portage.versions.catsplit(best_candidate)[1]
 		try:


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
  2012-08-01  7:28 [gentoo-commits] proj/arch-tools:new-pybugz " Paweł Hajdan
@ 2012-10-08 16:03 ` Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-10-08 16:03 UTC (permalink / raw
  To: gentoo-commits

commit:     5ff852b4a383456e6a9be6918f289eaa40cc0f64
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Wed Aug  1 07:28:10 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Wed Aug  1 07:28:10 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=5ff852b4

Also exclude x11 from stabilization candidates.

---
 stabilization-candidates.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index bf7825e..3268fdc 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -24,7 +24,7 @@ if __name__ == "__main__":
 	parser.add_option("--days", dest="days", type=int, default=30, help="Number of days in the tree after stabilization is possible.")
 	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
 	parser.add_option("--category", dest="category", help="Portage category filter (default is all categories)")
-	parser.add_option("--exclude", dest="exclude", default=".*(kde|sci|lisp|perl-core|virtual|gnome|ruby).*", help="Regular expression for excluded packages.")
+	parser.add_option("--exclude", dest="exclude", default=".*(kde|sci|lisp|perl-core|virtual|gnome|ruby|x11).*", help="Regular expression for excluded packages.")
 	parser.add_option("--file-bugs", dest="file_bugs", action="store_true", default=False, help="File stabilization bugs for detected candidates. Otherwise (default) the candidates are just displayed.")
 
 	(options, args) = parser.parse_args()


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
  2012-08-01 11:08 [gentoo-commits] proj/arch-tools:new-pybugz " Paweł Hajdan
@ 2012-10-08 16:03 ` Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-10-08 16:03 UTC (permalink / raw
  To: gentoo-commits

commit:     47a90a979384faa62dac5190aa2515b6e67c3150
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Wed Aug  1 11:07:53 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Wed Aug  1 11:07:53 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=47a90a97

Exclude mono/dotnet from stabilization candidates.

---
 stabilization-candidates.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 3268fdc..216e15f 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -24,7 +24,7 @@ if __name__ == "__main__":
 	parser.add_option("--days", dest="days", type=int, default=30, help="Number of days in the tree after stabilization is possible.")
 	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
 	parser.add_option("--category", dest="category", help="Portage category filter (default is all categories)")
-	parser.add_option("--exclude", dest="exclude", default=".*(kde|sci|lisp|perl-core|virtual|gnome|ruby|x11).*", help="Regular expression for excluded packages.")
+	parser.add_option("--exclude", dest="exclude", default=".*(kde|sci|lisp|perl-core|virtual|gnome|ruby|x11|mono|dotnet).*", help="Regular expression for excluded packages.")
 	parser.add_option("--file-bugs", dest="file_bugs", action="store_true", default=False, help="File stabilization bugs for detected candidates. Otherwise (default) the candidates are just displayed.")
 
 	(options, args) = parser.parse_args()


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2012-10-08 16:03 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-10-08 16:03 UTC (permalink / raw
  To: gentoo-commits

commit:     44f09a691a30d55a2b6dd98e17cfbd25817690cc
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Wed May  9 17:22:53 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Wed May  9 17:22:53 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=44f09a69

Process stabilization candidates incrementally,

instead of a one big batch at the end.

This helps to file at least some bugs if the script
crashes in the middle.

---
 stabilization-candidates.py |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 3b2b72e..04b6dee 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -154,10 +154,6 @@ if __name__ == "__main__":
 		else:
 			other_maintainers = []
 		url = 'http://packages.gentoo.org/package/%s?arches=linux' % urllib.quote(cp)
-		final_candidates.append((best_candidate, url, maintainer, other_maintainers))
-
-	for x in final_candidates:
-		best_candidate, url, maintainer, other_maintainers = x
 
 		if options.file_bugs:
 			description = ('Is it OK to stabilize =%s ?\n\n' % best_candidate +


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
  2012-10-08 16:02 [gentoo-commits] proj/arch-tools:new-pybugz " Paweł Hajdan
@ 2012-10-08 16:03 ` Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-10-08 16:03 UTC (permalink / raw
  To: gentoo-commits

commit:     08d0025e085923f23e02e4f6009a651d7d7619b7
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Mon Oct  8 16:01:18 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Mon Oct  8 16:01:18 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=08d0025e

More robust commit logic:

- do not overwrite own changes when stabilizing multiple versions of the
  same package
- ignore unrelated failures on other arches

---
 batch-stabilize.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/batch-stabilize.py b/batch-stabilize.py
index bede303..c7b676f 100755
--- a/batch-stabilize.py
+++ b/batch-stabilize.py
@@ -138,6 +138,9 @@ if __name__ == "__main__":
 					if run_command(["cvs", "up", pn], options.repo, log_file)[0] != 0:
 						print '!!! cvs up failed'
 						sys.exit(1)
+				for (pn, ebuild_name) in stabilization_dict[bug_id]:
+					cvs_path = os.path.join(options.repo, pn)
+					print_and_log('Working in %s...' % cvs_path, log_file)
 					if run_command(["ekeyword", options.arch, ebuild_name], cvs_path, log_file)[0] != 0:
 						print '!!! ekeyword failed'
 						sys.exit(1)
@@ -159,7 +162,7 @@ if __name__ == "__main__":
 					if run_command(["repoman", "manifest"], cvs_path, log_file)[0] != 0:
 						print '!!! repoman manifest failed'
 						sys.exit(1)
-					if run_command(["repoman", "commit", "-m", commit_message], cvs_path, log_file)[0] != 0:
+					if run_command(["repoman", "commit", "--ignore-arches", "-m", commit_message], cvs_path, log_file)[0] != 0:
 						print '!!! repoman commit failed'
 						sys.exit(1)
 				params = {}


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2012-10-16 16:54 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-10-16 16:54 UTC (permalink / raw
  To: gentoo-commits

commit:     9e5f324f7083e932580962d79f3d8c74b675339b
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 16 16:53:56 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Tue Oct 16 16:53:56 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=9e5f324f

Exclude games, requested by mr_bones_.

---
 stabilization-candidates.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 55c5314..4ee25d5 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -24,7 +24,7 @@ if __name__ == "__main__":
 	parser.add_option("--days", dest="days", type=int, default=30, help="Number of days in the tree after stabilization is possible.")
 	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
 	parser.add_option("--category", dest="category", help="Portage category filter (default is all categories)")
-	parser.add_option("--exclude", dest="exclude", default=".*(kde-base|sci|lisp|perl-core|virtual|gnome|ruby|x11|mono|dotnet).*", help="Regular expression for excluded packages.")
+	parser.add_option("--exclude", dest="exclude", default=".*(kde-base|sci|lisp|perl-core|virtual|gnome|ruby|x11|mono|dotnet|games).*", help="Regular expression for excluded packages.")
 	parser.add_option("--file-bugs", dest="file_bugs", action="store_true", default=False, help="File stabilization bugs for detected candidates. Otherwise (default) the candidates are just displayed.")
 
 	(options, args) = parser.parse_args()


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2012-10-16 16:54 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2012-10-16 16:54 UTC (permalink / raw
  To: gentoo-commits

commit:     ee16a77fa55b1ddd2c3b2397e428f06950e1c525
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 16 16:52:43 2012 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Tue Oct 16 16:52:43 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=ee16a77f

Only exclude kde-base, requested by kensington.

---
 stabilization-candidates.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 216e15f..55c5314 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -24,7 +24,7 @@ if __name__ == "__main__":
 	parser.add_option("--days", dest="days", type=int, default=30, help="Number of days in the tree after stabilization is possible.")
 	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
 	parser.add_option("--category", dest="category", help="Portage category filter (default is all categories)")
-	parser.add_option("--exclude", dest="exclude", default=".*(kde|sci|lisp|perl-core|virtual|gnome|ruby|x11|mono|dotnet).*", help="Regular expression for excluded packages.")
+	parser.add_option("--exclude", dest="exclude", default=".*(kde-base|sci|lisp|perl-core|virtual|gnome|ruby|x11|mono|dotnet).*", help="Regular expression for excluded packages.")
 	parser.add_option("--file-bugs", dest="file_bugs", action="store_true", default=False, help="File stabilization bugs for detected candidates. Otherwise (default) the candidates are just displayed.")
 
 	(options, args) = parser.parse_args()


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2013-02-28  4:50 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2013-02-28  4:50 UTC (permalink / raw
  To: gentoo-commits

commit:     c6330c864965ef81f5fe95f2c9d3ef07de66f4ff
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 28 04:49:16 2013 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Thu Feb 28 04:49:16 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=c6330c86

Add xfce to list of stabilization bugs excludes.

---
 stabilization-candidates.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 4ee25d5..20dae63 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -24,8 +24,8 @@ if __name__ == "__main__":
 	parser.add_option("--days", dest="days", type=int, default=30, help="Number of days in the tree after stabilization is possible.")
 	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
 	parser.add_option("--category", dest="category", help="Portage category filter (default is all categories)")
-	parser.add_option("--exclude", dest="exclude", default=".*(kde-base|sci|lisp|perl-core|virtual|gnome|ruby|x11|mono|dotnet|games).*", help="Regular expression for excluded packages.")
 	parser.add_option("--file-bugs", dest="file_bugs", action="store_true", default=False, help="File stabilization bugs for detected candidates. Otherwise (default) the candidates are just displayed.")
+	parser.add_option("--exclude", dest="exclude", default=".*(kde-base|sci|lisp|perl-core|virtual|gnome|ruby|x11|mono|dotnet|games|xfce).*", help="Regular expression for excluded packages.")
 
 	(options, args) = parser.parse_args()
 	if not options.arch:


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2013-02-28  4:50 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2013-02-28  4:50 UTC (permalink / raw
  To: gentoo-commits

commit:     3c20e14c939bf0efa495dead6243f8035d699b86
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 28 04:50:06 2013 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Thu Feb 28 04:50:06 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=3c20e14c

Stabilization candidates: split out the bug filing script.

---
 file-stabilization-bugs.py  |  103 +++++++++++++++++++++++++++++++++++++++++++
 stabilization-candidates.py |   66 +++++++++++++---------------
 2 files changed, 134 insertions(+), 35 deletions(-)

diff --git a/file-stabilization-bugs.py b/file-stabilization-bugs.py
new file mode 100755
index 0000000..4963937
--- /dev/null
+++ b/file-stabilization-bugs.py
@@ -0,0 +1,103 @@
+#!/usr/bin/env python
+# Copyright 2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import glob
+import itertools
+import optparse
+import os
+import pickle
+import re
+import shutil
+import subprocess
+import sys
+import urllib
+import xmlrpclib
+
+from bugz.bugzilla import BugzillaProxy
+from common import login
+import portage.versions
+from portage.xml.metadata import MetaDataXML
+
+def save_state(done_cpvs):
+	with open('file-stabilization-bugs.state', 'w') as state_file:
+		pickle.dump(done_cpvs, state_file)
+
+if __name__ == "__main__":
+	exit_code = 0
+
+	parser = optparse.OptionParser()
+	parser.add_option("-i", "--input", dest="input_filename", default="stabilization-candidates.txt", help="Input filename [default=%default]")
+	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
+
+	(options, args) = parser.parse_args()
+	if not options.input_filename:
+		parser.error("--input option is required")
+	if not options.repo:
+		parser.error("--repo option is required")
+	if args:
+		parser.error("unrecognized command-line args")
+
+	done_cpvs = []
+	if os.path.exists('file-stabilization-bugs.state'):
+		with open('file-stabilization-bugs.state', 'r') as state_file:
+			done_cpvs = pickle.load(state_file)
+
+	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:
+		for line in input_file:
+			line = line.strip()
+
+			# Skip empty/whitespace/comment lines.
+			if not line or line.startswith("#"):
+				continue
+
+			cpv = line
+			if cpv in done_cpvs:
+				print 'Skipping %s because it\'s marked as done' % cpv
+				continue
+
+			cp = portage.versions.pkgsplit(cpv)[0]
+
+			cvs_path = os.path.join(options.repo, cp)
+			metadata = MetaDataXML(os.path.join(cvs_path, 'metadata.xml'), '/usr/portage/metadata/herds.xml')
+			maintainer_split = metadata.format_maintainer_string().split(' ', 1)
+			maintainer = maintainer_split[0]
+			if len(maintainer_split) > 1:
+				other_maintainers = maintainer_split[1].split(',')
+			else:
+				other_maintainers = []
+
+			description = ('Is it OK to stabilize =%s ?\n\n' % cpv +
+				       'If so, please CC all arches which have stable keywords\n\n' +
+				       'for older versions of this package and add STABLEREQ keyword\n\n' +
+				       'to the bug.')
+			url = 'http://packages.gentoo.org/package/%s?arches=linux' % urllib.quote(cp)
+			params = {}
+			params['product'] = 'Gentoo Linux'
+			params['version'] = 'unspecified'
+			params['component'] = 'Keywording and Stabilization'
+			params['summary'] = 'Please stabilize =%s' % cpv
+			params['description'] = description
+			params['url'] = url
+			params['assigned_to'] = maintainer
+			params['cc'] = other_maintainers
+			params['severity'] = 'enhancement'
+			try:
+				bug_id = bugzilla.Bug.create(params)['id']
+				print 'Submitted bug #%d for %s. ;-)' % (bug_id, cpv)
+				done_cpvs += cpv
+				save_state(done_cpvs)
+			except xmlrpclib.Fault, f:
+				exit_code = 1
+				print f
+				print 'Failed to submit bug for %s. :-(' % cpv
+	
+	if exit_code == 0 and os.path.exists('file-stabilization-bugs.state'):
+		os.remove('file-stabilization-bugs.state')
+	
+	sys.exit(exit_code)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 20dae63..615e3b6 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -24,8 +24,8 @@ if __name__ == "__main__":
 	parser.add_option("--days", dest="days", type=int, default=30, help="Number of days in the tree after stabilization is possible.")
 	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
 	parser.add_option("--category", dest="category", help="Portage category filter (default is all categories)")
-	parser.add_option("--file-bugs", dest="file_bugs", action="store_true", default=False, help="File stabilization bugs for detected candidates. Otherwise (default) the candidates are just displayed.")
 	parser.add_option("--exclude", dest="exclude", default=".*(kde-base|sci|lisp|perl-core|virtual|gnome|ruby|x11|mono|dotnet|games|xfce).*", help="Regular expression for excluded packages.")
+	parser.add_option("-o", "--output", dest="output_filename", default="stabilization-candidates.txt", help="Output filename for generated stabilization candidates list.")
 
 	(options, args) = parser.parse_args()
 	if not options.arch:
@@ -46,8 +46,33 @@ if __name__ == "__main__":
 		if options.category and not cp.startswith(options.category + "/"):
 			continue
 
-		if options.exclude and re.match(options.exclude, cp):
+		cvs_path = os.path.join(options.repo, cp)
+		try:
+			metadata = MetaDataXML(os.path.join(cvs_path, 'metadata.xml'), '/usr/portage/metadata/herds.xml')
+		except IOError:
 			continue
+		maintainer_split = metadata.format_maintainer_string().split(' ', 1)
+		maintainer = maintainer_split[0]
+		if len(maintainer_split) > 1:
+			other_maintainers = maintainer_split[1].split(',')
+		else:
+			other_maintainers = []
+
+		if options.exclude:
+			if re.match(options.exclude, cp):
+				continue
+
+			if re.match(options.exclude, maintainer):
+				continue
+
+			skip = False
+			for m in other_maintainers:
+				if re.match(options.exclude, m):
+					skip = True
+					break
+			if skip:
+				continue
+
 
 		best_stable = portage.versions.best(portage.portdb.match(cp))
 		if not best_stable:
@@ -129,7 +154,6 @@ if __name__ == "__main__":
 			print 'version has bugs'
 			continue
 
-		cvs_path = os.path.join(options.repo, cp)
 		ebuild_name = portage.versions.catsplit(best_candidate)[1] + ".ebuild"
 		ebuild_path = os.path.join(cvs_path, ebuild_name)
 		manifest_path = os.path.join(cvs_path, 'Manifest')
@@ -155,35 +179,7 @@ if __name__ == "__main__":
 			f.write(manifest_contents)
 			f.close()
 
-		metadata = MetaDataXML(os.path.join(cvs_path, 'metadata.xml'), '/usr/portage/metadata/herds.xml')
-		maintainer_split = metadata.format_maintainer_string().split(' ', 1)
-		maintainer = maintainer_split[0]
-		if len(maintainer_split) > 1:
-			other_maintainers = maintainer_split[1].split(',')
-		else:
-			other_maintainers = []
-		url = 'http://packages.gentoo.org/package/%s?arches=linux' % urllib.quote(cp)
-
-		if options.file_bugs:
-			description = ('Is it OK to stabilize =%s ?\n\n' % best_candidate +
-				       'If so, please CC all arches which have stable keywords\n\n' +
-				       'for older versions of this package and add STABLEREQ keyword\n\n' +
-				       'to the bug.')
-			params = {}
-			params['product'] = 'Gentoo Linux'
-			params['version'] = 'unspecified'
-			params['component'] = 'Keywording and Stabilization'
-			params['summary'] = 'Please stabilize =%s' % best_candidate
-			params['description'] = description
-			params['url'] = url
-			params['assigned_to'] = maintainer
-			params['cc'] = other_maintainers
-			params['severity'] = 'enhancement'
-			try:
-				bug_id = bugzilla.Bug.create(params)['id']
-				print 'Submitted bug #%d for %s. ;-)' % (bug_id, best_candidate)
-			except xmlrpclib.Fault, f:
-				print f
-				print 'Failed to submit bug for %s. :-(' % best_candidate
-		else:
-			print (best_candidate, maintainer, other_maintainers)
+		with open(options.output_filename, 'a') as f:
+			f.write('# %s %s\n' % (maintainer, ', '.join(other_maintainers)))
+			f.write('%s\n' % best_candidate)
+		print (best_candidate, maintainer, other_maintainers)


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2013-03-11 21:56 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2013-03-11 21:56 UTC (permalink / raw
  To: gentoo-commits

commit:     51d52ff2515084afe5513c3d26ee5cf0cc683f8f
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Sat Mar  9 22:09:32 2013 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Sat Mar  9 22:09:32 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=51d52ff2

Exclude leechcraft from stabilization-candidates.py

---
 stabilization-candidates.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 615e3b6..d59c8d2 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -24,7 +24,7 @@ if __name__ == "__main__":
 	parser.add_option("--days", dest="days", type=int, default=30, help="Number of days in the tree after stabilization is possible.")
 	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
 	parser.add_option("--category", dest="category", help="Portage category filter (default is all categories)")
-	parser.add_option("--exclude", dest="exclude", default=".*(kde-base|sci|lisp|perl-core|virtual|gnome|ruby|x11|mono|dotnet|games|xfce).*", help="Regular expression for excluded packages.")
+	parser.add_option("--exclude", dest="exclude", default=".*(kde-base|sci|lisp|perl-core|virtual|gnome|ruby|x11|mono|dotnet|games|xfce|leechcraft).*", help="Regular expression for excluded packages.")
 	parser.add_option("-o", "--output", dest="output_filename", default="stabilization-candidates.txt", help="Output filename for generated stabilization candidates list.")
 
 	(options, args) = parser.parse_args()


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2013-05-19 23:35 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2013-05-19 23:35 UTC (permalink / raw
  To: gentoo-commits

commit:     3d2d92a6537bec6be9c39ac113eb88f85faca315
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Sun May 19 23:34:11 2013 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Sun May 19 23:34:11 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=3d2d92a6

Do not put empty lines in the stabilization bug

Reported on gentoo-dev by Jeroen Roovers.

---
 file-stabilization-bugs.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/file-stabilization-bugs.py b/file-stabilization-bugs.py
index 4963937..6f1bb64 100755
--- a/file-stabilization-bugs.py
+++ b/file-stabilization-bugs.py
@@ -72,9 +72,9 @@ if __name__ == "__main__":
 			else:
 				other_maintainers = []
 
-			description = ('Is it OK to stabilize =%s ?\n\n' % cpv +
-				       'If so, please CC all arches which have stable keywords\n\n' +
-				       'for older versions of this package and add STABLEREQ keyword\n\n' +
+			description = ('Is it OK to stabilize =%s ?\n' % cpv +
+				       'If so, please CC all arches which have stable keywords\n' +
+				       'for older versions of this package and add STABLEREQ keyword\n' +
 				       'to the bug.')
 			url = 'http://packages.gentoo.org/package/%s?arches=linux' % urllib.quote(cp)
 			params = {}


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2013-06-22 14:57 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2013-06-22 14:57 UTC (permalink / raw
  To: gentoo-commits

commit:     a92c88330af1aec3aa9ee58dc497f047129ccd2e
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 21 12:23:48 2013 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Fri Jun 21 12:23:48 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=a92c8833

Apply feedback from gentoo-dev:

- put package name and version first in the summary
  (for better sorting of bugs by summary)

- add STABLEREQ keyword at the time of filing the bug
  (this needs to be done after creating the bug, limitation
   of the Bugzilla API)

---
 file-stabilization-bugs.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/file-stabilization-bugs.py b/file-stabilization-bugs.py
index 6f1bb64..40bf784 100755
--- a/file-stabilization-bugs.py
+++ b/file-stabilization-bugs.py
@@ -74,14 +74,13 @@ if __name__ == "__main__":
 
 			description = ('Is it OK to stabilize =%s ?\n' % cpv +
 				       'If so, please CC all arches which have stable keywords\n' +
-				       'for older versions of this package and add STABLEREQ keyword\n' +
-				       'to the bug.')
+				       'for older versions of this package.')
 			url = 'http://packages.gentoo.org/package/%s?arches=linux' % urllib.quote(cp)
 			params = {}
 			params['product'] = 'Gentoo Linux'
 			params['version'] = 'unspecified'
 			params['component'] = 'Keywording and Stabilization'
-			params['summary'] = 'Please stabilize =%s' % cpv
+			params['summary'] = '%s: stabilization request' % cpv
 			params['description'] = description
 			params['url'] = url
 			params['assigned_to'] = maintainer
@@ -92,6 +91,15 @@ if __name__ == "__main__":
 				print 'Submitted bug #%d for %s. ;-)' % (bug_id, cpv)
 				done_cpvs += cpv
 				save_state(done_cpvs)
+				try:
+					params = {}
+					params['ids'] = [bug_id]
+					params['keywords'] = {'set': 'STABLEREQ'}
+					bugzilla.Bug.update(params)
+				except xmlrpclib.Fault, f:
+					exit_code = 1
+					print f
+					print 'Failed to add STABLEREQ keyword for %s. :-/' % cpv
 			except xmlrpclib.Fault, f:
 				exit_code = 1
 				print f


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2013-06-22 15:05 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2013-06-22 15:05 UTC (permalink / raw
  To: gentoo-commits

commit:     f2329213c9f95b809a704608eaa0270f60c97bba
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 21 12:32:11 2013 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Fri Jun 21 12:32:11 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=f2329213

Use python2 as interpreter

Fixes Gentoo bug #429320 by Pacho Ramos.

---
 batch-stabilize.py          | 2 +-
 bugzilla-viewer.py          | 2 +-
 file-stabilization-bugs.py  | 2 +-
 maintainer-timeout.py       | 2 +-
 reverse-dependencies.py     | 2 +-
 stabilization-candidates.py | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/batch-stabilize.py b/batch-stabilize.py
index c7b676f..2093da5 100755
--- a/batch-stabilize.py
+++ b/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
 

diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py
index 76daabf..05c5dea 100755
--- a/bugzilla-viewer.py
+++ b/bugzilla-viewer.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
 

diff --git a/file-stabilization-bugs.py b/file-stabilization-bugs.py
index 40bf784..1c5bbe9 100755
--- a/file-stabilization-bugs.py
+++ b/file-stabilization-bugs.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 # Copyright 2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 

diff --git a/maintainer-timeout.py b/maintainer-timeout.py
index 6287bec..ad5593f 100755
--- a/maintainer-timeout.py
+++ b/maintainer-timeout.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 # Copyright 2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 

diff --git a/reverse-dependencies.py b/reverse-dependencies.py
index 4f87139..96233ea 100755
--- a/reverse-dependencies.py
+++ b/reverse-dependencies.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
 

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index d59c8d2..8798518 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.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
 


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2014-02-12  7:06 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2014-02-12  7:06 UTC (permalink / raw
  To: gentoo-commits

commit:     709e4466eb1a8d3c19d522bb2539a821b133bd76
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 18:21:45 2014 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Tue Feb 11 18:21:45 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=709e4466

Fix maintainer-tiemout.py

- adjust search strings for new bug template
- port to new pybugz

---
 common.py             | 17 ++++++++++----
 maintainer-timeout.py | 65 ++++++++++++++++++++++++++++-----------------------
 2 files changed, 48 insertions(+), 34 deletions(-)

diff --git a/common.py b/common.py
index 16abf70..cf89eb7 100644
--- a/common.py
+++ b/common.py
@@ -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)))


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2014-04-07 12:40 Samuli Suominen
  0 siblings, 0 replies; 59+ messages in thread
From: Samuli Suominen @ 2014-04-07 12:40 UTC (permalink / raw
  To: gentoo-commits

commit:     adb66a9d3f80f8f660d362ca5c8363cf85102a0d
Author:     Samuli Suominen <ssuominen <AT> gentoo <DOT> org>
AuthorDate: Mon Apr  7 12:34:37 2014 +0000
Commit:     Samuli Suominen <ssuominen <AT> gentoo <DOT> org>
CommitDate: Mon Apr  7 12:34:37 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=adb66a9d

List packages that have xfce in metadata.xml for skipping. List girara and zathura for skipping, see bug 502714 and gentoo-dev ML for discussions

---
 stabilization-candidates.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 8798518..52c88f1 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -24,7 +24,7 @@ if __name__ == "__main__":
 	parser.add_option("--days", dest="days", type=int, default=30, help="Number of days in the tree after stabilization is possible.")
 	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
 	parser.add_option("--category", dest="category", help="Portage category filter (default is all categories)")
-	parser.add_option("--exclude", dest="exclude", default=".*(kde-base|sci|lisp|perl-core|virtual|gnome|ruby|x11|mono|dotnet|games|xfce|leechcraft).*", help="Regular expression for excluded packages.")
+	parser.add_option("--exclude", dest="exclude", default=".*(kde-base|sci|lisp|perl-core|virtual|gnome|ruby|x11|mono|dotnet|games|xfce|xfburn|mousepad|orage|xfbib|thunar|ristretto|pragha|xfmpc|parole|midori|gigolo|rodent|xfwm|girara|zathura|leechcraft).*", help="Regular expression for excluded packages.")
 	parser.add_option("-o", "--output", dest="output_filename", default="stabilization-candidates.txt", help="Output filename for generated stabilization candidates list.")
 
 	(options, args) = parser.parse_args()


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2014-06-14  9:47 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2014-06-14  9:47 UTC (permalink / raw
  To: gentoo-commits

commit:     85a5fa0e24d89b5b8a41cc63f4c59e2e46faa4a6
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 14 09:41:35 2014 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Sat Jun 14 09:41:35 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=85a5fa0e

Fix issue in batch-stabilize leading to errors from Bugzilla

xmlrpclib.Fault: <Fault 410: 'You must log in before using this part of
Bugzilla.'>

---
 batch-stabilize.py    | 3 ++-
 common.py             | 5 +----
 maintainer-timeout.py | 2 +-
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/batch-stabilize.py b/batch-stabilize.py
index 2093da5..053cd19 100755
--- a/batch-stabilize.py
+++ b/batch-stabilize.py
@@ -68,7 +68,7 @@ if __name__ == "__main__":
 	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)
+	user, login_data = login(bugzilla)
 	
 	with open(options.input_filename, "r") as input_file:
 		stabilization_dict = {}
@@ -188,6 +188,7 @@ if __name__ == "__main__":
 				# 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.
 				params = {}
+				params['token'] = login_data['token']
 				params['ids'] = [bug_id]
 				params['cc'] = {}
 				params['cc']['remove'] = ['%s@gentoo.org' % options.arch]

diff --git a/common.py b/common.py
index cf89eb7..578b0e0 100644
--- a/common.py
+++ b/common.py
@@ -69,10 +69,7 @@ def login(bugzilla):
 	params = {}
 	params['login'] = user
 	params['password'] = password
-	print 'Logging in'
-	bugzilla.User.login(params)
-
-	return user
+	return user, bugzilla.User.login(params)
 
 
 class Bug:

diff --git a/maintainer-timeout.py b/maintainer-timeout.py
index ba8c322..76c7e59 100755
--- a/maintainer-timeout.py
+++ b/maintainer-timeout.py
@@ -29,7 +29,7 @@ if __name__ == "__main__":
 	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)
+	user, login_data = login(bugzilla)
 	
 	bugs = bugzilla.Bug.search({'reporter': user, 'summary': ['stabilize', 'stabilization', 'stable'], 'resolution': ''})['bugs']
 	comments = bugzilla.Bug.comments({'ids': [bug['id'] for bug in bugs]})


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2015-01-05 14:41 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2015-01-05 14:41 UTC (permalink / raw
  To: gentoo-commits

commit:     e484b1da3bd10769d331ab4e914fa45c5660e726
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Dec 30 16:46:24 2014 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Mon Dec 29 14:58:15 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=e484b1da

batch-stabilize: use include-arches option

---
 batch-stabilize.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/batch-stabilize.py b/batch-stabilize.py
index 81f97ba..14cd69d 100755
--- a/batch-stabilize.py
+++ b/batch-stabilize.py
@@ -166,7 +166,8 @@ if __name__ == "__main__":
 					if run_command(["repoman", "manifest"], cvs_path, log_file)[0] != 0:
 						print('!!! repoman manifest failed')
 						sys.exit(1)
-					if run_command(["repoman", "commit", "--ignore-arches", "-m", commit_message], cvs_path, log_file)[0] != 0:
+					if run_command(["repoman", "commit",
+						"--include-arches", options.arch, "-m", commit_message], cvs_path, log_file)[0] != 0:
 						print('!!! repoman commit failed')
 						sys.exit(1)
 				params = {}


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2015-01-05 14:41 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2015-01-05 14:41 UTC (permalink / raw
  To: gentoo-commits

commit:     40f058957e72e82f4e54d2f453c02e51c62f37c5
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Dec 23 16:29:12 2014 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Mon Dec 29 14:57:12 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=40f05895

Fix subprocess handling in batch-stabilize

---
 batch-stabilize.py | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/batch-stabilize.py b/batch-stabilize.py
index 155af38..81f97ba 100755
--- a/batch-stabilize.py
+++ b/batch-stabilize.py
@@ -26,19 +26,23 @@ def print_and_log(message, log):
 		log.flush()
 
 def run_command(args, cwd, log):
-	try:
-		message = "Running %r in %s...\n" % (args, cwd)
-		sys.stdout.write(message)
-		log.write(message)
+	message = "Running %r in %s...\n" % (args, cwd)
+	returncode = 0
+	sys.stdout.write(message)
+	log.write(message)
 
-		cmd  = subprocess.Popen(args, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-		output = cmd.communicate()[0]
-		log.write("Finished with exit code %d\n" % cmd.returncode)
-		log.write(output)
-		return (cmd.returncode, output)
+	try:
+		output = subprocess.check_output(args, cwd=cwd,
+				stderr=subprocess.STDOUT, universal_newlines=True)
+	except subprocess.CalledProcessError as e:
+		output = e.output
+		returncode = e.returncode
 	finally:
+		log.write("Finished with exit code %d\n" % returncode)
+		log.write(output)
 		log.flush()
 
+	return (returncode, output)
 def save_state(done_bugs):
 	with open('batch-stabilize.state', 'wb') as state_file:
 		pickle.dump(done_bugs, state_file)


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2015-01-05 14:41 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2015-01-05 14:41 UTC (permalink / raw
  To: gentoo-commits

commit:     842f3d251d81ffc274fa01a1d9ba9b5794a2d714
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Dec 13 19:33:09 2014 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Mon Dec 29 14:52:27 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=842f3d25

Port most tools to python 3

This commit ports the following tools to python 3.

- common code
- batch-stabilize
- file-stabilization-bugs
- maintainer-timeout
- reverse-dependencies
- stabilization-candidates

This is a list of the changes:

- Remove the dependency on pybugz; these tools now use xmlrpc.client
  directly. This is needed because the next release of pybugz does the
  same thing; we no longer have a bugzilla module since it was just a
  wrapper.

Handle tokens correctly:

- When we log into Bugzilla, we are given a
  token we must pass back to it with every command we issue.

- Log out at the end of every session to expire the token.

Fix the state file processing:

- The pickle module handles binary files, not text files, so read and
  write the state file in binary mode.

- Add fix_imports=True when reading the state file so a python-2
  compatible state file can be read.

- Do not set the URL for a stabilization request

X-Gentoo-Bug: 532054
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=532054
X-Gentoo-Bug: 532368
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=532368

---
 batch-stabilize.py          | 43 ++++++++++++++++++++----------------
 common.py                   |  4 ++--
 file-stabilization-bugs.py  | 42 ++++++++++++++++++-----------------
 maintainer-timeout.py       | 31 ++++++++++++++++++--------
 reverse-dependencies.py     |  6 ++---
 stabilization-candidates.py | 54 ++++++++++++++++++++++++++-------------------
 6 files changed, 104 insertions(+), 76 deletions(-)

diff --git a/batch-stabilize.py b/batch-stabilize.py
index 053cd19..155af38 100755
--- a/batch-stabilize.py
+++ b/batch-stabilize.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
 # Copyright 2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
@@ -11,8 +11,8 @@ import re
 import shutil
 import subprocess
 import sys
+import xmlrpc.client
 
-from bugz.bugzilla import BugzillaProxy
 from common import login
 import portage.versions
 
@@ -20,7 +20,7 @@ BUG_REGEX = re.compile("[Bb]ug #?(\d+)")
 
 def print_and_log(message, log):
 	try:
-		print message
+		print(message)
 		log.write(message + '\n')
 	finally:
 		log.flush()
@@ -40,7 +40,7 @@ def run_command(args, cwd, log):
 		log.flush()
 
 def save_state(done_bugs):
-	with open('batch-stabilize.state', 'w') as state_file:
+	with open('batch-stabilize.state', 'wb') as state_file:
 		pickle.dump(done_bugs, state_file)
 
 if __name__ == "__main__":
@@ -62,12 +62,12 @@ if __name__ == "__main__":
 
 	done_bugs = []
 	if os.path.exists('batch-stabilize.state'):
-		with open('batch-stabilize.state', 'r') as state_file:
-			done_bugs = pickle.load(state_file)
+		with open('batch-stabilize.state', 'rb') as state_file:
+			done_bugs = pickle.load(state_file, fix_imports=True)
 
 	url = 'https://bugs.gentoo.org/xmlrpc.cgi'
-	print 'You will be prompted for your Gentoo Bugzilla username and password (%s).' % url
-	bugzilla = BugzillaProxy(url)
+	print('You will be prompted for your Gentoo Bugzilla username and password (%s).' % url)
+	bugzilla = xmlrpc.client.ServerProxy(url)
 	user, login_data = login(bugzilla)
 	
 	with open(options.input_filename, "r") as input_file:
@@ -83,14 +83,14 @@ if __name__ == "__main__":
 			if line.startswith("#"):
 				match = BUG_REGEX.search(line, re.IGNORECASE)
 				if not match:
-					print 'Ignoring comment line [%s]...' % line
+					print('Ignoring comment line [%s]...' % line)
 					continue
 				else:
 					bug_id = int(match.group(1))
 				continue
 
 			if bug_id == -1:
-				print 'Could not recognize bug id'
+				print('Could not recognize bug id')
 				sys.exit(1)
 
 			# Drop the leading '='.
@@ -109,10 +109,10 @@ if __name__ == "__main__":
 			for (pn, ebuild_name) in stabilization_dict[bug_id]:
 				ebuild_path = os.path.join(options.repo, pn, ebuild_name)
 				if not os.path.exists(ebuild_path):
-					print '%s: file does not exist' % ebuild_path
+					print('%s: file does not exist' % ebuild_path)
 					success = False
 		if not success:
-			print 'Sanity check failed. Please make sure your CVS repo is up to date (cvs up).'
+			print('Sanity check failed. Please make sure your CVS repo is up to date (cvs up).')
 			sys.exit(1)
 
 		with open('batch-stabilize.log', 'a') as log_file:
@@ -132,20 +132,20 @@ if __name__ == "__main__":
 						try:
 							shutil.rmtree(cvs_path)
 						except OSError:
-							print '!!! rmtree %s failed' % cvs_path
+							print('!!! rmtree %s failed' % cvs_path)
 							sys.exit(1)
 
 					if run_command(["cvs", "up", pn], options.repo, log_file)[0] != 0:
-						print '!!! cvs up failed'
+						print('!!! cvs up failed')
 						sys.exit(1)
 				for (pn, ebuild_name) in stabilization_dict[bug_id]:
 					cvs_path = os.path.join(options.repo, pn)
 					print_and_log('Working in %s...' % cvs_path, log_file)
 					if run_command(["ekeyword", options.arch, ebuild_name], cvs_path, log_file)[0] != 0:
-						print '!!! ekeyword failed'
+						print('!!! ekeyword failed')
 						sys.exit(1)
 					if run_command(["repoman", "manifest"], cvs_path, log_file)[0] != 0:
-						print '!!! repoman manifest failed'
+						print('!!! repoman manifest failed')
 						sys.exit(1)
 				for (pn, ebuild_name) in stabilization_dict[bug_id]:
 					cvs_path = os.path.join(options.repo, pn)
@@ -160,12 +160,13 @@ if __name__ == "__main__":
 					if run_command(["echangelog", commit_message], cvs_path, log_file)[0] != 0:
 						print_and_log('echangelog failed, maybe just the Manifest is being updated; continuing', log_file)
 					if run_command(["repoman", "manifest"], cvs_path, log_file)[0] != 0:
-						print '!!! repoman manifest failed'
+						print('!!! repoman manifest failed')
 						sys.exit(1)
 					if run_command(["repoman", "commit", "--ignore-arches", "-m", commit_message], cvs_path, log_file)[0] != 0:
-						print '!!! repoman commit failed'
+						print('!!! repoman commit failed')
 						sys.exit(1)
 				params = {}
+				params['Bugzilla_token'] = login_data['token']
 				params['ids'] = [bug_id]
 				bug_xml = bugzilla.Bug.get(params)['bugs'][0]
 				has_my_arch = False
@@ -188,7 +189,7 @@ if __name__ == "__main__":
 				# 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.
 				params = {}
-				params['token'] = login_data['token']
+				params['Bugzilla_token'] = login_data['token']
 				params['ids'] = [bug_id]
 				params['cc'] = {}
 				params['cc']['remove'] = ['%s@gentoo.org' % options.arch]
@@ -209,3 +210,7 @@ if __name__ == "__main__":
 	
 	if os.path.exists('batch-stabilize.state'):
 		os.remove('batch-stabilize.state')
+
+		params = {}
+		params['Bugzilla_token'] = login_data['token']
+		bugzilla.User.logout(params)

diff --git a/common.py b/common.py
index 578b0e0..89e4996 100644
--- a/common.py
+++ b/common.py
@@ -1,7 +1,7 @@
 # Copyright 2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-import cStringIO
+import io
 import datetime
 import getpass
 import re
@@ -53,7 +53,7 @@ def detect_cpvs(text):
 
 
 def get_input(prompt):
-	return raw_input(prompt)
+	return input(prompt)
 
 
 def login(bugzilla):

diff --git a/file-stabilization-bugs.py b/file-stabilization-bugs.py
index 1c5bbe9..f9b170c 100755
--- a/file-stabilization-bugs.py
+++ b/file-stabilization-bugs.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
 # Copyright 2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
@@ -11,16 +11,14 @@ import re
 import shutil
 import subprocess
 import sys
-import urllib
-import xmlrpclib
+import xmlrpc.client
 
-from bugz.bugzilla import BugzillaProxy
 from common import login
 import portage.versions
 from portage.xml.metadata import MetaDataXML
 
 def save_state(done_cpvs):
-	with open('file-stabilization-bugs.state', 'w') as state_file:
+	with open('file-stabilization-bugs.state', 'wb') as state_file:
 		pickle.dump(done_cpvs, state_file)
 
 if __name__ == "__main__":
@@ -40,13 +38,13 @@ if __name__ == "__main__":
 
 	done_cpvs = []
 	if os.path.exists('file-stabilization-bugs.state'):
-		with open('file-stabilization-bugs.state', 'r') as state_file:
-			done_cpvs = pickle.load(state_file)
+		with open('file-stabilization-bugs.state', 'rb') as state_file:
+			done_cpvs = pickle.load(state_file, fix_imports=True)
 
 	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)
+	print('You will be prompted for your Gentoo Bugzilla username and password (%s).' % url)
+	bugzilla = xmlrpc.client.ServerProxy(url)
+	user, login_data = login(bugzilla)
 	
 	with open(options.input_filename, "r") as input_file:
 		for line in input_file:
@@ -58,7 +56,7 @@ if __name__ == "__main__":
 
 			cpv = line
 			if cpv in done_cpvs:
-				print 'Skipping %s because it\'s marked as done' % cpv
+				print('Skipping %s because it\'s marked as done' % cpv)
 				continue
 
 			cp = portage.versions.pkgsplit(cpv)[0]
@@ -75,37 +73,41 @@ if __name__ == "__main__":
 			description = ('Is it OK to stabilize =%s ?\n' % cpv +
 				       'If so, please CC all arches which have stable keywords\n' +
 				       'for older versions of this package.')
-			url = 'http://packages.gentoo.org/package/%s?arches=linux' % urllib.quote(cp)
 			params = {}
+			params['Bugzilla_token'] = login_data['token']
 			params['product'] = 'Gentoo Linux'
 			params['version'] = 'unspecified'
 			params['component'] = 'Keywording and Stabilization'
 			params['summary'] = '%s: stabilization request' % cpv
 			params['description'] = description
-			params['url'] = url
 			params['assigned_to'] = maintainer
 			params['cc'] = other_maintainers
 			params['severity'] = 'enhancement'
 			try:
 				bug_id = bugzilla.Bug.create(params)['id']
-				print 'Submitted bug #%d for %s. ;-)' % (bug_id, cpv)
+				print('Submitted bug #%d for %s. ;-)' % (bug_id, cpv))
 				done_cpvs += cpv
 				save_state(done_cpvs)
 				try:
 					params = {}
+					params['Bugzilla_token'] = login_data['token']
 					params['ids'] = [bug_id]
 					params['keywords'] = {'set': 'STABLEREQ'}
 					bugzilla.Bug.update(params)
-				except xmlrpclib.Fault, f:
+				except xmlrpc.client.Fault as f:
 					exit_code = 1
-					print f
-					print 'Failed to add STABLEREQ keyword for %s. :-/' % cpv
-			except xmlrpclib.Fault, f:
+					print(f)
+					print('Failed to add STABLEREQ keyword for %s. :-/' % cpv)
+			except xmlrpc.client.Fault as f:
 				exit_code = 1
-				print f
-				print 'Failed to submit bug for %s. :-(' % cpv
+				print(f)
+				print('Failed to submit bug for %s. :-(' % cpv)
 	
 	if exit_code == 0 and os.path.exists('file-stabilization-bugs.state'):
 		os.remove('file-stabilization-bugs.state')
 	
+	params = {}
+	params['Bugzilla_token'] = login_data['token']
+	bugzilla.User.logout(params)
+
 	sys.exit(exit_code)

diff --git a/maintainer-timeout.py b/maintainer-timeout.py
index 76c7e59..54b4044 100755
--- a/maintainer-timeout.py
+++ b/maintainer-timeout.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
 # Copyright 2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
@@ -6,11 +6,11 @@ import datetime
 import optparse
 import os.path
 import sys
+import xmlrpc.client
 
-from bugz.bugzilla import BugzillaProxy
 import portage.versions
 
-from common import Bug, chunks, login, detect_cpvs
+from common import login, detect_cpvs
 
 
 def keyword_to_email(keyword):
@@ -27,12 +27,20 @@ if __name__ == "__main__":
 		parser.error("unrecognized command-line args")
 
 	url = 'https://bugs.gentoo.org/xmlrpc.cgi'
-	print 'You will be prompted for your Gentoo Bugzilla username and password (%s).' % url
-	bugzilla = BugzillaProxy(url)
+	print('You will be prompted for your Gentoo Bugzilla username and password (%s).' % url)
+	bugzilla = xmlrpc.client.ServerProxy(url)
 	user, login_data = login(bugzilla)
 	
-	bugs = bugzilla.Bug.search({'reporter': user, 'summary': ['stabilize', 'stabilization', 'stable'], 'resolution': ''})['bugs']
-	comments = bugzilla.Bug.comments({'ids': [bug['id'] for bug in bugs]})
+	params = {}
+	params['Bugzilla_token'] = login_data['token']
+	params['reporter'] = user
+	params['summary'] = ['stabilize', 'stabilization', 'stable']
+	params['resolution'] = ''
+	bugs = bugzilla.Bug.search(params)['bugs']
+	params = {}
+	params['Bugzilla_token'] = login_data['token']
+	params['ids'] = [bug['id'] for bug in bugs]
+	comments = bugzilla.Bug.comments(params)
 	for bug in bugs:
 		# Skip bugs where stabilization seems to be already in progress.
 		arch_found = False
@@ -68,6 +76,7 @@ if __name__ == "__main__":
 					target_keywords.add(keyword)
 
 		params = {}
+		params['Bugzilla_token'] = login_data['token']
 		params['ids'] = [bug['id']]
 		params['cc'] = {}
 		params['cc']['add'] = list(set(keyword_to_email(k) for k in target_keywords))
@@ -75,7 +84,11 @@ if __name__ == "__main__":
 		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 ;-)' % (
+		print('Updated bug #%s (%s). Target KEYWORDS: %s ;-)' % (
 			bug['id'],
 			bug['summary'],
-			', '.join(list(target_keywords)))
+			', '.join(list(target_keywords))))
+
+	params = {}
+	params['Bugzilla_token'] = login_data['token']
+	bugzilla.User.logout(params)

diff --git a/reverse-dependencies.py b/reverse-dependencies.py
index 96233ea..624b668 100755
--- a/reverse-dependencies.py
+++ b/reverse-dependencies.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
 # Copyright 2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
@@ -16,7 +16,7 @@ def process_deps(deps, use=None):
 		use = []
 	result = []
 	for index, x in enumerate(deps):
-		if type(x) == types.ListType:
+		if type(x) == list:
 			continue
 		elif x == "||":  # Any-of.
 			result.extend(process_deps(deps[index + 1], use))
@@ -82,4 +82,4 @@ if __name__ == "__main__":
 								output_file.write("#\t%s\n" % ",".join(use_combination))
 						output_file.write("%s\n" % cp)
 				elif options.verbose:
-					print 'No reverse dependencies for %s' % pn
+					print('No reverse dependencies for %s' % pn)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 52c88f1..d324bdb 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
 # Copyright 2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
@@ -8,10 +8,8 @@ import os.path
 import random
 import re
 import subprocess
-import xmlrpclib
-import urllib
+import xmlrpc.client
 
-from bugz.bugzilla import BugzillaProxy
 from portage.package.ebuild.getmaskingstatus import getmaskingstatus
 from portage.xml.metadata import MetaDataXML
 import portage.versions
@@ -36,9 +34,9 @@ if __name__ == "__main__":
 		parser.error("unrecognized command-line args")
 
 	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)
+	print('You will be prompted for your Gentoo Bugzilla username and password (%s).' % url)
+	bugzilla = xmlrpc.client.ServerProxy(url)
+	user, login_data = login(bugzilla)
 	
 	final_candidates = []
 	now = datetime.datetime.now()
@@ -77,7 +75,7 @@ if __name__ == "__main__":
 		best_stable = portage.versions.best(portage.portdb.match(cp))
 		if not best_stable:
 			continue
-		print 'Working on %s...' % cp,
+		print('Working on %s...' % cp, end=' ')
 		candidates = []
 		for cpv in portage.portdb.cp_list(cp):
 			# Only consider higher versions than best stable.
@@ -100,12 +98,12 @@ if __name__ == "__main__":
 				continue
 
 			# Eliminate hard masked packages among others.
-			if getmaskingstatus(cpv) not in [[u'~%s keyword' % arch] for arch in options.arch]:
+			if getmaskingstatus(cpv) not in [['~%s keyword' % arch] for arch in options.arch]:
 				continue
 
 			candidates.append(cpv)
 		if not candidates:
-			print 'no candidates'
+			print('no candidates')
 			continue
 
 		candidates.sort(key=portage.versions.cpv_sort_key())
@@ -122,14 +120,14 @@ if __name__ == "__main__":
 				regex = '\*%s \((.*)\)' % re.escape(pv)
 				match = re.search(regex, changelog_file.read())
 				if not match:
-					print 'error parsing ChangeLog'
+					print('error parsing ChangeLog')
 					continue
 				changelog_date = datetime.datetime.strptime(match.group(1), '%d %b %Y')
 				if now - changelog_date < datetime.timedelta(days=options.days):
-					print 'not old enough'
+					print('not old enough')
 					continue
-		except IOError, e:
-			print e
+		except IOError as e:
+			print(e)
 			continue
 
 		keywords = portage.db["/"]["porttree"].dbapi.aux_get(best_candidate, ['KEYWORDS'])[0]
@@ -139,19 +137,25 @@ if __name__ == "__main__":
 				missing_arch = True
 				break
 		if missing_arch:
-			print 'not keyworded ~arch'
+			print('not keyworded ~arch')
 			continue
 
 		# Do not risk trying to stabilize a package with known bugs.
-		bugs = [x for x in bugzilla.Bug.search({'summary': cp})['bugs'] if x['is_open'] and x['severity'] not in ['enhancement', 'QA']]
+		params = {}
+		params['Bugzilla_token'] = login_data['token']
+		params['summary'] = cp
+		bugs = [x for x in bugzilla.Bug.search(params)['bugs'] if x['is_open'] and x['severity'] not in ['enhancement', 'QA']]
 		if bugs:
-			print 'has bugs'
+			print('has bugs')
 			continue
 
 		# Protection against filing a stabilization bug twice.
-		bugs = bugzilla.Bug.search({'summary': best_candidate})['bugs']
+		params = {}
+		params['Bugzilla_token'] = login_data['token']
+		params['summary'] = best_candidate
+		bugs = bugzilla.Bug.search(params)['bugs']
 		if bugs:
-			print 'version has bugs'
+			print('version has bugs')
 			continue
 
 		ebuild_name = portage.versions.catsplit(best_candidate)[1] + ".ebuild"
@@ -160,8 +164,8 @@ if __name__ == "__main__":
 		try:
 			original_contents = open(ebuild_path).read()
 			manifest_contents = open(manifest_path).read()
-		except IOError, e:
-			print e
+		except IOError as e:
+			print(e)
 			continue
 		try:
 			for arch in options.arch:
@@ -169,7 +173,7 @@ if __name__ == "__main__":
 			subprocess.check_output(["repoman", "manifest"], cwd=cvs_path)
 			subprocess.check_output(["repoman", "full"], cwd=cvs_path)
 		except subprocess.CalledProcessError:
-			print 'repoman error'
+			print('repoman error')
 			continue
 		finally:
 			f = open(ebuild_path, "w")
@@ -182,4 +186,8 @@ if __name__ == "__main__":
 		with open(options.output_filename, 'a') as f:
 			f.write('# %s %s\n' % (maintainer, ', '.join(other_maintainers)))
 			f.write('%s\n' % best_candidate)
-		print (best_candidate, maintainer, other_maintainers)
+		print((best_candidate, maintainer, other_maintainers))
+
+	params = {}
+	params['Bugzilla_token'] = login_data['token']
+	bugzilla.User.logout(params)


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2017-07-09 14:42 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2017-07-09 14:42 UTC (permalink / raw
  To: gentoo-commits

commit:     eed2243011824ddb3525a75409fae1398a11fb11
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Sun Jul  9 14:42:21 2017 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Sun Jul  9 14:42:21 2017 +0000
URL:        https://gitweb.gentoo.org/proj/arch-tools.git/commit/?id=eed22430

stabilization-candidates: update for git

 stabilization-candidates.py | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index d324bdb..2537ab4 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -20,7 +20,7 @@ if __name__ == "__main__":
 	parser = optparse.OptionParser()
 	parser.add_option("--arch", dest="arch", action="append", help="Gentoo arch to use, e.g. x86, amd64, ... Can be passed multiple times.")
 	parser.add_option("--days", dest="days", type=int, default=30, help="Number of days in the tree after stabilization is possible.")
-	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
+	parser.add_option("--repo", dest="repo", help="Path to portage git repository")
 	parser.add_option("--category", dest="category", help="Portage category filter (default is all categories)")
 	parser.add_option("--exclude", dest="exclude", default=".*(kde-base|sci|lisp|perl-core|virtual|gnome|ruby|x11|mono|dotnet|games|xfce|xfburn|mousepad|orage|xfbib|thunar|ristretto|pragha|xfmpc|parole|midori|gigolo|rodent|xfwm|girara|zathura|leechcraft).*", help="Regular expression for excluded packages.")
 	parser.add_option("-o", "--output", dest="output_filename", default="stabilization-candidates.txt", help="Output filename for generated stabilization candidates list.")
@@ -116,18 +116,16 @@ if __name__ == "__main__":
 
 		pv = portage.versions.catsplit(best_candidate)[1]
 		try:
-			with open(os.path.join(options.repo, cp, 'ChangeLog')) as changelog_file:
-				regex = '\*%s \((.*)\)' % re.escape(pv)
-				match = re.search(regex, changelog_file.read())
-				if not match:
-					print('error parsing ChangeLog')
-					continue
-				changelog_date = datetime.datetime.strptime(match.group(1), '%d %b %Y')
-				if now - changelog_date < datetime.timedelta(days=options.days):
-					print('not old enough')
-					continue
-		except IOError as e:
-			print(e)
+			git_log = subprocess.check_output(
+				['git', 'log', '--date-order', '--date=short', '--format=%cd', '%s.ebuild' % pv],
+				cwd=os.path.join(options.repo, cp))
+			changelog_date_str = git_log.splitlines()[0].decode('utf-8')
+			changelog_date = datetime.datetime.strptime(changelog_date_str, '%Y-%m-%d')
+			if now - changelog_date < datetime.timedelta(days=options.days):
+				print('not old enough')
+				continue
+		except subprocess.CalledProcessError as ex:
+			print('git error: ' + ex.output)
 			continue
 
 		keywords = portage.db["/"]["porttree"].dbapi.aux_get(best_candidate, ['KEYWORDS'])[0]


^ permalink raw reply related	[flat|nested] 59+ messages in thread

* [gentoo-commits] proj/arch-tools:master commit in: /
@ 2017-07-10 20:29 Paweł Hajdan
  0 siblings, 0 replies; 59+ messages in thread
From: Paweł Hajdan @ 2017-07-10 20:29 UTC (permalink / raw
  To: gentoo-commits

commit:     064b7b3dbf4277b9c57add479a478386504fc0d2
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 10 20:28:50 2017 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Mon Jul 10 20:28:50 2017 +0000
URL:        https://gitweb.gentoo.org/proj/arch-tools.git/commit/?id=064b7b3d

stabilization-candidates: retry network errors

 common.py                   | 19 +++++++++++++++++++
 stabilization-candidates.py | 26 +++++++++++++++++---------
 2 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/common.py b/common.py
index 89e4996..8e0c14c 100644
--- a/common.py
+++ b/common.py
@@ -1,10 +1,12 @@
 # Copyright 2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+import functools
 import io
 import datetime
 import getpass
 import re
+import time
 
 import portage
 
@@ -17,6 +19,23 @@ def chunks(iterable, length):
 		yield iterable[i:i + length]
 
 
+def retry(ExceptionToCheck, tries=4, delay=3, backoff=2):
+	def deco_retry(f):
+		@functools.wraps(f)
+		def f_retry(*args, **kwargs):
+			mtries, mdelay = tries, delay
+			while mtries > 1:
+				try:
+					return f(*args, **kwargs)
+				except ExceptionToCheck:
+					time.sleep(mdelay)
+					mtries -= 1
+					mdelay *= backoff
+			return f(*args, **kwargs)
+		return f_retry
+	return deco_retry
+
+
 # Snippet from http://bugs.python.org/issue9584
 def expand_braces(orig):
 	r = r'.*(\{.+?[^\\]\})'

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 2537ab4..0cedac4 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -7,6 +7,7 @@ import optparse
 import os.path
 import random
 import re
+import socket
 import subprocess
 import xmlrpc.client
 
@@ -14,7 +15,7 @@ from portage.package.ebuild.getmaskingstatus import getmaskingstatus
 from portage.xml.metadata import MetaDataXML
 import portage.versions
 
-from common import login
+from common import login, retry
 
 if __name__ == "__main__":
 	parser = optparse.OptionParser()
@@ -139,19 +140,26 @@ if __name__ == "__main__":
 			continue
 
 		# Do not risk trying to stabilize a package with known bugs.
-		params = {}
-		params['Bugzilla_token'] = login_data['token']
-		params['summary'] = cp
-		bugs = [x for x in bugzilla.Bug.search(params)['bugs'] if x['is_open'] and x['severity'] not in ['enhancement', 'QA']]
+		@retry(socket.error)
+		def get_package_bugs():
+			params = {}
+			params['Bugzilla_token'] = login_data['token']
+			params['summary'] = cp
+			return [x for x in bugzilla.Bug.search(params)['bugs']
+				if x['is_open'] and x['severity'] not in ['enhancement', 'QA']]
+		bugs = get_package_bugs()
 		if bugs:
 			print('has bugs')
 			continue
 
 		# Protection against filing a stabilization bug twice.
-		params = {}
-		params['Bugzilla_token'] = login_data['token']
-		params['summary'] = best_candidate
-		bugs = bugzilla.Bug.search(params)['bugs']
+		@retry(socket.error)
+		def get_package_bugs():
+			params = {}
+			params['Bugzilla_token'] = login_data['token']
+			params['summary'] = best_candidate
+			return bugzilla.Bug.search(params)['bugs']
+		bugs = get_package_bugs()
 		if bugs:
 			print('version has bugs')
 			continue


^ permalink raw reply related	[flat|nested] 59+ messages in thread

end of thread, other threads:[~2017-07-10 20:29 UTC | newest]

Thread overview: 59+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-19 23:35 [gentoo-commits] proj/arch-tools:master commit in: / Paweł Hajdan
  -- strict thread matches above, loose matches on Subject: below --
2017-07-10 20:29 Paweł Hajdan
2017-07-09 14:42 Paweł Hajdan
2015-01-05 14:41 Paweł Hajdan
2015-01-05 14:41 Paweł Hajdan
2015-01-05 14:41 Paweł Hajdan
2014-06-14  9:47 Paweł Hajdan
2014-04-07 12:40 Samuli Suominen
2014-02-12  7:06 Paweł Hajdan
2013-06-22 15:05 Paweł Hajdan
2013-06-22 14:57 Paweł Hajdan
2013-03-11 21:56 Paweł Hajdan
2013-02-28  4:50 Paweł Hajdan
2013-02-28  4:50 Paweł Hajdan
2012-10-16 16:54 Paweł Hajdan
2012-10-16 16:54 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:02 [gentoo-commits] proj/arch-tools:new-pybugz " Paweł Hajdan
2012-10-08 16:03 ` [gentoo-commits] proj/arch-tools:master " Paweł Hajdan
2012-08-01 11:08 [gentoo-commits] proj/arch-tools:new-pybugz " Paweł Hajdan
2012-10-08 16:03 ` [gentoo-commits] proj/arch-tools:master " Paweł Hajdan
2012-08-01  7:28 [gentoo-commits] proj/arch-tools:new-pybugz " Paweł Hajdan
2012-10-08 16:03 ` [gentoo-commits] proj/arch-tools:master " Paweł Hajdan
2012-06-04  9:18 [gentoo-commits] proj/arch-tools:new-pybugz " Paweł Hajdan
2012-10-08 16:03 ` [gentoo-commits] proj/arch-tools:master " Paweł Hajdan
2012-03-27 15:26 Paweł Hajdan
2012-03-09 11:49 Paweł Hajdan
2012-03-09 11:49 Paweł Hajdan
2012-02-02 16:48 Paweł Hajdan
2012-01-27 14:55 Paweł Hajdan
2012-01-21 17:05 Paweł Hajdan
2011-12-14  7:23 Paweł Hajdan
2011-12-06 11:14 Paweł Hajdan
2011-12-01 18:56 Paweł Hajdan
2011-12-01 18:47 Paweł Hajdan
2011-12-01 18:47 Paweł Hajdan
2011-11-30 17:38 Paweł Hajdan
2011-11-23  8:59 Paweł Hajdan
2011-11-23  8:59 Paweł Hajdan
2011-11-21  8:34 Paweł Hajdan
2011-11-03 11:00 Paweł Hajdan
2011-10-22  8:18 Paweł Hajdan
2011-10-21 15:15 Paweł Hajdan
2011-10-18 14:05 Paweł Hajdan
2011-10-16  3:51 Paweł Hajdan
2011-10-13 21:59 Paweł Hajdan
2011-10-04 21:46 Paweł Hajdan
2011-09-19  3:09 Paweł Hajdan
2011-08-07  3:26 Paweł Hajdan
2011-06-05 16:16 Paweł Hajdan
2011-06-02 15:41 Paweł Hajdan
2011-06-02 15:38 Paweł Hajdan
2011-05-25 19:51 Paweł Hajdan
2011-05-25 10:32 Paweł Hajdan
2011-05-22 15:31 Paweł Hajdan
2011-05-22 15:16 Paweł Hajdan
2011-05-22 13:36 Paweł Hajdan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox