diff --git a/distgit_bugzilla_sync/script.py b/distgit_bugzilla_sync/script.py index ce7eda2..bd9b099 100644 --- a/distgit_bugzilla_sync/script.py +++ b/distgit_bugzilla_sync/script.py @@ -446,9 +446,24 @@ class BugzillaProxy: # FIXME: initialowner has been made mandatory for some # reason. Asking dkl why. data['initialowner'] = owner_email + + def edit_component(data, num_attempts=5): + for i in range(num_attempts): + try: + self.server.editcomponent(data) + break + except Exception as e: + if i >= num_attempts - 1: + raise + if self.config['verbose']: + print(f" ERROR {e}") + print(" - Query failed, going to try again in 20 seconds") + # Wait 20 seconds and try again + time.sleep(20) + if not self.config["dryrun"]: try: - self.server.editcomponent(data) + edit_component(data) except xmlrpc.client.Fault as e: # Output something useful in args e.args = (data, e.faultCode, e.faultString) @@ -456,6 +471,7 @@ class BugzillaProxy: except xmlrpc.client.ProtocolError as e: e.args = ('ProtocolError', e.errcode, e.errmsg) raise + if owner_changed: self.update_open_bugs( new_poc=owner_email, @@ -500,9 +516,24 @@ class BugzillaProxy: print(f"[ADDCOMP] {bz_product_name}/{package} {key} set to FAS name(s) `{value}`") else: print(f"[ADDCOMP] {bz_product_name}/{package} {key} set to {data.get(key)}") + + def add_component(data, num_attempts=5): + for i in range(num_attempts): + try: + self.server.addcomponent(data) + break + except Exception as e: + if i >= num_attempts - 1: + raise + if self.config['verbose']: + print(f" ERROR {e}") + print(" - Query failed, going to try again in 20 seconds") + # Wait 20 seconds and try again + time.sleep(20) + if not self.config["dryrun"]: try: - self.server.addcomponent(data) + add_component(data) except xmlrpc.client.Fault as e: # Output something useful in args e.args = (data, e.faultCode, e.faultString)