diff options
Diffstat (limited to 'fedora-easy-karma.py')
-rwxr-xr-x | fedora-easy-karma.py | 208 |
1 files changed, 173 insertions, 35 deletions
diff --git a/fedora-easy-karma.py b/fedora-easy-karma.py index 7443aa4..3d0e947 100755 --- a/fedora-easy-karma.py +++ b/fedora-easy-karma.py @@ -98,7 +98,8 @@ class FEK_helper(object): values["type"] = "" if "critpath" in update and update["critpath"]: - # I'm not sure if this is what the data member acutally means, assuming for now + # I'm not sure if this is what the data member acutally means, + # assuming for now if not update["date_approved"]: values["type"] = "unapproved " @@ -169,8 +170,8 @@ class FEK_helper(object): comment["username"] += " (unauthenticated)" comments.append( - "%(indent)s%(username)s - %(timestamp)s (karma %(karma)s)" % - comment + "%(indent)s%(username)s - %(timestamp)s " + "(karma %(karma)s)" % comment ) if comment["text"]: @@ -203,7 +204,17 @@ class FEK_helper(object): def wrap_paragraphs(paragraphs, width=67, subsequent_indent=(" " * 11 + ": "), second_column_indent=0): - return ("\n%s" % subsequent_indent).join(map(lambda p: "\n".join(wrap(p, width=width, subsequent_indent=(subsequent_indent + " " * second_column_indent))), paragraphs)) + return ("\n%s" % subsequent_indent).join( + map(lambda p: "\n".join( + wrap(p, + width=width, + subsequent_indent=( + subsequent_indent + " " * second_column_indent) + ) + ), + paragraphs + ) + ) @staticmethod def wrap_paragraphs_prefix(paragraphs, first_prefix, width=80, @@ -254,9 +265,11 @@ the update will be skipped. Note: <CTRL>-<D> on an empty prompt exits the program. -If you use a default comment, '<CTRL>-<X> <backspace>' can be used to delete the default comment to easily enter a custom one. +If you use a default comment, '<CTRL>-<X> <backspace>' can be used to delete +the default comment to easily enter a custom one. -For further documentation, please visit https://fedoraproject.org/wiki/Fedora_Easy_Karma +For further documentation, please visit: +https://fedoraproject.org/wiki/Fedora_Easy_Karma The source can be found at http://fedorapeople.org/cgit/till/public_git/fedora-easy-karma.git/ @@ -307,27 +320,139 @@ class FedoraEasyKarma(object): extra_newline=False) parser = OptionParser(usage=usage) - parser.add_option("", "--bodhi-cached", dest="bodhi_cached", help="Use cached bodhi query", action="store_true", default=False) - parser.add_option("", "--bodhi-update-cache", dest="bodhi_update_cache", help="Update bodhi query cache", action="store_true", default=False) - parser.add_option("", "--critpath-only", dest="critpath_only", help="Only consider unapproved critpath updates", action="store_true", default=False) - parser.add_option("", "--datadir", dest="datadir", help="Directory to store cache or ignore data, default: %default", default="~/.fedora-easy-karma") - parser.add_option("", "--debug", dest="debug", help="Enable debug output", action="store_true", default=False) - parser.add_option("", "--default-comment", dest="default_comment", help="Default comment to use, default: %default", default="", metavar="COMMENT") - parser.add_option("", "--default-karma", dest="default_karma", help="Default karma to use, default: %default", default="", metavar="KARMA") - parser.add_option("", "--fas-username", dest="fas_username", help="FAS username", default=None) - parser.add_option("", "--no-ignore-own", dest="ignore_own", help="Do not ignore own updates.", action="store_false", default=True) - parser.add_option("", "--include-commented", dest="include_commented", help="Also ask for more comments on updates that already got a comment from you, this is enabled if patterns are provided", action="store_true", default=False) - parser.add_option("", "--include-ignored", dest="include_ignored", help="Also ask for comments on updates that have been ignored previously.", action="store_true", default=False) - parser.add_option("", "--installed-max-days", dest="installed_max_days", help="Only check packages installed within the last XX days, default: %default", metavar="DAYS", default=28, type="int") - parser.add_option("", "--installed-min-days", dest="installed_min_days", help="Only check packages installed for at least XX days, default: %default", metavar="DAYS", default=0, type="int") - parser.add_option("", "--list-rpms-only", dest="list_rpms_only", help="Only list affected rpms", action="store_true", default=False) - parser.add_option("", "--no-skip-empty-comment", dest="skip_empty_comment", help="Do not skip update if comment is empty", action="store_false", default=True) - parser.add_option("", "--product", dest="product", help="product to query Bodhi for, 'F' for Fedora, 'EL-' for EPEL, default: %default", default="F") - parser.add_option("", "--releasever", dest="releasever", help="releasever to query Bodhi for, default: releasever from dnf or yum", default=None) - parser.add_option("", "--retries", dest="retries", help="Number if retries when submitting a comment in case of an error, default: %default", default=3, type="int") - parser.add_option("", "--wrap-bugs", dest="wrap_bugs", help="Apply line-wrapping to bugs", action="store_true", default=False) - parser.add_option("", "--wrap-rpms", dest="wrap_rpms", help="Apply line-wrapping to list of installed rpms", action="store_true", default=False) - parser.add_option("", "--wrap-width", dest="wrap_width", help="Width to use for line wrapping of updates, default: %default", default=80, type="int") + parser.add_option("", + "--bodhi-cached", dest="bodhi_cached", + help="Use cached bodhi query", + action="store_true", + default=False) + parser.add_option("", + "--bodhi-update-cache", + dest="bodhi_update_cache", + help="Update bodhi query cache", + action="store_true", + default=False) + parser.add_option("", + "--critpath-only", + dest="critpath_only", + help="Only consider unapproved critpath updates", + action="store_true", + default=False) + parser.add_option("", + "--datadir", + dest="datadir", + help="Directory to store cache or ignore data, " + "default: %default", + default="~/.fedora-easy-karma") + parser.add_option("", + "--debug", + dest="debug", + help="Enable debug output", + action="store_true", + default=False) + parser.add_option("", + "--default-comment", + dest="default_comment", + help="Default comment to use, default: %default", + default="", + metavar="COMMENT") + parser.add_option("", + "--default-karma", + dest="default_karma", + help="Default karma to use, default: %default", + default="", + metavar="KARMA") + parser.add_option("", + "--fas-username", + dest="fas_username", + help="FAS username", + default=None) + parser.add_option("", + "--no-ignore-own", + dest="ignore_own", + help="Do not ignore own updates.", + action="store_false", + default=True) + parser.add_option("", + "--include-commented", + dest="include_commented", + help="Also ask for more comments on updates that " + "already got a comment from you, this is " + "enabled if patterns are provided", + action="store_true", + default=False) + parser.add_option("", + "--include-ignored", + dest="include_ignored", + help="Also ask for comments on updates that have " + "been ignored previously.", + action="store_true", + default=False) + parser.add_option("", + "--installed-max-days", + dest="installed_max_days", + help="Only check packages installed within the last " + "XX days, default: %default", + metavar="DAYS", + default=28, + type="int") + parser.add_option("", + "--installed-min-days", + dest="installed_min_days", + help="Only check packages installed for at least " + "XX days, default: %default", + metavar="DAYS", + default=0, + type="int") + parser.add_option("", + "--list-rpms-only", + dest="list_rpms_only", + help="Only list affected rpms", + action="store_true", + default=False) + parser.add_option("", + "--no-skip-empty-comment", + dest="skip_empty_comment", + help="Do not skip update if comment is empty", + action="store_false", + default=True) + parser.add_option("", + "--product", + dest="product", + help="product to query Bodhi for, 'F' for Fedora, " + "'EL-' for EPEL, default: %default", + default="F") + parser.add_option("", + "--releasever", + dest="releasever", + help="releasever to query Bodhi for, " + "default: releasever from dnf or yum", + default=None) + parser.add_option("", + "--retries", + dest="retries", + help="Number if retries when submitting a comment " + "in case of an error, default: %default", + default=3, + type="int") + parser.add_option("", + "--wrap-bugs", + dest="wrap_bugs", + help="Apply line-wrapping to bugs", + action="store_true", + default=False) + parser.add_option("", + "--wrap-rpms", + dest="wrap_rpms", + help="Apply line-wrapping to list of installed rpms", + action="store_true", + default=False) + parser.add_option("", + "--wrap-width", + dest="wrap_width", + help="Width to use for line wrapping of updates, " + "default: %default", + default=80, + type="int") (self.options, args) = parser.parse_args() @@ -362,9 +487,12 @@ 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 + # 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) + bc = BodhiClient(username=self.options.fas_username, + useragent="Fedora Easy Karma/GIT", + retries=self.options.retries) self.bc = bc # Bodhi is too slow for our queries, therefore wait longer bc.timeout = 300 @@ -494,12 +622,20 @@ class FedoraEasyKarma(object): processed_updates.append(update) affected_builds = [b["nvr"] for b in update["builds"]] - installed_pkgs = list(itertools.chain(*[installed_testing_builds[b] for b in affected_builds if b in installed_testing_builds])) + installed_pkgs = list( + itertools.chain(*[installed_testing_builds[b] for + b in affected_builds if + b in installed_testing_builds]) + ) if args: - if not self.match_any(args, [["%(name)s" % pkg for pkg in installed_pkgs], - # remove version and release - ["-".join(b.split("-")[:-2]) for b in affected_builds]]): + installed_pkgs_names = ["%(name)s" % pkg for pkg in + installed_pkgs] + # remove version and release + affected_builds_names = ["-".join(b.split("-")[:-2]) for b + in affected_builds] + if not self.match_any(args, [installed_pkgs_names, + affected_builds_names]): continue installed_rpms = [ self.format_rpm(pkg) for pkg in installed_pkgs] @@ -532,7 +668,8 @@ class FedoraEasyKarma(object): result = self.send_comment(bc, update, comment, karma) if not result[0]: - self.warning("Comment not submitted: %s" % result[1]) + self.warning("Comment not submitted: %s" % + result[1]) else: print "skipped because of empty comment" elif karma == "i": @@ -579,7 +716,8 @@ class FedoraEasyKarma(object): 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'])) + self.info("Fetching updates page {} of {}".format( + next_page, result['pages'])) result = bodhi_client.query(page=next_page, **query_args) self.debug("Queried Bodhi page %s" % next_page, False) updates.extend(result['updates']) |