[packagedb-cli] Fix the --nocolor option
by Pierre-YvesChibon
commit 691cbd4a9507653267a04593e69f8a7706e947ba
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Thu Jun 16 13:25:15 2011 +0200
Fix the --nocolor option
Make sure that no characters are added when printing the output into a file
pkgdb.py | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb.py
index bb9250f..8635918 100755
--- a/pkgdb.py
+++ b/pkgdb.py
@@ -45,7 +45,9 @@ elif '--verbose' in sys.argv:
log.setLevel(logging.INFO)
if '--nocolor' in sys.argv:
- red = reset
+ red = " "
+ bold = " "
+ reset = " "
cmdlist = ['acl', 'list', 'request', 'update', 'orphan']
actionlist = ['watchbugzilla', 'watchcommits', 'commit', 'approveacls']
12 years, 11 months
[packagedb-cli] Proposed --nocolor argument.
by Pierre-YvesChibon
commit d9a787912bf42d877a129fb3f712a2d4f1b4c671
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Wed Jun 15 15:32:37 2011 +0200
Proposed --nocolor argument.
pkgdb.py | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb.py
index dd83c7a..bb9250f 100755
--- a/pkgdb.py
+++ b/pkgdb.py
@@ -44,6 +44,9 @@ if '--debug' in sys.argv:
elif '--verbose' in sys.argv:
log.setLevel(logging.INFO)
+if '--nocolor' in sys.argv:
+ red = reset
+
cmdlist = ['acl', 'list', 'request', 'update', 'orphan']
actionlist = ['watchbugzilla', 'watchcommits', 'commit', 'approveacls']
@@ -833,6 +836,8 @@ def setup_parser():
parser.add_argument('--password', dest="password",
help="FAS password (if not provided, will be asked " \
"later)")
+ parser.add_argument('--nocolor', action='store_true',
+ help="Removes color from output")
parser.add_argument('--verbose', action='store_true',
help="Gives more info about what's going on")
parser.add_argument('--debug', action='store_true',
12 years, 11 months
[packagedb-cli] Add gitignore file
by Pierre-YvesChibon
commit 565d9773a10fddd25aa0660ec6eaf1c208d45324
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Wed Jun 15 15:55:05 2011 +0200
Add gitignore file
.gitignore | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a13b289
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.pyc
+\[PATCH\]*
+00*
12 years, 11 months
[packagedb-cli] Fix style
by Pierre-YvesChibon
commit 20a258546c2dc70da6e6f0098a8c3fa7512400c5
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Wed Jun 15 15:54:04 2011 +0200
Fix style
pkgdb.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb.py
index 777d959..dd83c7a 100755
--- a/pkgdb.py
+++ b/pkgdb.py
@@ -834,9 +834,9 @@ def setup_parser():
help="FAS password (if not provided, will be asked " \
"later)")
parser.add_argument('--verbose', action='store_true',
- help="give more info about what's going on")
+ help="Gives more info about what's going on")
parser.add_argument('--debug', action='store_true',
- help="output bunches of debugging info")
+ help="Outputs bunches of debugging info")
return parser
12 years, 11 months
[packagedb-cli] Fix indentation of group account, Fix#3
by Pierre-YvesChibon
commit c547b54343b2a583463fd49a5a9abbc49e65b6ee
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Wed Jun 15 15:18:08 2011 +0200
Fix indentation of group account, Fix#3
pkgdb.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb.py
index 4fa2f95..777d959 100755
--- a/pkgdb.py
+++ b/pkgdb.py
@@ -482,7 +482,7 @@ def get_package_info(packagename, branch=None, pending=False,
# print group information
print "{0}Group:".format(" " * 8)
for group in collection['groups']:
- tmp = " " * 8 + group['groupname']
+ tmp = " " * 10 + group['groupname']
prevstring = group['groupname']
info = _get_group_info(group, pkgdbinfo['statusMap'],
tmp, prevstring,
12 years, 11 months
[packagedb-cli] _get_group_info return None if no present ACLs present
by Pierre-YvesChibon
commit 3f281e2a32216cbb1b44480732de4b36aee37703
Author: Stanislav Ochotnicky <sochotnicky(a)redhat.com>
Date: Wed Jun 15 09:09:52 2011 -0400
_get_group_info return None if no present ACLs present
If user used to have ACLs on the package but he/she doesn't have them
anymore pkgdb shouldn't show him (it will display blank line with name
anyway)
pkgdb.py | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb.py
index e86f2ba..4fa2f95 100755
--- a/pkgdb.py
+++ b/pkgdb.py
@@ -104,11 +104,13 @@ def _get_group_info(group, statusmap, tmpstring="", prevstring="",
true then only statuscode corresponding to "awaiting review" are
returned
"""
+ has_acl = False
for acl in ['watchbugzilla', 'watchcommits', 'commit',
'approveacls']:
tmpstring = tmpstring + " " * (24 - len(tmpstring))
if acl in group['aclOrder'].keys() and \
group['aclOrder'][acl] is not None:
+ has_acl = True
aclout = statusmap[str(
group['aclOrder'][acl]['statuscode'])]
tmpstring = tmpstring + aclout + " " * (16 - len(aclout))
@@ -116,6 +118,11 @@ def _get_group_info(group, statusmap, tmpstring="", prevstring="",
else:
tmpstring = tmpstring + " " * 16
prevstring = ""
+ if not has_acl:
+ # return None if there are no ACLs (it used to have ACLs in
+ # past)
+ return
+
if pending and "awaiting" in tmpstring.lower():
return tmpstring.rstrip()
elif pending:
12 years, 11 months
[packagedb-cli] Fix version in last builds
by Pierre-YvesChibon
commit b6d28623e4df70d5751f0c7409eb53d5f84df039
Author: Stanislav Ochotnicky <sochotnicky(a)redhat.com>
Date: Wed Jun 15 08:42:53 2011 -0400
Fix version in last builds
version variable is global for version of pkgdb. nvr should be correct build nvr.
pkgdb.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb.py
index 0a01398..e86f2ba 100755
--- a/pkgdb.py
+++ b/pkgdb.py
@@ -193,7 +193,7 @@ def _get_last_build(packagename, tag):
" " * 5,
build['completion_time'].split(" ")[0],
build['owner_name'],
- version,
+ nvr,
tag)
12 years, 11 months
[packagedb-cli] Layout of help messages
by Pierre-YvesChibon
commit 51b031973766f68d82838ae4ca3cd5bb3ef22be8
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Tue Jun 14 11:13:05 2011 +0200
Layout of help messages
pkgdb.py | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb.py
index 1248ebb..0a01398 100755
--- a/pkgdb.py
+++ b/pkgdb.py
@@ -776,7 +776,7 @@ def setup_action_parser(action, last_args=None):
"simple pattern")
parser.add_argument('branch', default='devel', nargs="?",
help="Branch of the package to orphan " \
- "(default: devel, can be: all)")
+ "(default: 'devel', can be: 'all')")
parser.add_argument('--retire', action="store_true", default=False,
help="Retire the given package")
parser.add_argument('--all', action="store_true", default=False,
@@ -786,22 +786,22 @@ def setup_action_parser(action, last_args=None):
parser.add_argument('package', help="Name of the package")
parser.add_argument("action",
help="Request a specific ACL for this package " \
- "(actions are {0},all)".format(", ".join(actionlist)))
+ "(actions are '{0}', 'all')".format("', '".join(actionlist)))
parser.add_argument('branch', default='devel', nargs="?",
help="Branch of the package for which the ACL is " \
- "requested (default: devel, can be: all)")
+ "requested (default: 'devel', can be: 'all')")
elif action == "update":
parser.add_argument('package', help="Name of the package")
parser.add_argument("action",
help="Request a specific ACL for this package " \
- "(actions are {0},all)".format(", ".join(actionlist)))
+ "(actions are: '{0}', 'all')".format("', '".join(actionlist)))
parser.add_argument('user',
help="FAS username of the person who requested ACL " \
"on this package")
parser.add_argument('branch', default='devel', nargs="?",
help="Branch of the package for which the ACL is " \
- "requested (default: devel, can be: all)")
+ "requested (default: 'devel', can be: 'all')")
parser.add_argument('--approve', action="store_true", default=False,
help="Approve the requested ACL")
parser.add_argument('--deny', action="store_true", default=False,
12 years, 11 months
[packagedb-cli] Revert "Revise the orphan --all procedure to reduce the number of call to pkgdb."
by Pierre-YvesChibon
commit 141db61f5b73e2c71ee26d530a9e44aa6e5fd6e2
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Tue Jun 14 10:54:33 2011 +0200
Revert "Revise the orphan --all procedure to reduce the number of call to pkgdb."
This reverts commit 25a34ed0119b3604f50af89b383b12af69a92a4f.
This method is not yet available in PackageDB. We should only apply this
when PackageDB has been adjusted.
pkgdb.py | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb.py
index 76a0800..1248ebb 100755
--- a/pkgdb.py
+++ b/pkgdb.py
@@ -662,12 +662,11 @@ def orphan_package(packagename, branch='devel', allpkgs=False,
log.debug("Orphan all packages")
if branch == "all":
log.debug("Orphan in all branches")
- pkgdbclient.change_owner(pkgdbclient.username, 'orphan',
- "*")
+ branches = _get_active_branches()
+ for branch in branches:
+ _orphan_one_package(pkg, branch, username, password)
else:
- log.debug("Orphan branch {0}".format(branch))
- pkgdbclient.change_owner(pkgdbclient.username, 'orphan',
- "*", branch)
+ _orphan_one_package(pkg, branch, username, password)
elif re.match(packagename, pkg):
log.debug("motif : {0}".format(motif))
log.debug("package : {0}".format(pkg))
12 years, 11 months
[packagedb-cli] Refactor list and acl
by Pierre-YvesChibon
commit 7d4723290b5ec248ed541a6280b679840f720d68
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Tue Jun 14 10:51:34 2011 +0200
Refactor list and acl
- Add an option to list to print only the name of the package (without the description).
- Allow to see acl for all branches if asked
pkgdb.py | 58 ++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 42 insertions(+), 16 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb.py
index 51d7e6e..76a0800 100755
--- a/pkgdb.py
+++ b/pkgdb.py
@@ -283,7 +283,7 @@ def _answer_acl(action, user, packagename, answer, branch):
" so?".format(answer)
-def get_packages(motif=None):
+def get_packages(motif=None, name_only=False):
"""
Retrieve the list of all packages in packagedb.
This list can be reduced using a motif (pattern) which is optional.
@@ -295,6 +295,7 @@ def get_packages(motif=None):
:karg motif the motif used to search for the packages. If the motif
does not end with a "*", one is added.
+ :karg name_only if true only the name of the package is returned.
"""
if motif is not None:
log.info("Query packages starting with: {0}".format(motif))
@@ -310,13 +311,17 @@ def get_packages(motif=None):
req_params={'tg_paginate_limit': 0})
print pkgdbinfo['title']
for pkg in pkgdbinfo['packages']:
- print " ", pkg['name'], " " * (30 - len(pkg['name'])), \
- pkg['summary']
+ out = " " + pkg['name']+ " " * (33 - \
+ len(pkg['name'])) + \
+ pkg['summary']
+ if name_only:
+ out = " ", pkg['name']
+ print out
print "Total: {0} packages".format(len(pkgdbinfo['packages']))
log.info(pkgdbinfo.keys())
-def get_orphaned_packages(motif=None, eol=False):
+def get_orphaned_packages(motif=None, eol=False, name_only=False):
"""
Retrieve the list of orphans packages.
@@ -328,6 +333,7 @@ def get_orphaned_packages(motif=None, eol=False):
:karg motif the motif used to search for the packages. If the motif
does not end with a "*", one is added.
:karg eol if true only the EOL packages are returned.
+ :karg name_only if true only the name of the package is returned.
"""
url = '/acls/orphans/'
if eol is not None and eol:
@@ -350,13 +356,17 @@ def get_orphaned_packages(motif=None, eol=False):
print pkgdbinfo.keys()
print pkgdbinfo['title']
for pkg in pkgdbinfo['pkgs']:
- print " ", pkg['name'], " " * (30 - len(pkg['name'])), \
- pkg['summary']
+ out = " " + pkg['name']+ " " * (33 - \
+ len(pkg['name'])) + \
+ pkg['summary']
+ if name_only:
+ out = " " + pkg['name']
+ print out
print "Total: {0} packages".format(len(pkgdbinfo['pkgs']))
log.info(pkgdbinfo.keys())
-def get_packager_info(packager, output=True):
+def get_packager_info(packager, output=True, name_only=False):
"""
Retrieve the list of all the package for which the given packager
has
@@ -368,6 +378,9 @@ def get_packager_info(packager, output=True):
(default options)
:arg packager name of the packager for who to retrieve info
+ :karg output if False the packager information are not printed to
+ std.out
+ :karg name_only if true only the name of the package is returned.
"""
log.info("Query pkgdb for packager: {0}".format(packager))
pkgdbinfo = pkgdbclient.send_request('/users/packages/{0}'.format(
@@ -381,10 +394,16 @@ def get_packager_info(packager, output=True):
if 'pkgs' in pkgdbinfo:
for pkg in pkgdbinfo['pkgs']:
log.info(pkg.keys())
+ log.info(name_only)
pkgs.append(pkg['name'])
if output:
- print " ", pkg['name'], " " * (30 - len(pkg['name'])), \
+ out = " " + pkg['name']+ " " * (33 - \
+ len(pkg['name'])) + \
pkg['summary']
+ if name_only:
+ out = " " + pkg['name']
+ log.info(out)
+ print out
#pkgdbinfo['statusMap'][pkg['statuscode']]
if output:
print "Total: {0} packages".format(len(pkgdbinfo['pkgs']))
@@ -431,8 +450,9 @@ def get_package_info(packagename, branch=None, pending=False,
'component': packagename})
print "{0} bugs open (new, assigned, needinfo)".format(len(bugbz))
for collection in pkgdbinfo['packageListings']:
- if branch is None or branch == \
- collection['collection']['branchname']:
+ if branch is None \
+ or branch == "all" \
+ or branch == collection['collection']['branchname']:
# Retrieve ACL information
print "{0}{1}{2}{3}Owner:{4}{5}".rstrip().format(
@@ -718,7 +738,7 @@ def setup_action_parser(action, last_args=None):
if action == 'acl':
parser.add_argument('package', help="Name of the package to query")
parser.add_argument('branch', default='devel', nargs="?",
- help="Branch of the package to query")
+ help="Branch of the package to query (default: 'devel', can be: 'all')")
parser.add_argument('--pending', action="store_true", default=False,
help="Display only ACL awaiting review")
parser.add_argument('--noextra', action="store_false", default=True,
@@ -730,6 +750,9 @@ def setup_action_parser(action, last_args=None):
dest='all', help="List all packages starting " \
"with the given pattern (without pattern this may " \
"take a while)")
+ parser.add_argument('--nameonly', action="store_true", default=False,
+ dest='name_only',
+ help="Returns only the name of the package (without the description)")
parser.add_argument('--orphaned', action="store_true", default=False,
dest='orphaned', help="List all orphaned packages")
parser.add_argument('--eol', action="store_true", default=False,
@@ -831,22 +854,25 @@ def main():
log.info("package : {0}".format(args.package))
log.info("branch : {0}".format(args.branch))
#log.info("approve : {0}".format(args.approve))
- get_package_info(args.package, args.branch, args.pending,
- args.noextra)
+ get_package_info(args.package, branch=args.branch,
+ pending=args.pending, extra=args.noextra)
elif action == "list":
log.info("pattern : {0}".format(args.pattern))
log.info("all : {0}".format(args.all))
+ log.info("orphaned: {0}".format(args.orphaned))
log.info("user : {0}".format(args.username))
+ log.info("name only: {0}".format(args.name_only))
if(args.all is not None and args.all):
log.info(args)
get_packages("*")
elif (args.orphaned is not None and args.orphaned):
- get_orphaned_packages(args.pattern, args.eol)
+ get_orphaned_packages(args.pattern, eol=args.eol,
+ name_only=args.name_only)
elif (args.username is not None and args.username):
- get_packager_info(args.username)
+ get_packager_info(args.username, name_only=args.name_only)
elif (args.pattern is not None):
- get_packages(args.pattern)
+ get_packages(args.pattern, name_only=args.name_only)
else:
raise argparse.ArgumentTypeError(
"Not enough argument given")
12 years, 11 months