diff options
author | 2016-12-22 06:07:45 +1100 | |
---|---|---|
committer | 2016-12-22 06:54:48 +1100 | |
commit | faea11639892c8175f34b62c8315713395e75d16 (patch) | |
tree | 2794d87a61bfcf27574b23881c29dbc2073f231e | |
parent | Replace hard-coded bug update script with brand new template. (diff) | |
download | tatt-faea11639892c8175f34b62c8315713395e75d16.tar.gz tatt-faea11639892c8175f34b62c8315713395e75d16.tar.bz2 tatt-faea11639892c8175f34b62c8315713395e75d16.zip |
When using -b, fetch atoms from the new atom field or flagged attachment.
-rwxr-xr-x | scripts/tatt | 29 | ||||
-rw-r--r-- | tatt/packageFinder.py | 20 |
2 files changed, 32 insertions, 17 deletions
diff --git a/scripts/tatt b/scripts/tatt index de80917..417831e 100755 --- a/scripts/tatt +++ b/scripts/tatt @@ -5,6 +5,8 @@ from subprocess import * import sys import re import os +import base64 +import requests from tatt.gentooPackage import gentooPackage as gP import tatt.packageFinder as packageFinder @@ -18,6 +20,8 @@ from tatt.job import job as job ##### Generate a global config obj, reading from ~/.tatt ##### config = tattConfig() +session = requests.Session() +session.params.update({'Bugzilla_api_key': config['bugzilla-key']}) ######### Main program starts here ############### @@ -123,22 +127,19 @@ if options.infile: sys.exit(1) packraw = packfile.read() packfile.close() - myJob.packageList = packageFinder.findPackages(packraw, re.compile(config['atom-regexp'])) + myJob.packageList = packageFinder.findPackages(packraw, config['arch']) ## -b and a bugnumber was given ? if options.bugnum: print("Bugnumber: " + options.bugnum) myJob.bugnumber=options.bugnum - p1 = Popen(['bugz', 'get', myJob.bugnumber, '-n'], stdout=PIPE) - # This returns a bytes encoded string, but we need standard utf-8 - # to use a string object via its buffer API. -> decode. - bugraw = p1.communicate()[0].decode('utf-8') - bugtitle = [l for l in bugraw.splitlines() if 'Title' in l][0] - if re.search('KEYWORDREQ', bugraw): + params = {"id": options.bugnum} + response = session.get(config["bugzilla-url"] + "/rest/bug", params=params).json()["bugs"][0] + if "KEYWORDREQ" in response["keywords"] or response["component"] == "Keywording": # This is a keywording bug: print ("Keywording bug detected.") myJob.type="keyword" - elif re.search('STABLEREQ', bugraw): + elif "STABLEREQ" in response["keywords"] or response["component"] == "Stabilization": # Stablebug print ("Stabilization bug detected.") myJob.type="stable" @@ -147,7 +148,17 @@ if options.bugnum: sys.exit(1) # If myJob.packageList is still empty we search in the bug-title if myJob.packageList==None: - myJob.packageList = packageFinder.findPackages(bugtitle, re.compile(config['atom-regexp'])) + if response["cf_stabilisation_atoms"]: + myJob.packageList = packageFinder.findPackages(response["cf_stabilisation_atoms"], config['arch']) + else: + response = session.get(config["bugzilla-url"] + "/rest/bug/{}/attachment".format(options.bugnum), params=params).json()["bugs"][str(options.bugnum)] + for attachment in response: + if attachment["is_obsolete"] == 1: + continue + for flag in attachment['flags']: + if flag["name"] == "stabilization-list" and flag["status"] == '+': + myJob.packageList = packageFinder.findPackages(base64.b64decode(attachment["data"]).decode("utf8"), config['arch']) + # joint code for -f and -b ########################## diff --git a/tatt/packageFinder.py b/tatt/packageFinder.py index f0fb467..c1d7bd0 100644 --- a/tatt/packageFinder.py +++ b/tatt/packageFinder.py @@ -1,13 +1,17 @@ -"""module for identifying package names in files and strings""" +"""module for extracting packages from a package/architecture list """ -import re from .gentooPackage import gentooPackage as gP -def findPackages (s, regexp): +def findPackages (s, arch): """ Given a string s, - and a compiled regexp regexp - return all gentooPacakges that can be identified in the string""" + and a string arch + return all gentooPackages from that string that need actioning on that arch """ - # Should it be this simple? - return [gP(ps) for ps in regexp.findall(s)] - # Yes, it is... + packages = [] + + for line in s.splitlines(): + atom, _, arches = line.partition(' ') + if not arches or arch in arches.split(' '): + packages.append(gP(atom)) + + return(packages) |