summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Flink <tflink@fedoraproject.org>2015-09-21 19:10:24 +0200
committerTill Maas <opensource@till.name>2015-09-21 19:10:24 +0200
commit2fe169d4c1a9e97efa84ed8d3999e55cba4df294 (patch)
tree966dde9803e4a630e3495703cbd915b23cda5a8c
parentc8e437c0e9b7f75539ca0353acd96c174171d8eb (diff)
downloadfedora-easy-karma-2fe169d4c1a9e97efa84ed8d3999e55cba4df294.tar.gz
fedora-easy-karma-2fe169d4c1a9e97efa84ed8d3999e55cba4df294.tar.xz
fedora-easy-karma-2fe169d4c1a9e97efa84ed8d3999e55cba4df294.zip
Initial adjustments for Bodhi2
-rwxr-xr-xfedora-easy-karma.py107
1 files changed, 67 insertions, 40 deletions
diff --git a/fedora-easy-karma.py b/fedora-easy-karma.py
index 7671f63..9e77244 100755
--- a/fedora-easy-karma.py
+++ b/fedora-easy-karma.py
@@ -55,7 +55,7 @@ class FEK_helper(object):
@staticmethod
def bodhi_update_str(
update,
- bodhi_base_url="https://admin.fedoraproject.org/updates/",
+ bodhi_base_url="https://bodhi.fedoraproject.org/",
bugzilla_bug_url="https://bugzilla.redhat.com/",
test_cases_url="https://fedoraproject.org/wiki/",
wrap_bugs=True,
@@ -98,7 +98,8 @@ class FEK_helper(object):
values["type"] = ""
if "critpath" in update and update["critpath"]:
- if not update["critpath_approved"]:
+ # I'm not sure if this is what the data member acutally means, assuming for now
+ if not update["date_approved"]:
values["type"] = "unapproved "
values["type"] += "critpath "
@@ -113,11 +114,11 @@ class FEK_helper(object):
if len(update["bugs"]):
bugs = []
for bug in update["bugs"]:
- bz_id = bug["bz_id"]
+ bug_id = bug["bug_id"]
if bugzilla_bug_url:
- bz_id = "%s%d" % (bugzilla_bug_url, bz_id)
+ bug_id = "%s%d" % (bugzilla_bug_url, bug_id)
bz_title = bug["title"]
- bugs.append("%s - %s" % (bz_id, bz_title))
+ bugs.append("%s - %s" % (bug_id, bz_title))
if wrap_bugs:
values["bugs"] = "%s\n" % FEK_helper.wrap_paragraphs_prefix(
@@ -130,11 +131,12 @@ class FEK_helper(object):
else:
values["bugs"] = ""
- if update["nagged"] and "test_cases" in update["nagged"]:
- test_cases = []
- for tc in update["nagged"]["test_cases"]:
- tc = tc.replace(" ", "_").replace(":", "%3A")
- test_cases.append(test_cases_url + tc)
+ test_cases = []
+ for case in update["test_cases"]:
+ tc = case['name']
+ tc = tc.replace(" ", "_").replace(":", "%3A")
+ test_cases.append(test_cases_url + tc)
+ if len(test_cases) > 0:
values["test_cases"] = "%s\n" % FEK_helper.wrap_paragraphs_prefix(
test_cases, first_prefix=" Test Cases: ", width=width,
extra_newline=True
@@ -161,11 +163,13 @@ class FEK_helper(object):
indent = " " * 13
comment["indent"] = indent
+ # the format of the user has changed, add a data member
+ comment["username"] = comment["user"]["name"]
if comment["anonymous"]:
- comment["author"] += " (unauthenticated)"
+ comment["username"] += " (unauthenticated)"
comments.append(
- "%(indent)s%(author)s - %(timestamp)s (karma %(karma)s)" %
+ "%(indent)s%(username)s - %(timestamp)s (karma %(karma)s)" %
comment
)
@@ -178,15 +182,21 @@ class FEK_helper(object):
else:
values["comments"] = ""
+ # does this need to be changed to alias?
if update["updateid"]:
- url_path = "%s/%s" % (update["release"]["name"],
- update["updateid"])
+ url_path = "updates/%s" % (update["updateid"])
else:
url_path = update["title"]
values["update_url"] = " %s%s\n" % (bodhi_base_url, url_path)
- values["karma_status"] = "%d/%d" % (values["karma"],
- values["stable_karma"])
+ # stable_karma can come back as None, meaning that auto-requesting push
+ # to stable has been disabled.
+ # https://github.com/fedora-infra/bodhi/issues/274
+ if values['stable_karma'] is None:
+ values['karma_status'] = "%d" % (values["karma"])
+ else:
+ values["karma_status"] = "%d/%s" % (values["karma"],
+ values["stable_karma"])
return format_string % values
@@ -353,6 +363,8 @@ class FedoraEasyKarma(object):
fas_username = os.environ["LOGNAME"]
self.options.fas_username = fas_username
+ # note that the retry logic in the bodhi client is currently not functional
+ # https://github.com/fedora-infra/python-fedora/issues/144
bc = BodhiClient(username=self.options.fas_username, useragent="Fedora Easy Karma/GIT", retries=self.options.retries)
# Bodhi is too slow for our queries, therefore wait longer
bc.timeout = 300
@@ -400,17 +412,8 @@ class FedoraEasyKarma(object):
self.info("Waiting for Bodhi for a list of packages in "
"updates-testing (%s)..." % release)
self.debug("starting bodhi query")
- try:
- testing_updates = bc.query(
- release=release,
- status="testing",
- limit=1000)
- # There is no clear indication which Exceptions bc.query() might
- # throw, therefore catch all (python-fedora-0.3.32.3-1.fc19)
- except Exception as e:
- print "Cannot query Bodhi: {0}".format(e)
- sys.exit(1)
- testing_updates = testing_updates["updates"]
+ testing_updates = self.query_bodhi(bc, release, pending=False)
+ print("found {} testing updates".format(len(testing_updates)))
# can't query for requestless as of python-fedora 0.3.18
# (request=None results in no filtering by request)
@@ -418,18 +421,8 @@ class FedoraEasyKarma(object):
# extend list of updates with updates that are going to testing to
# support manually installed rpms from koji
- try:
- pending_updates = bc.query(
- release=release,
- status="pending",
- request="testing",
- limit=1000)
- # There is no clear indication which Exceptions bc.query() might
- # throw, therefore catch all (python-fedora-0.3.32.3-1.fc19)
- except Exception as e:
- print "Cannot query Bodhi: {0}".format(e)
- sys.exit(1)
- testing_updates.extend(pending_updates["updates"])
+ pending_updates = self.query_bodhi(bc, release, pending=True)
+ testing_updates.extend(pending_updates)
del pending_updates
if self.options.bodhi_update_cache:
@@ -564,6 +557,40 @@ class FedoraEasyKarma(object):
pickle.dump(ignored_updates, outfile, -1)
outfile.close()
+ def query_bodhi(self, bodhi_client, release, pending=False):
+ """Deal with querying bodhi and combining all relevant pages into a
+ single list of updates."""
+
+ query_args = {"release": release,
+ "limit": 100
+ }
+ if pending:
+ query_args["request"] = "testing"
+ query_args["status"] = "pending"
+ else:
+ query_args["status"] = "testing"
+
+ updates = []
+ try:
+ # since bodhi now has a limit of 100 but multiple pages, get ALL
+ # of the updates before starting to process
+ result = bodhi_client.query(**query_args)
+ updates.extend(result['updates'])
+ while result.page < result.pages:
+ next_page = result['page'] + 1
+ self.info("Fetching updates page {} of {}".format(next_page, result['pages']))
+ result = bodhi_client.query(page=next_page, **query_args)
+ updates.extend(result['updates'])
+ # There is no clear indication which Exceptions bc.query() might
+ # throw, therefore catch all (python-fedora-0.3.32.3-1.fc19)
+ except Exception as e:
+ print "Error while querying Bodhi: {0}".format(e)
+ #sys.exit(1)
+ raise e
+
+ return updates
+
+
def already_commented(self, update, user):
for comment in update["comments"]:
# :TODO:WORKAROUND:
@@ -574,7 +601,7 @@ class FedoraEasyKarma(object):
# https://fedorahosted.org/bodhi/ticket/400
# https://bugzilla.redhat.com/show_bug.cgi?id=572228
if not comment["anonymous"] and \
- comment["author"].split(" ")[0] == user:
+ comment["user"]["name"] == user:
return True
return False