From 629c43a1818e4a35037ad3e6818cdbb22cd20c2d Mon Sep 17 00:00:00 2001 From: Till Maas Date: Jul 07 2013 21:01:55 +0000 Subject: BodhiClient adjustments wrt retries - set retries - except errors from BodhiClient.query() --- diff --git a/fedora-easy-karma.py b/fedora-easy-karma.py index 87265d7..3872050 100755 --- a/fedora-easy-karma.py +++ b/fedora-easy-karma.py @@ -266,7 +266,7 @@ class FedoraEasyKarma(object): fas_username = os.environ["LOGNAME"] self.options.fas_username = fas_username - bc = BodhiClient(username=self.options.fas_username, useragent="Fedora Easy Karma/GIT") + bc = BodhiClient(username=self.options.fas_username, useragent="Fedora Easy Karma/GIT", retries=self.options.retries) my = yum.YumBase() my.preconf.debuglevel = 0 @@ -309,16 +309,34 @@ class FedoraEasyKarma(object): print "Cannot access bodhi cache file: %s" % cachefile_name sys.exit(ioe.errno) else: - self.info("Getting list of packages in updates-testing...") + self.info("Waiting for Bodhi for a list of packages in updates-testing (%s)..." % release) self.debug("starting bodhi query") - # probably raises some exceptions - testing_updates = bc.query(release=release, status="testing", limit=1000)["updates"] + 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) + else: + testing_updates = testing_updates["updates"] + # can't query for requestless as of python-fedora 0.3.18 # (request=None results in no filtering by request) testing_updates = [x for x in testing_updates if not x["request"]] + # extend list of updates with updates that are going to testing to # support manually installed rpms from koji - testing_updates.extend(bc.query(release=release, status="pending", request="testing", limit=1000)["updates"]) + 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) + else: + testing_updates.extend(pending_updates["updates"]) + del pending_updates if self.options.bodhi_update_cache: try: @@ -498,9 +516,12 @@ class FedoraEasyKarma(object): def send_comment(self, bc, update, comment, karma): + orig_retries = bc.retries + bc.retries = 1 for retry in range(0, self.options.retries + 1): try: res = bc.comment(update["title"], comment, karma=karma) + bc.retries = orig_retries return (True, res) except fedora.client.AuthError, e: self.warning("Authentication error") @@ -508,6 +529,7 @@ class FedoraEasyKarma(object): except fedora.client.ServerError, e: self.warning("Server error: %s" % str(e)) + bc.retries = orig_retries return (False, 'too many errors')