summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Maas <opensource@till.name>2011-08-23 18:03:54 +0200
committerTill Maas <opensource@till.name>2011-08-23 18:03:54 +0200
commitb0706146b2f9a5a88878b8af571f94b6d21c7155 (patch)
tree7c29139f3c0cddb844013f5a79aaa9d80596a5ee
parentadba30551f317092dc775a5a74ebf816e7f03e82 (diff)
downloadfedora-easy-karma-b0706146b2f9a5a88878b8af571f94b6d21c7155.tar.gz
fedora-easy-karma-b0706146b2f9a5a88878b8af571f94b6d21c7155.tar.xz
fedora-easy-karma-b0706146b2f9a5a88878b8af571f94b6d21c7155.zip
Allow to ignore updates without commenting
-rwxr-xr-xfedora-easy-karma.py46
1 files changed, 41 insertions, 5 deletions
diff --git a/fedora-easy-karma.py b/fedora-easy-karma.py
index 64045fe..92fbec2 100755
--- a/fedora-easy-karma.py
+++ b/fedora-easy-karma.py
@@ -205,6 +205,7 @@ class FedoraEasyKarma(object):
"-1 : Update breaks something or does not fix a bug it is supposed to\n"
" 0 : The update has not been tested much or at all\n"
" 1 : The update seems not to break anything new\n"
+ " i : Ignore the update in the future\n"
"All other inputs will skip the update.\n"
"You can use <CTRL>-<D> on an empty prompt to exit\n"
"If you use a default comment, '<CTRL>-<X> <backspace>' can be used to delete the default comment to easily enter a custom one.\n"
@@ -220,14 +221,15 @@ class FedoraEasyKarma(object):
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-cachedir", dest="bodhi_cachedir", help="Directory to store bodhi cache, default: %default", default="~/.fedora-easy-karma")
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("", "--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)
@@ -268,7 +270,7 @@ class FedoraEasyKarma(object):
release = "%s%s" % (self.options.product, self.options.releasever)
- self.options.bodhi_cachedir = os.path.expanduser(self.options.bodhi_cachedir)
+ self.options.datadir = os.path.expanduser(self.options.datadir)
@@ -291,7 +293,7 @@ class FedoraEasyKarma(object):
else:
installed_testing_builds[build] = [pkg]
- cachefile_name = os.path.join(self.options.bodhi_cachedir, "bodhi-cache-%s.cpickle" % release)
+ cachefile_name = os.path.join(self.options.datadir, "bodhi-cache-%s.cpickle" % release)
if self.options.bodhi_cached:
self.debug("reading bodhi cache")
try:
@@ -315,7 +317,7 @@ class FedoraEasyKarma(object):
if self.options.bodhi_update_cache:
try:
- os.makedirs(self.options.bodhi_cachedir)
+ os.makedirs(self.options.datadir)
except OSError:
# only pass for Errno 17: file exists
self.debug("makedirs OSError", update_timestamp=False)
@@ -325,6 +327,16 @@ class FedoraEasyKarma(object):
outfile.close()
+ ignorefile_name = os.path.join(self.options.datadir, "ignore.cpickle")
+ previously_ignored_updates = []
+ self.debug("reading ignore file %s" % ignorefile_name)
+ try:
+ ignorefile = open(ignorefile_name, "rb")
+ previously_ignored_updates = pickle.load(ignorefile)
+ ignorefile.close()
+ except IOError, ioe:
+ self.debug("Cannot access ignore file: %s" % ignorefile_name)
+
self.debug("post processing bodhi query")
# reduce to unapproved critpath updates. Cannot query for this in
# python-fedora 0.3.20 and might not want to do to keep the cache
@@ -341,10 +353,19 @@ class FedoraEasyKarma(object):
self.debug("starting feedback loop")
# multiple build can be grouped together in one update, only ask once per update
processed_updates = []
+ ignored_updates = []
builds = testing_builds.keys()
builds.sort()
for build in builds:
update = testing_builds[build]
+
+ # Do not query for previously ignored updates
+ # Store update title to save these to a file
+ if not self.options.include_ignored and update.title in previously_ignored_updates:
+ print "ignored: %s" % update.title
+ ignored_updates.append(update.title)
+ continue
+
if update not in processed_updates and build in installed_testing_builds:
processed_updates.append(update)
@@ -366,7 +387,7 @@ class FedoraEasyKarma(object):
if self.already_commented(update, self.options.fas_username):
print "!!! already commented by you !!!"
try:
- karma = self.raw_input("Comment? -1/0/1 ->karma, other -> skip> ", default=self.options.default_karma, add_to_history=False)
+ karma = self.raw_input("Comment? -1/0/1 -> karma, 'i' -> ignore, other -> skip> ", default=self.options.default_karma, add_to_history=False)
if karma in ["-1", "0", "1"]:
comment = self.raw_input("Comment> ", default=self.options.default_comment)
if comment or not self.options.skip_empty_comment:
@@ -375,12 +396,27 @@ class FedoraEasyKarma(object):
self.warning("Comment not submitted: %s" % result[1])
else:
print "skipped because of empty comment"
+ elif karma == "i":
+ ignored_updates.append(update.title)
+ print "ignored as requested"
+
except EOFError:
sys.stdout.write("\nExiting on User request\n")
sys.exit(0)
else:
print "\n".join(installed_rpms)
+ # store ignored_updates
+ try:
+ os.makedirs(self.options.datadir)
+ except OSError:
+ # :TODO: only pass for Errno 17: file exists
+ self.debug("makedirs OSError", update_timestamp=False)
+ self.debug("writing ignore file")
+ outfile = open(ignorefile_name, "wb")
+ pickle.dump(ignored_updates, outfile, -1)
+ outfile.close()
+
def already_commented(self, update, user):
for comment in update["comments"]: