[packagedb-cli] Bump to 2.0.1
by Pierre-YvesChibon
commit 93aec7196474fd8b5ad377e986f6b085c2ef4ead
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed May 14 23:32:15 2014 +0200
Bump to 2.0.1
pkgdb2client.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/pkgdb2client.py b/pkgdb2client.py
index 1e70913..fc2489a 100644
--- a/pkgdb2client.py
+++ b/pkgdb2client.py
@@ -23,7 +23,7 @@ import requests
logging.basicConfig()
LOG = logging.getLogger("pkgdb2client")
-__version__ = '2.0.1'
+__version__ = '2.1'
PKGDB_URL = r'https://admin.fedoraproject.org/pkgdb/'
10 years
[packagedb-cli] Call directly get_packages instead of doing it manually and actually set the critpath flag
by Pierre-YvesChibon
commit 657544605994ec2cc176a4f060b843c070d71c84
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed May 14 18:31:20 2014 +0200
Call directly get_packages instead of doing it manually and actually set the critpath flag
pkgdb2client.py | 55 +++++++++----------------------------------------------
1 files changed, 9 insertions(+), 46 deletions(-)
---
diff --git a/pkgdb2client.py b/pkgdb2client.py
index 8157da0..1e70913 100644
--- a/pkgdb2client.py
+++ b/pkgdb2client.py
@@ -343,52 +343,15 @@ class PkgDB(object):
200.
'''
- def _get_pages(page):
- ''' Retrieve a specified page of the packages list.
-
- :arg page: the page number to retrieve
-
- '''
- args = {
- 'pattern': pattern,
- 'branches': branches,
- 'status': 'Approved',
- 'page': page,
- }
- if count is True:
- args['count'] = count
- if acls is True:
- args['acls'] = acls
-
- req = self.__send_request(
- url='{0}/api/packages/'.format(self.url),
- method='GET',
- params=args)
-
- output = req.json()
-
- if req.status_code != 200:
- LOG.debug('full output %s', output)
- raise PkgDBException(output['error'])
-
- return output
-
- if page == 'all':
- page = 0
-
- if count:
- page = 1
-
- if page < 1:
- output = _get_pages(1)
- total = output['page_total']
- for i in range(2, total + 1):
- data = _get_pages(i)
- output['packages'].extend(data['packages'])
- else:
- output = _get_pages(page)
-
- return output
+ return self.get_packages(
+ pattern=pattern,
+ branches=branches,
+ critpath=True,
+ status=status,
+ acls=acls,
+ page=page,
+ count=count,
+ )
def get_collections(self, pattern='*', clt_status=None):
''' Return the list of collections matching the provided criterias.
10 years
[packagedb-cli] Add the critpath filter to get_packages
by Pierre-YvesChibon
commit 900753cfed18d8ecb3b6b4b382189fc30426007c
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed May 14 18:06:10 2014 +0200
Add the critpath filter to get_packages
pkgdb2client.py | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/pkgdb2client.py b/pkgdb2client.py
index 5f90857..8157da0 100644
--- a/pkgdb2client.py
+++ b/pkgdb2client.py
@@ -621,7 +621,8 @@ class PkgDB(object):
def get_packages(
self, pattern='*', branches=None, poc=None, status=None,
- orphaned=False, acls=False, eol=False, page=1, count=False):
+ orphaned=False, critpath=None, acls=False, eol=False,
+ page=1, count=False):
''' Return the list of packages matching the provided criterias.
To get information about what packages a person has acls on, you
@@ -642,6 +643,10 @@ class PkgDB(object):
:type status: str or list or None
:kwarg orphaned: A boolean to returned only orphaned packages
:type orphaned: bool
+ :kwarg critpath: A boolean to returned only packages in the critical
+ path. Can be ``True``, ``False`` or ``None``.
+ Defaults to ``None``.
+ :type critpath: bool
:kwarg acls: A boolean to return the package ACLs in the output.
Beware, this may slow down you call considerably, maybe even
leading to a timeout
@@ -684,6 +689,10 @@ class PkgDB(object):
args['acls'] = acls
if orphaned is True:
args['orphaned'] = orphaned
+ if critpath is True:
+ args['critpath'] = 1
+ elif critpath is False:
+ args['critpath'] = 0
if eol is True:
args['eol'] = eol
10 years
[packagedb-cli] Add method to retrieve packages marked as being in the critical path
by Pierre-YvesChibon
commit 874bc77dbb4768ac49c04540083c06a935e1daea
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed May 14 18:03:27 2014 +0200
Add method to retrieve packages marked as being in the critical path
pkgdb2client.py | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 83 insertions(+), 0 deletions(-)
---
diff --git a/pkgdb2client.py b/pkgdb2client.py
index f2862ad..5f90857 100644
--- a/pkgdb2client.py
+++ b/pkgdb2client.py
@@ -307,6 +307,89 @@ class PkgDB(object):
return output
+ def get_critpath_packages(
+ self, pattern='*', branches=None, status='Approved', acls=False,
+ page=1, count=False):
+ ''' Return the list of packages matching the provided criterias
+ in the critical path.
+
+ To get information about what packages a person has acls on, you
+ also need to call ``get_packager_acls``.
+
+ :kwarg pattern: The pattern to match against the name of the
+ packages
+ :type pattern: str
+ :kwarg branches: One or more branches to restrict the packages
+ returned
+ :type branches: str or list or None
+ :kwarg status: The status of the package to filter the packages
+ returned, options are: ``Approved``, ``Orphaned``, ``Removed``,
+ ``Retired``. Defaults to ``Approved``.
+ :type status: str or list or None
+ :kwarg acls: A boolean to return the package ACLs in the output.
+ Beware, this may slow down you call considerably, maybe even
+ leading to a timeout
+ :type acls: bool
+ :kwarg page: The page number to retrieve. If page is 0 or lower or
+ equal to ``all`` then all pages are returned. Defaults to 0.
+ :type page: int or ``all``
+ :kwarg count: A boolean to retrieve the count of ACLs the user has
+ instead of the details. If count is True the page argument will
+ be ignored
+ :type count: bool
+ :return: the json object returned by the API
+ :rtype: dict
+ :raise PkgDBException: if the API call does not return a http code
+ 200.
+
+ '''
+ def _get_pages(page):
+ ''' Retrieve a specified page of the packages list.
+
+ :arg page: the page number to retrieve
+
+ '''
+ args = {
+ 'pattern': pattern,
+ 'branches': branches,
+ 'status': 'Approved',
+ 'page': page,
+ }
+ if count is True:
+ args['count'] = count
+ if acls is True:
+ args['acls'] = acls
+
+ req = self.__send_request(
+ url='{0}/api/packages/'.format(self.url),
+ method='GET',
+ params=args)
+
+ output = req.json()
+
+ if req.status_code != 200:
+ LOG.debug('full output %s', output)
+ raise PkgDBException(output['error'])
+
+ return output
+
+ if page == 'all':
+ page = 0
+
+ if count:
+ page = 1
+
+ if page < 1:
+ output = _get_pages(1)
+ total = output['page_total']
+ for i in range(2, total + 1):
+ data = _get_pages(i)
+ output['packages'].extend(data['packages'])
+ else:
+ output = _get_pages(page)
+
+ return output
+
def get_collections(self, pattern='*', clt_status=None):
''' Return the list of collections matching the provided criterias.
10 years
[packagedb-cli] Created tag v2.0.1
by Pierre-YvesChibon
The signed tag 'v2.0.1' was created.
Tagger: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed May 14 17:48:03 2014 +0200
Release 2.0.1
Changes since the last tag 'v2.0':
Pierre-Yves Chibon (2):
Fix the default url to point to the prod instance of pkgdb2
Bump release to 2.0.1
10 years
[packagedb-cli] Bump release to 2.0.1
by Pierre-YvesChibon
commit 08f7753448ce92934948cc661c6532f223e2dd6c
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed May 14 17:47:22 2014 +0200
Bump release to 2.0.1
pkgdb2client.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/pkgdb2client.py b/pkgdb2client.py
index 5a1f50d..f2862ad 100644
--- a/pkgdb2client.py
+++ b/pkgdb2client.py
@@ -23,7 +23,7 @@ import requests
logging.basicConfig()
LOG = logging.getLogger("pkgdb2client")
-__version__ = '2.0'
+__version__ = '2.0.1'
PKGDB_URL = r'https://admin.fedoraproject.org/pkgdb/'
10 years
[packagedb-cli] Created tag v2.0
by Pierre-YvesChibon
The signed tag 'v2.0' was created.
Tagger: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed May 14 14:09:06 2014 +0200
Release 2.0
Changes since the last tag 'v1.7.0':
Pierre-Yves Chibon (107):
Add backend library to query the packagedb database (v2)
Add the first iteration of the pkgdb2-cli
Bug and typo fixes to the CLI
Add a login mechanism, use requests' json converted and use a session local to the object
Support login in with the CLI and updating ACL request
Fix login against other instances of pkgdb, remember the user's username and fix the update_acl call
Work on pkgdb2-cli
Start adding some logging also to the API
Improve documentation for _parse_service_form
Handle the logging from the API as well
Instance the koji and bz client when we need them and rely on argparse for the nocolor option
Typoes...
Move handling the logging level in the main
Add support for the pagination of the api packages endpoint
Adjust the CLI to the API
Add a little more debuging output, it will be handy to know what has been called with what to debug
Small pep8 cleanup
Raise an exception if trying to run a method w/o being authenticated
Add create_package method to create a package via the API
Add create_collection method to create a collection via the API
Add update_collection_status method to update a collection status via the API
Add update_package_poc method to update the point of contact via the API
Add get_packagers method to retrieve packagers via the API
Add get_packager_acls method to retrieve the ACLs of a packager via the API
Fix typo pages_total changed for page_total
Fix ordering of the functions
Add get_packager_stats method to retrieve stats about a packager via the API
Some more fix in the ordering of the functions
Fix copyright year
Actually, in 2014, the copyright belongs to Red Hat Inc
Add documentation about the exceptions raised by the methods
Add documentation about the object returned and its type
Rename the module pkgdb2 and fix the import in the cli
pylint fixes in pkgdb2-cli
Move the check for --test into the main method where it belongs
Simplifies the returns
pylint fixes in the pkgdb2 module
Let's not expose the limit argument, we'll just use the default
Documentation and allow disabling iteration when the API paginates
pep8 fixes
Rename the pkgdb2-cli into pkgdb2_cli.py so that it can be moved to the std path
Adjust the README file
Update setup.py to the new structure and version
Move the __version__ into the pkgdb2 module
Adjust the copyright also for pkgdb2_cli, in 2014, it's Red Hat
Update the .gitignore file
Documentation fixes
pep8 fixes
Adjust the shebang, pkgdb2 is not to be run while pkgdb2_cli is and also in venv
Update documentation by including the type of the arguments in the methods
Update the pkgdb2 module documentation
Let's be consistent on the usage our of triple quotes
Small adjustment in what the version of a collection may be
Add the possibility to make insecure http calls
Fix the api call and gathering of the pagination output
Use branchename and status in update_collection_status to be consistent in our variable naming.
Small pep8 fix
Add first tests for the pkgdb2 API
Adjust the pkgdb2 module to the changes in the API
Adjust pkgdb2-cli to use the pkgdb2 module properly
Add tests for the methods requiring authentications
Rename the logged attribute to is_logged_in and __logged to __logged in
Have the get_collections accept multiple clt_status
Fix docstring in get_packager_acls
Instead of the iterate boolean, use page to determine what results to retrieve
Adjust the documentation to specify get_packages also accept a list of package status as filter
Reorganise the .gitignore file
Remove the old pkgdb-cli script
The file installed on the python stdlib doesn't need +x
Remove shebang this we put the file in the std path
Include the test.py file in the sources
Fix the tests, remove the iterate arg, adjust package name and acls numbers
Have PkgDBAuthException inherit from PkgDBException and fedora.client.AuthError
Fix some documentations error, thanks @abadger
Points by default to pkgdb in stg, only official pkgdb2 instance running
Somehow the trailing slash is important
Have get_package support filtering for multiple branches
Adjust the pkgdb2-cli to the update of the pkgdb2 module
Use a dedicated __send_request method to make the http calls
Small pep8 fix
Fix import of AuthError
Small adjustments in the tests
Allow get_packager_acls to restrict the ACLs retrieved to a specific set of ACLs
Fix documentation for the options available for the acls kwarg of get_packager
Add tests for the get_packager method restricted to some ACLs only
Fix typo in the doc, thanks @abadger
Specify in get_packagers which packagers are returned (vs what FAS provides)
Add support for the eol argument for the API endpoints that have it
Specify that the update_acl method can be used to request or set ACLs as well
pep8 fixes
Add the poc argument to the get_packager_acls method in the pkgdb2 module
Add tests for the poc and count argument of get_packager_acls
Fix the get_collections call for pkgdb-cli branch
Change pkgdb-cli branch to pkgdb-cli branches to be consistent with pkgdb-cli v1
Remove the username argument from the constructor as we do not use it anywhere
Merge pull request #1 from fedora-infra/pkgdb2
Rename pkgdb2 into pkgdb2client
Rename the `pkgdb` logger into `pkgdb2client` to be consistent with the module name
Adjust import and logger in pkgdb2_cli for the `pkgdb2client` change
Adjust the setup.py to include `pkgdb2client` instead of `pkgdb2`
Merge pull request #3 from fedora-infra/rename
Specify to FedOAuth that we want to authenticate with FAS
Merge pull request #4 from fedora-infra/openid_fix
Point pkgdb-cli to the prod instance of pkgdb2 by default
If ran with --test query FAS and pkgdb in staging
Adjust the unit-tests to work on the current version of the DB
Adjust import in setup.py
10 years
[packagedb-cli] Adjust import in setup.py
by Pierre-YvesChibon
commit 062a11fc417e1d9a6f34b82642add43ad0d1c3c6
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed May 14 14:08:46 2014 +0200
Adjust import in setup.py
setup.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/setup.py b/setup.py
index a54f9a3..de0d315 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ Setup script
from setuptools import setup
-from pkgdb2 import __version__
+from pkgdb2client import __version__
setup(
name='packagedb-cli',
10 years
[packagedb-cli: 5/5] Adjust the unit-tests to work on the current version of the DB
by Pierre-YvesChibon
commit 767b18fbb9f27cc8e71006ec265c26398fb01f63
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Wed May 14 14:03:25 2014 +0200
Adjust the unit-tests to work on the current version of the DB
test.py | 62 +++++++++++++++++++++++++++++++-------------------------------
1 files changed, 31 insertions(+), 31 deletions(-)
---
diff --git a/test.py b/test.py
index a47a40f..0d7ec61 100644
--- a/test.py
+++ b/test.py
@@ -9,7 +9,7 @@ import uuid
import fedora_cert
-from pkgdb2 import PkgDB, PkgDBException
+from pkgdb2client import PkgDB, PkgDBException
PKGDB_URL = 'http://127.0.0.1:5000'
@@ -65,7 +65,7 @@ class TestPkgdDB(unittest.TestCase):
self.assertEqual(out['output'], 'ok')
self.assertEqual(len(out['packages']), 4)
self.assertEqual(
- out['packages'][0]['collection']['branchname'], 'devel')
+ out['packages'][0]['collection']['branchname'], 'master')
self.assertEqual(
out['packages'][0]['package']['name'], 'guake')
self.assertEqual(
@@ -111,7 +111,7 @@ class TestPkgdDB(unittest.TestCase):
self.assertEqual(
sorted(out.keys()),
['acls', 'output', 'page', 'page_total'])
- self.assertEqual(len(out['acls']), 237)
+ self.assertEqual(len(out['acls']), 239)
self.assertEqual(out['page_total'], 1)
out = self.pkgdb.get_packager_acls('pingou', page=3)
@@ -125,21 +125,21 @@ class TestPkgdDB(unittest.TestCase):
self.assertEqual(
sorted(out.keys()),
['acls_count', 'output', 'page', 'page_total'])
- self.assertEqual(out['acls_count'], 1035)
+ self.assertEqual(out['acls_count'], 1043)
self.assertEqual(out['page_total'], 1)
out = self.pkgdb.get_packager_acls('pingou', poc=True, count=True)
self.assertEqual(
sorted(out.keys()),
['acls_count', 'output', 'page', 'page_total'])
- self.assertEqual(out['acls_count'], 800)
+ self.assertEqual(out['acls_count'], 804)
self.assertEqual(out['page_total'], 1)
out = self.pkgdb.get_packager_acls('pingou', poc=False, count=True)
self.assertEqual(
sorted(out.keys()),
['acls_count', 'output', 'page', 'page_total'])
- self.assertEqual(out['acls_count'], 235)
+ self.assertEqual(out['acls_count'], 239)
self.assertEqual(out['page_total'], 1)
def test_get_packager_stats(self):
@@ -147,11 +147,11 @@ class TestPkgdDB(unittest.TestCase):
out = self.pkgdb.get_packager_stats('pingou')
self.assertEqual(
sorted(out.keys()),
- ['EL-5', 'EL-6', 'devel', 'epel7', 'f19', 'f20', 'output'])
+ ['el5', 'el6', 'epel7', 'f19', 'f20', 'master', 'output'])
self.assertEqual(
- sorted(out['devel'].keys()),
+ sorted(out['master'].keys()),
['co-maintainer', 'point of contact'])
- self.assertTrue(out['devel']['point of contact'] >= 60)
+ self.assertTrue(out['master']['point of contact'] >= 60)
def test_get_packagers(self):
''' Test the get_packagers function. '''
@@ -177,7 +177,7 @@ class TestPkgdDB(unittest.TestCase):
self.assertEqual(out['page'], 1)
self.assertEqual(out['page_total'], 1)
- out = self.pkgdb.get_packages('gua*', branches='EL-6')
+ out = self.pkgdb.get_packages('gua*', branches='el6')
self.assertEqual(
sorted(out.keys()),
['output', 'packages', 'page', 'page_total'])
@@ -249,7 +249,7 @@ class TestPkgdDB(unittest.TestCase):
sorted(out.keys()),
['output', 'packages', 'page', 'page_total'])
self.assertEqual(len(out['packages']), 250)
- self.assertEqual(out['packages'][0]['name'], 'ghex')
+ self.assertEqual(out['packages'][0]['name'], 'ghc-parameterized-data')
self.assertEqual(
sorted(out['packages'][0].keys()),
['creation_date', 'description', 'name', 'review_url',
@@ -345,7 +345,7 @@ class TestPkgdDBAuth(unittest.TestCase):
def test_3_orphan_packages(self):
''' Test the orphan_packages function. '''
- out = self.pkgdb.orphan_packages('guake', ['devel', 'EL-6'])
+ out = self.pkgdb.orphan_packages('guake', ['master', 'el6'])
self.assertEqual(
sorted(out.keys()),
@@ -355,15 +355,15 @@ class TestPkgdDBAuth(unittest.TestCase):
self.assertEqual(
out['messages'],
['user: pingou changed poc of package: guake from: pingou '
- 'to: orphan on branch: devel',
+ 'to: orphan on branch: master',
'user: pingou changed poc of package: guake from: pingou '
- 'to: orphan on branch: EL-6'])
+ 'to: orphan on branch: el6'])
def test_4_unorphan_packages(self):
''' Test the unorphan_packages function. '''
out = self.pkgdb.unorphan_packages(
- 'guake', ['devel', 'EL-6'], 'pingou')
+ 'guake', ['master', 'el6'], 'pingou')
self.assertEqual(
sorted(out.keys()),
@@ -372,13 +372,13 @@ class TestPkgdDBAuth(unittest.TestCase):
self.assertEqual(out['output'], 'ok')
self.assertEqual(
out['messages'],
- ['Package guake has been unorphaned on devel by pingou',
- 'Package guake has been unorphaned on EL-6 by pingou'])
+ ['Package guake has been unorphaned on master by pingou',
+ 'Package guake has been unorphaned on el6 by pingou'])
def test_5_retire_packages(self):
''' Test the retire_packages function. '''
- out = self.pkgdb.retire_packages('guake', 'devel')
+ out = self.pkgdb.retire_packages('guake', 'master')
self.assertEqual(
sorted(out.keys()),
@@ -388,12 +388,12 @@ class TestPkgdDBAuth(unittest.TestCase):
self.assertEqual(
out['messages'],
['user: pingou updated package: guake status from: Approved to '
- 'Retired on branch: devel'])
+ 'Retired on branch: master'])
def test_6_unretire_packages(self):
''' Test the unretire_packages function. '''
- out = self.pkgdb.unretire_packages('guake', 'devel')
+ out = self.pkgdb.unretire_packages('guake', 'master')
self.assertEqual(
sorted(out.keys()),
@@ -403,14 +403,14 @@ class TestPkgdDBAuth(unittest.TestCase):
self.assertEqual(
out['messages'],
['user: pingou updated package: guake status from: Retired to '
- 'Approved on branch: devel'])
+ 'Approved on branch: master'])
def test_7_update_acl(self):
''' Test the update_acl function. '''
out = self.pkgdb.update_acl(
- 'guake', ['devel', 'EL-6'], 'commit', 'Awaiting Review',
- 'Ralph')
+ 'guake', ['master', 'el6'], 'commit', 'Awaiting Review',
+ 'ralph')
self.assertEqual(
sorted(out.keys()),
@@ -420,9 +420,9 @@ class TestPkgdDBAuth(unittest.TestCase):
self.assertEqual(
out['messages'],
['user: pingou set acl: commit of package: guake from: '
- 'Awaiting Review to: Awaiting Review on branch: devel',
+ 'Awaiting Review to: Awaiting Review on branch: master',
'user: pingou set acl: commit of package: guake from: '
- 'Awaiting Review to: Awaiting Review on branch: EL-6'])
+ 'Awaiting Review to: Awaiting Review on branch: el6'])
def test_8_update_collection_status(self):
''' Test the update_collection_status function. '''
@@ -442,7 +442,7 @@ class TestPkgdDBAuth(unittest.TestCase):
''' Test the update_package_poc function. '''
out = self.pkgdb.update_package_poc(
- 'guake', ['devel', 'EL-6'], 'ralph')
+ 'guake', ['master', 'el6'], 'ralph')
self.assertEqual(
sorted(out.keys()),
@@ -452,12 +452,12 @@ class TestPkgdDBAuth(unittest.TestCase):
self.assertEqual(
out['messages'],
['user: pingou changed poc of package: guake from: orphan to: '
- 'ralph on branch: devel',
+ 'ralph on branch: master',
'user: pingou changed poc of package: guake from: pingou to: '
- 'ralph on branch: EL-6'])
+ 'ralph on branch: el6'])
out = self.pkgdb.update_package_poc(
- 'guake', ['devel', 'EL-6'], 'pingou')
+ 'guake', ['master', 'el6'], 'pingou')
self.assertEqual(
sorted(out.keys()),
@@ -467,9 +467,9 @@ class TestPkgdDBAuth(unittest.TestCase):
self.assertEqual(
out['messages'],
['user: pingou changed poc of package: guake from: ralph to: '
- 'pingou on branch: devel',
+ 'pingou on branch: master',
'user: pingou changed poc of package: guake from: ralph to: '
- 'pingou on branch: EL-6'])
+ 'pingou on branch: el6'])
def suite():
10 years