commit 63bc7da77cfe6c613a87edc042f2844409b8cb1b Author: Pierre-Yves Chibon pingou@pingoured.fr Date: Wed Mar 5 16:54:07 2014 +0100
Instance the koji and bz client when we need them and rely on argparse for the nocolor option
pkgdb2-cli | 34 ++++++++++++++++++++-------------- 1 files changed, 20 insertions(+), 14 deletions(-) --- diff --git a/pkgdb2-cli b/pkgdb2-cli index b738a4f..c3447eb 100755 --- a/pkgdb2-cli +++ b/pkgdb2-cli @@ -30,14 +30,14 @@ import fedora_cert import timeit
version = '2.0' -kojiclient = koji.ClientSession( - 'http://koji.fedoraproject.org/kojihub', {}) +KOJI_HUB = 'http://koji.fedoraproject.org/kojihub' +RH_BZ_API = 'https://bugzilla.redhat.com/xmlrpc.cgi' + pkgdbclient = PkgDB('http://209.132.184.188/') fasclient = AccountSystem('https://admin.fedoraproject.org/accounts') -bzclient = RHBugzilla(url='https://bugzilla.redhat.com/xmlrpc.cgi') -bold = "\033[1m" -red = "\033[0;31m" -reset = "\033[0;0m" +BOLD = "\033[1m" +RED = "\033[0;31m" +RESET = "\033[0;0m"
# Initial simple logging stuff logging.basicConfig() @@ -50,11 +50,6 @@ if '--debug' in sys.argv: elif '--verbose' in sys.argv: log.setLevel(logging.INFO)
-if '--nocolor' in sys.argv: - red = "" - bold = "" - reset = "" - if '--test' in sys.argv: print "Testing environment" fasclient = AccountSystem( @@ -146,6 +141,8 @@ def _get_last_build(packagename, tag): list of available tag. """ log.debug("Search last build for {0} in {1}".format(packagename, tag)) + kojiclient = koji.ClientSession(KOJI_HUB, {}) + data = kojiclient.getLatestBuilds( tag, package=packagename) versions = [] @@ -381,6 +378,8 @@ def do_acl(args): log.info("package : {0}".format(args.package)) log.info("branch : {0}".format(args.branch)) #log.info("approve : {0}".format(args.approve)) + bzclient = RHBugzilla(url=RH_BZ_API) + if args.branch == 'all': args.branch = None output = pkgdbclient.get_package(args.package, branch=args.branch) @@ -401,13 +400,13 @@ def do_acl(args): continue owner = pkg['point_of_contact'] if owner == 'orphan': - owner = red + owner + reset + owner = RED + owner + RESET
# Retrieve ACL information print "\n{0}{1}{2}{3}Point of Contact:{4}{5}".rstrip().format( - red + bold, + RED + BOLD, pkg['collection']['branchname'], - reset, + RESET, " " * (8 - len(pkg['collection']['branchname'])), " " * 5, owner) @@ -629,6 +628,13 @@ def main(): parser = setup_parser() # Parse the commandline arg = parser.parse_args() + + if arg.nocolor: + global RED, BOLD, RESET + RED = "" + BOLD = "" + RESET = "" + arg.func(arg)
packagedb-cli-commits@lists.stg.fedorahosted.org