diff options
-rwxr-xr-x | cnucnu.py | 6 | ||||
-rw-r--r-- | lib/cnucnu/checkshell.py | 13 | ||||
-rw-r--r-- | lib/cnucnu/config.py | 20 |
3 files changed, 20 insertions, 19 deletions
@@ -78,7 +78,7 @@ if __name__ == '__main__': from optparse import OptionParser parser = OptionParser() - parser.add_option("", "--check", dest="action", help="check URL and regex interactively", action="store_const", const="check") + parser.add_option("", "--shell", dest="action", help="Interactive shell", action="store_const", const="shell") parser.add_option("", "--config", dest="config_filename", help="config_filename, e.g. for bugzilla credentials", default="./cnucnu.ini") parser.add_option("", "--create-bugs", dest="action", help="file bugs for outdated packages", action="store_const", const="create-bugs") parser.add_option("", "--fm-outdated-all", dest="action", help="compare all packages in rawhide with freshmeat", action="store_const", const="fm-outdated-all") @@ -86,7 +86,7 @@ if __name__ == '__main__': (options, args) = parser.parse_args() conf = config.Config(options.config_filename) - if options.action == "check": + if options.action == "shell": shell = CheckShell(config=conf) while True: try: @@ -97,7 +97,7 @@ if __name__ == '__main__': print repr(ex) break elif options.action == "create-bugs": - bugzilla_config = conf.get_bugzilla_config() + bugzilla_config = conf.bugzilla_config br = BugzillaReporter(**bugzilla_config) pl = PackageList() diff --git a/lib/cnucnu/checkshell.py b/lib/cnucnu/checkshell.py index 0cddbd1..9e408f4 100644 --- a/lib/cnucnu/checkshell.py +++ b/lib/cnucnu/checkshell.py @@ -46,8 +46,11 @@ class CheckShell(cmd.Cmd): @property def br(self): if not self._br: - bugzilla_config = self.config.get_bugzilla_config() - self._br = BugzillaReporter(**bugzilla_config) + try: + bugzilla_config = self.config.bugzilla_config + self._br = BugzillaReporter(**bugzilla_config) + except: + print "Cannot query bugzilla, maybe config is faulty or missing" return self._br def update_prompt(self): @@ -119,16 +122,16 @@ class CheckShell(cmd.Cmd): else: status = "" print "Repo Version: %s%s" % (self.package.repo_version, status) - if self.package.upstream_newer: + if self.package.upstream_newer and self.br: bugs = self.br.get_open(self.package) if bugs: for bug in bugs: - print "Open Bug:", "https://bugzilla.redhat.com/show_bug.cgi?id=%s" % bug.bug_id + print "Open Bug:", "https://bugzilla.redhat.com/show_bug.cgi?id=%s %s:%s" % (bug.bug_id, bug.bug_status, bug.summary) bugs = self.br.get_bug(self.package) if bugs: for bug in bugs: - print "Closed Bug:", "https://bugzilla.redhat.com/show_bug.cgi?id=%s" % bug.bug_id + print "Matching Bug:", "https://bugzilla.redhat.com/show_bug.cgi?id=%s %s:%s" % (bug.bug_id, bug.bug_status, bug.summary) except Exception, e: print e return stop diff --git a/lib/cnucnu/config.py b/lib/cnucnu/config.py index c13a2c8..d1620ad 100644 --- a/lib/cnucnu/config.py +++ b/lib/cnucnu/config.py @@ -28,15 +28,13 @@ class Config(object): ini.readfp(file) file.close() - self.bugzilla_username = ini.get("cnucnu", "bugzilla username") - self.bugzilla_password = ini.get("cnucnu", "bugzilla password") - self.bugzilla_url = ini.get("cnucnu", "bugzilla url") - self.bugzilla_product = ini.get("cnucnu", "bugzilla product") - - def get_bugzilla_config(self): - config = {} - for attr in dir(self): - if attr.startswith("bugzilla_"): - config[attr] = getattr(self, attr) - return config + self._bugzilla_config = {} + @property + def bugzilla_config(self): + if not self._bugzilla_config: + for name, value in self.ini.items("cnucnu"): + bugzilla_prefix = "bugzilla " + if name.startswith(bugzilla_prefix): + self._bugzilla_config["bugzilla_"+name[len(bugzilla_prefix):]] = value + return self._bugzilla_config |