[packagedb-cli] Bump the version to 2.3.1 in the setup.py file
by Pierre-YvesChibon
commit 6f61292caa3e27c50c79027c3802463e9a9cebc6
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Jun 12 14:50:46 2014 +0200
Bump the version to 2.3.1 in the setup.py file
setup.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/setup.py b/setup.py
index be5cb79..ab5a733 100644
--- a/setup.py
+++ b/setup.py
@@ -8,7 +8,7 @@ from setuptools import setup
setup(
name='packagedb-cli',
description='A command line tool to access the Fedora Package Database.',
- version='2.2',
+ version='2.3.1',
license='GPLv2+',
download_url='https://fedorahosted.org/releases/p/a/packagedb-cli/',
url='https://fedorahosted.org/packagedb-cli/',
9 years, 11 months
[packagedb-cli] If the branch is orphaned there are sometime no ACLs at all
by Pierre-YvesChibon
commit 75e7ff5e99476f8900ca666490b12a1a6a2c8f80
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Jun 12 14:48:43 2014 +0200
If the branch is orphaned there are sometime no ACLs at all
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1108634
pkgdb2_cli.py | 37 ++++++++++++++++++++-----------------
1 files changed, 20 insertions(+), 17 deletions(-)
---
diff --git a/pkgdb2_cli.py b/pkgdb2_cli.py
index 20938b2..983bd14 100644
--- a/pkgdb2_cli.py
+++ b/pkgdb2_cli.py
@@ -391,24 +391,27 @@ def do_acl(args):
# print ACL information
print "{0}ACLs:".format(" " * 8)
- acls = _get_acls_info(pkg['acls'])
- users = sorted(acls, key=lambda user: user.replace('group::', ''))
- for user in users:
- if user.startswith('group::'):
- tmp = " " * 3 + user
- else:
- tmp = " " * 10 + user
- tmp = tmp + " " * (24 - len(tmp))
- for acl_title in ["watchbugzilla", "watchcommits",
- "commit", "approveacls"]:
- #print '\n', acl_title
- if acl_title in acls[user]:
- aclout = acls[user][acl_title]
- tmp = tmp + aclout + " " * (16 - len(aclout))
+ if 'acls' in pkg:
+ acls = _get_acls_info(pkg['acls'])
+ users = sorted(acls, key=lambda user: user.replace('group::', ''))
+ for user in users:
+ if user.startswith('group::'):
+ tmp = " " * 3 + user
else:
- tmp = tmp + " " * 16
- if tmp is not None and tmp.strip() != "":
- print tmp
+ tmp = " " * 10 + user
+ tmp = tmp + " " * (24 - len(tmp))
+ for acl_title in ["watchbugzilla", "watchcommits",
+ "commit", "approveacls"]:
+ #print '\n', acl_title
+ if acl_title in acls[user]:
+ aclout = acls[user][acl_title]
+ tmp = tmp + aclout + " " * (16 - len(aclout))
+ else:
+ tmp = tmp + " " * 16
+ if tmp is not None and tmp.strip() != "":
+ print tmp
+ else:
+ print ' No ACLs found'
# print the last build
if args.extra:
9 years, 11 months
[packagedb-cli] Adjust tests a little to make them more flexible
by Pierre-YvesChibon
commit 427be946fe27bb542b4cbc1d58c1c1ad86ea07b2
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue Jun 10 11:44:44 2014 +0200
Adjust tests a little to make them more flexible
test.py | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/test.py b/test.py
index 36305b8..e2d3f75 100644
--- a/test.py
+++ b/test.py
@@ -129,7 +129,7 @@ class TestPkgdDB(unittest.TestCase):
sorted(out.keys()),
['acls', 'output', 'page', 'page_total'])
self.assertTrue(len(out['acls']) >= 239)
- self.assertEqual(out['page_total'], 1)
+ self.assertEqual(out['page_total'], 2)
out = self.pkgdb.get_packager_acls('pingou', page=3)
self.assertEqual(
@@ -149,7 +149,7 @@ class TestPkgdDB(unittest.TestCase):
self.assertEqual(
sorted(out.keys()),
['acls_count', 'output', 'page', 'page_total'])
- self.assertTrue(out['acls_count'] >= 804)
+ self.assertTrue(out['acls_count'] >= 750)
self.assertEqual(out['page_total'], 1)
out = self.pkgdb.get_packager_acls('pingou', poc=False, count=True)
@@ -168,7 +168,7 @@ class TestPkgdDB(unittest.TestCase):
self.assertEqual(
sorted(out['master'].keys()),
['co-maintainer', 'point of contact'])
- self.assertTrue(out['master']['point of contact'] >= 60)
+ self.assertTrue(out['master']['point of contact'] >= 50)
def test_get_packagers(self):
''' Test the get_packagers function. '''
9 years, 11 months
[packagedb-cli] Fix the tests to account for the presence of the `acls` key even if it's empty
by Pierre-YvesChibon
commit 972922f3c0d75ae7bd8d0a4dd35cfce9025f4558
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed Jun 4 18:22:15 2014 +0200
Fix the tests to account for the presence of the `acls` key even if it's empty
test.py | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/test.py b/test.py
index c693fff..36305b8 100644
--- a/test.py
+++ b/test.py
@@ -188,7 +188,7 @@ class TestPkgdDB(unittest.TestCase):
self.assertEqual(out['packages'][0]['name'], 'guacamole-client')
self.assertEqual(
sorted(out['packages'][0].keys()),
- ['creation_date', 'description', 'name', 'review_url',
+ ['acls', 'creation_date', 'description', 'name', 'review_url',
'status', 'summary', 'upstream_url'])
self.assertEqual(out['packages'][1]['name'], 'guacamole-common')
self.assertEqual(out['page'], 1)
@@ -202,7 +202,7 @@ class TestPkgdDB(unittest.TestCase):
self.assertEqual(out['packages'][0]['name'], 'guacamole-common')
self.assertEqual(
sorted(out['packages'][0].keys()),
- ['creation_date', 'description', 'name', 'review_url',
+ ['acls', 'creation_date', 'description', 'name', 'review_url',
'status', 'summary', 'upstream_url'])
self.assertEqual(out['packages'][1]['name'], 'guacamole-ext')
self.assertEqual(out['page'], 1)
@@ -216,7 +216,7 @@ class TestPkgdDB(unittest.TestCase):
self.assertEqual(out['packages'][0]['name'], 'guake')
self.assertEqual(
sorted(out['packages'][0].keys()),
- ['creation_date', 'description', 'name', 'review_url',
+ ['acls', 'creation_date', 'description', 'name', 'review_url',
'status', 'summary', 'upstream_url'])
self.assertEqual(out['page'], 1)
self.assertEqual(out['page_total'], 1)
@@ -229,7 +229,7 @@ class TestPkgdDB(unittest.TestCase):
self.assertEqual(out['packages'][0]['name'], 'guacd')
self.assertEqual(
sorted(out['packages'][0].keys()),
- ['creation_date', 'description', 'name', 'review_url',
+ ['acls', 'creation_date', 'description', 'name', 'review_url',
'status', 'summary', 'upstream_url'])
self.assertEqual(out['page'], 1)
self.assertEqual(out['page_total'], 1)
@@ -242,7 +242,7 @@ class TestPkgdDB(unittest.TestCase):
self.assertEqual(out['packages'][0]['name'], 'ghex')
self.assertEqual(
sorted(out['packages'][0].keys()),
- ['creation_date', 'description', 'name', 'review_url',
+ ['acls', 'creation_date', 'description', 'name', 'review_url',
'status', 'summary', 'upstream_url'])
self.assertEqual(out['packages'][1]['name'], 'glom')
self.assertEqual(out['page'], 1)
@@ -269,7 +269,7 @@ class TestPkgdDB(unittest.TestCase):
self.assertEqual(out['packages'][0]['name'], 'ghc-parameterized-data')
self.assertEqual(
sorted(out['packages'][0].keys()),
- ['creation_date', 'description', 'name', 'review_url',
+ ['acls', 'creation_date', 'description', 'name', 'review_url',
'status', 'summary', 'upstream_url'])
self.assertEqual(out['page'], 2)
self.assertEqual(out['page_total'], 6)
9 years, 11 months
[packagedb-cli] Adjust the pkgdb-cli list --user to rely on the new API added in pkgdb 1.6
by Pierre-YvesChibon
commit af10afd22a5f4370285ee84423c2ac5b8d283ccd
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed Jun 4 18:20:03 2014 +0200
Adjust the pkgdb-cli list --user to rely on the new API added in pkgdb 1.6
This makes retrieving the packages of a specified user much faster than
iterating over all his/her ACLs.
pkgdb2_cli.py | 32 ++++++++++++++++++++++----------
1 files changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/pkgdb2_cli.py b/pkgdb2_cli.py
index 4b34e59..20938b2 100644
--- a/pkgdb2_cli.py
+++ b/pkgdb2_cli.py
@@ -435,16 +435,28 @@ def do_list(args):
pattern += '*'
if args.user and not args.poc:
- output = pkgdbclient.get_packager_acls(
- packagername=args.user,
- page='all',
- )
- output2 = {'packages': []}
- for item in output['acls']:
- pkg = item['packagelist']['package']
- if pkg not in output2['packages']:
- output2['packages'].append(pkg)
- output = output2
+ version = pkgdbclient.get_version()
+ if version >= (1, 6):
+ output = pkgdbclient.get_packager_package(args.user)
+ output['packages'] = output['point of contact']
+ for pkg in output['co-maintained']:
+ if pkg not in output['packages']:
+ output['packages'].append(pkg)
+ for pkg in output['watch']:
+ if pkg not in output['packages']:
+ output['packages'].append(pkg)
+ else:
+ # This is for backward compat but it's way slower
+ output = pkgdbclient.get_packager_acls(
+ packagername=args.user,
+ page='all',
+ )
+ output2 = {'packages': []}
+ for item in output['acls']:
+ pkg = item['packagelist']['package']
+ if pkg not in output2['packages']:
+ output2['packages'].append(pkg)
+ output = output2
else:
output = pkgdbclient.get_packages(
pattern=pattern,
9 years, 11 months
[packagedb-cli] Add method to retrieve the packages of a specific packager
by Pierre-YvesChibon
commit 654c3de254eaf6a69fb5a693fb42f297af90c17a
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed Jun 4 17:58:54 2014 +0200
Add method to retrieve the packages of a specific packager
This new method has been added in pkgdb API version 1.6 and allow to
more quickly retrieve the list of packages a packager is involved with.
pkgdb2client.py | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/pkgdb2client.py b/pkgdb2client.py
index cf1a807..f25936a 100644
--- a/pkgdb2client.py
+++ b/pkgdb2client.py
@@ -649,6 +649,29 @@ class PkgDB(object):
return self.handle_api_call('/packagers/', params=args)
+
+ def get_packager_package(self, packager):
+ ''' Return the list of packages related to the specified packager.
+
+ The list of packages is split into three categories:
+ point of contact, co-maintained, watch
+ These are the same three categories used in the packager's page in
+ the pkgdb2 UI.
+
+ :arg packager: The name the packager to query the packages of
+ :type pattern: str
+ :return: the json object returned by the API
+ :rtype: dict
+ :raise PkgDBException: if the API call does not return a http code
+ 200.
+
+ '''
+ args = {
+ 'packagername': packager,
+ }
+
+ return self.handle_api_call('/packager/package/', params=args)
+
def get_packages(
self, pattern='*', branches=None, poc=None, status=None,
orphaned=False, critpath=None, acls=False, eol=False,
9 years, 11 months
[packagedb-cli] Add a dedicated method to retrieve the current version of the pkgdb API
by Pierre-YvesChibon
commit 4332518728eca57cf1aa45d6f133a5711e3ef5eb
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed Jun 4 17:58:33 2014 +0200
Add a dedicated method to retrieve the current version of the pkgdb API
pkgdb2client.py | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/pkgdb2client.py b/pkgdb2client.py
index 668290f..cf1a807 100644
--- a/pkgdb2client.py
+++ b/pkgdb2client.py
@@ -935,3 +935,33 @@ class PkgDB(object):
'poc': poc,
}
return self.handle_api_call('/package/acl/reassign/', data=args)
+
+ def get_version(self):
+ ''' Return a tuple of the pkgdb API version.
+
+ :return: the pkgdb API version
+ :rtype: tuple
+ :raise PkgDBException: if the API call does not return a http code
+ 200.
+
+ Example of data returned
+
+ ::
+
+ (1, 6)
+
+ '''
+ version = self.handle_api_call('/version')
+ if not 'version' in version:
+ raise PkgDBException(
+ 'No version information could be retrieved')
+ version = version['version']
+ output = []
+ for el in version.split('.'):
+ try:
+ el = int(el)
+ except ValueError:
+ pass
+ output.append(el)
+
+ return tuple(output)
9 years, 11 months
[packagedb-cli] Update the `list` method to return all packages unless specified otherwise
by Pierre-YvesChibon
commit 731a4d3d3bc56e80af9299f562d3ba622f53b350
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Mon Jun 2 09:55:30 2014 +0200
Update the `list` method to return all packages unless specified otherwise
This change brings back the behavior that pkgdb-cli had for pkgdb1 where
`list --user` return all the packages the user has ACLs for whatever the ACL.
This commit also adds a `--poc` argument allowing restricting the list of
packages returned to only the packages the user is point of contact for
(which was the default until now).
This allows listing the packages of a pseudo-user which we currently could
not do.
Relates to https://fedorahosted.org/pkgdb2/ticket/14#comment:12
pkgdb2_cli.py | 35 +++++++++++++++++++++++++++--------
1 files changed, 27 insertions(+), 8 deletions(-)
---
diff --git a/pkgdb2_cli.py b/pkgdb2_cli.py
index 2926b25..4b34e59 100644
--- a/pkgdb2_cli.py
+++ b/pkgdb2_cli.py
@@ -226,7 +226,12 @@ def setup_parser():
help="List all orphaned and eol'd packages")
parser_list.add_argument(
'--user', dest='user', default=None,
- help="List all the packages of the user <user>")
+ help="List all the packages of that user <user> has ACLs on")
+ parser_list.add_argument(
+ '--poc', action="store_true",
+ default=False, dest='poc',
+ help="Used in combination with `--user`, restrict the list to the "
+ "packages the user is the point of contact of")
parser_list.add_argument(
'--branch', dest='branch', default=None,
help="Specify a branch (default:'all')")
@@ -416,6 +421,7 @@ def do_list(args):
'''
LOG.info("pattern : {0}".format(args.pattern))
+ LOG.info("poc : {0}".format(args.poc))
LOG.info("orphaned : {0}".format(args.orphaned))
LOG.info("user : {0}".format(args.user))
LOG.info("name only: {0}".format(args.name_only))
@@ -428,13 +434,26 @@ def do_list(args):
if not pattern.endswith('*'):
pattern += '*'
- output = pkgdbclient.get_packages(
- pattern=pattern,
- branches=args.branch,
- poc=args.user,
- orphaned=args.orphaned,
- page='all',
- )
+ if args.user and not args.poc:
+ output = pkgdbclient.get_packager_acls(
+ packagername=args.user,
+ page='all',
+ )
+ output2 = {'packages': []}
+ for item in output['acls']:
+ pkg = item['packagelist']['package']
+ if pkg not in output2['packages']:
+ output2['packages'].append(pkg)
+ output = output2
+ else:
+ output = pkgdbclient.get_packages(
+ pattern=pattern,
+ branches=args.branch,
+ poc=args.user,
+ orphaned=args.orphaned,
+ page='all',
+ )
+
cnt = 0
for pkg in sorted(output['packages'], key=lambda pkg: (pkg['name'])):
out = " " + pkg['name'] + ' ' * (33 - len(pkg['name'])) + \
9 years, 11 months
[packagedb-cli] Drop `--all` as this is now the default if `list` is called with no arguments
by Pierre-YvesChibon
commit b3a4d966a52c0bb968bdb9d29564b7f0bd09d8f4
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Mon Jun 2 09:48:54 2014 +0200
Drop `--all` as this is now the default if `list` is called with no arguments
pkgdb2_cli.py | 10 +---------
1 files changed, 1 insertions(+), 9 deletions(-)
---
diff --git a/pkgdb2_cli.py b/pkgdb2_cli.py
index ada709c..2926b25 100644
--- a/pkgdb2_cli.py
+++ b/pkgdb2_cli.py
@@ -213,11 +213,6 @@ def setup_parser():
'list',
help='List package according to the specified criteria')
parser_list.add_argument(
- '--all', action="store_true",
- default=False, dest='all',
- help="Query all the package in the collection. This may take a "
- "while.")
- parser_list.add_argument(
'--nameonly', action="store_true",
default=False, dest='name_only',
help="Returns only the name of the package (without the description)")
@@ -421,17 +416,14 @@ def do_list(args):
'''
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.user))
LOG.info("name only: {0}".format(args.name_only))
LOG.info("branch : {0}".format(args.branch))
pattern = args.pattern
- if not pattern or args.all:
+ if not pattern:
pattern = '*'
- elif not pattern and not args.all:
- raise argparse.ArgumentTypeError("Not enough arguments given")
if not pattern.endswith('*'):
pattern += '*'
9 years, 11 months
[packagedb-cli] When listing packages, return all pages not just the first one
by Pierre-YvesChibon
commit ee648c8ba1a625b60c1253c868c6639cdfaee583
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Mon Jun 2 07:52:35 2014 +0200
When listing packages, return all pages not just the first one
pkgdb2_cli.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/pkgdb2_cli.py b/pkgdb2_cli.py
index 8f5be19..ada709c 100644
--- a/pkgdb2_cli.py
+++ b/pkgdb2_cli.py
@@ -440,7 +440,8 @@ def do_list(args):
pattern=pattern,
branches=args.branch,
poc=args.user,
- orphaned=args.orphaned
+ orphaned=args.orphaned,
+ page='all',
)
cnt = 0
for pkg in sorted(output['packages'], key=lambda pkg: (pkg['name'])):
9 years, 11 months