[packagedb-cli] (10 commits) ...If the user is already logged in via the session pickle, move on
by Pierre-YvesChibon
Summary of changes:
210c90b... pkgdb2client: Cleanup on-demand login code
9e15b95... Merge pull request #12 from tyll/simplify
341896e... pkgdb2_cli: Ask for password only if required
afda46e... PkgDB: Store cookies
2409a12... Merge pull request #13 from tyll/cli
9cbc4b2... pkgdb2client: fix indentation
15df804... Merge pull request #14 from tyll/simplify
ea7de6a... Merge pull request #9 from tyll/store_cookies
31e1efa... If no password is provided, skip the auth tests
516e953... If the user is already logged in via the session pickle, mo
9 years, 11 months
[packagedb-cli] pkgdb2client is a library, no need for if __name__ == '__main__'
by Pierre-YvesChibon
commit 2ef3c4a32ca8991ff36f6e23fac6ae11141226ef
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu May 29 17:11:50 2014 +0200
pkgdb2client is a library, no need for if __name__ == '__main__'
Signed-off-by: Pierre-Yves Chibon <pingou(a)pingoured.fr>
pkgdb2client.py | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
---
diff --git a/pkgdb2client.py b/pkgdb2client.py
index e637a0e..e2fa32f 100644
--- a/pkgdb2client.py
+++ b/pkgdb2client.py
@@ -894,6 +894,3 @@ class PkgDB(object):
}
return self.handle_api_call('/package/acl/reassign/', data=args)
-
-if __name__ == "__main__":
- pkgdb = PkgDB(login_callback=ask_password)
9 years, 11 months
[packagedb-cli: 6/6] Merge pull request #10 from tyll/simplify
by Pierre-YvesChibon
commit f9998cc9bb4451227cbf3d98b72b561a9499837b
Merge: f62a547 09c1697
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu May 29 17:08:04 2014 +0200
Merge pull request #10 from tyll/simplify
pkgdb2client: Remove duplicate code to call the API
pkgdb2client.py | 348 ++++++++++++++++++++-----------------------------------
1 files changed, 127 insertions(+), 221 deletions(-)
---
9 years, 11 months
[packagedb-cli: 5/6] Merge pull request #11 from tyll/pep8
by Pierre-YvesChibon
commit f62a5471ed4ba17fa08a13c9e7b25dfca33b3e28
Merge: af8bff6 92588f7
Author: Ralph Bean <rbean(a)redhat.com>
Date: Thu May 29 08:59:34 2014 -0400
Merge pull request #11 from tyll/pep8
setup.py: Fix wrap line
setup.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
---
9 years, 11 months
[packagedb-cli: 4/6] setup.py: Wrap line
by Pierre-YvesChibon
commit 92588f7dbfcb25b306fd01e0e571ef843d26e194
Author: Till Maas <opensource(a)till.name>
Date: Thu May 29 14:15:18 2014 +0200
setup.py: Wrap line
setup.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/setup.py b/setup.py
index cc14d3a..be5cb79 100644
--- a/setup.py
+++ b/setup.py
@@ -27,7 +27,8 @@ setup(
'Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: Developers',
- 'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)',
+ 'License :: OSI Approved :: GNU General Public License v2 or later '
+ '(GPLv2+)',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
9 years, 11 months
[packagedb-cli: 3/6] pkgdb2client: Support on-demand authentication
by Pierre-YvesChibon
commit 09c1697b87eb672b540a2e41a8648331edaddd5c
Author: Till Maas <opensource(a)till.name>
Date: Thu May 29 14:08:31 2014 +0200
pkgdb2client: Support on-demand authentication
Login only when required by pkgdb, support specifying a callback to get
user name and password.
pkgdb2client.py | 97 +++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 66 insertions(+), 31 deletions(-)
---
diff --git a/pkgdb2client.py b/pkgdb2client.py
index a2fbe64..e637a0e 100644
--- a/pkgdb2client.py
+++ b/pkgdb2client.py
@@ -15,9 +15,11 @@
# license.
"""
+import getpass
import logging
import pkg_resources
+import fedora_cert
from fedora.client import AuthError
import requests
@@ -62,13 +64,33 @@ def _parse_service_form(response):
return (parsed.form.attrs['action'], inputs)
+def ask_password(username=None, bad_password=False):
+ """ Example login_callback to ask username/password from user
+ :kwarg username: Username
+ :type username: str
+ :kwarg bad_password: Whether there was a previous failed login attempt
+ :type bad_password: bool
+ :return: username, password
+ :rtype: tuple
+ """
+ if bad_password:
+ print "Bad password, please retry"
+ if not username:
+ try:
+ username = fedora_cert.read_user_cert()
+ except fedora_cert.fedora_cert_error:
+ username = raw_input("Username: ")
+ password = getpass.getpass("FAS password for user {0}: ".format(username))
+ return username, password
+
+
class PkgDB(object):
''' PkgDB class used to interact with the Package DB instance via its
API.
'''
- def __init__(self, url=PKGDB_URL, insecure=False):
+ def __init__(self, url=PKGDB_URL, insecure=False, login_callback=None):
''' Constructor for the PkgDB object used to query the package
database.
@@ -88,6 +110,9 @@ class PkgDB(object):
self.__logged_in = False
self.username = None
self.password = None
+ # should accept username and bad_password
+ self.login_callback = login_callback
+ self.login_retries = 3
def __send_request(self, url, method, params=None, data=None):
''' Send a http request to the provided URL with the provided
@@ -115,7 +140,8 @@ class PkgDB(object):
''' Return whether the user if logged in or not. '''
return self.__logged_in
- def login(self, username=None, password=None, openid_insecure=False):
+ def login(self, username=None, password=None, openid_insecure=False,
+ response=None):
''' Login the user on pkgdb2.
:arg username: the FAS username of the user.
@@ -134,6 +160,9 @@ class PkgDB(object):
username = self.username
if not password:
password = self.password
+ if self.login_callback and not password:
+ username, password = self.login_callback(username=username,
+ bad_password=False)
if not username or not password:
raise PkgDBAuthException('Username or password missing')
@@ -147,7 +176,8 @@ class PkgDB(object):
motif = re.compile(fedora_openid)
# Log into the service
- response = self.session.get(self.url + '/login/')
+ if not response:
+ response = self.session.get(self.url + '/login/')
if '<title>OpenID transaction in progress</title>' \
in response.text:
@@ -203,7 +233,8 @@ class PkgDB(object):
:arg data: POST data for the API call
:type data: dict
:return: requests response object
- :rtype: requests.Response()
+ :rtype: requests.models.Response
+ :raise PkgDBAuthException: If login is required and fails
'''
if data:
method = "POST"
@@ -213,6 +244,33 @@ class PkgDB(object):
url = self.url + "/api" + path
response = self.__send_request(url=url, method=method, data=data,
params=params)
+ if '<title>OpenID transaction in progress</title>' \
+ in response.text:
+ bad_password = False
+ password = self.password
+ username = self.username
+ success = False
+ for count in xrange(0, self.login_retries):
+ if not username or not password or bad_password:
+ if self.login_callback:
+ username, password = self.login_callback(
+ username=username,
+ bad_password=bad_password
+ )
+ else:
+ raise PkgDBAuthException('Authentication retired')
+ try:
+ self.login(username=username, password=password,
+ response=response)
+ success = True
+ break
+ except PkgDBException:
+ response = None
+ bad_password = True
+ if not success:
+ raise PkgDBAuthException("Too many failed login attempts")
+ response = self.__send_request(url=url, method=method, data=data,
+ params=params)
return response
def handle_api_call(self, path, params=None, data=None):
@@ -273,9 +331,6 @@ class PkgDB(object):
200.
'''
- if not self.is_logged_in:
- raise PkgDBAuthException('Authentication required')
-
args = {
'clt_name': clt_name,
'version': version,
@@ -325,9 +380,6 @@ class PkgDB(object):
200.
'''
- if not self.is_logged_in:
- raise PkgDBAuthException('Authentication required')
-
args = {
'pkgname': pkgname,
'summary': summary,
@@ -668,9 +720,6 @@ class PkgDB(object):
200.
'''
- if not self.is_logged_in:
- raise PkgDBAuthException('Authentication required')
-
args = {
'pkgnames': pkgnames,
'branches': branches,
@@ -695,9 +744,6 @@ class PkgDB(object):
200.
'''
- if not self.is_logged_in:
- raise PkgDBAuthException('Authentication required')
-
args = {
'pkgnames': pkgnames,
'branches': branches,
@@ -724,9 +770,6 @@ class PkgDB(object):
200.
'''
- if not self.is_logged_in:
- raise PkgDBAuthException('Authentication required')
-
args = {
'pkgnames': pkgnames,
'branches': branches,
@@ -752,9 +795,6 @@ class PkgDB(object):
200.
'''
- if not self.is_logged_in:
- raise PkgDBAuthException('Authentication required')
-
args = {
'pkgnames': pkgnames,
'branches': branches,
@@ -792,9 +832,6 @@ class PkgDB(object):
200.
'''
- if not self.is_logged_in:
- raise PkgDBAuthException('Authentication required')
-
args = {
'pkgname': pkgname,
'branches': branches,
@@ -822,9 +859,6 @@ class PkgDB(object):
200.
'''
- if not self.is_logged_in:
- raise PkgDBAuthException('Authentication required')
-
args = {
'branch': branch,
'clt_status': clt_status,
@@ -853,12 +887,13 @@ class PkgDB(object):
200.
'''
- if not self.is_logged_in:
- raise PkgDBAuthException('Authentication required')
-
args = {
'pkgnames': pkgnames,
'branches': branches,
'poc': poc,
}
return self.handle_api_call('/package/acl/reassign/', data=args)
+
+
+if __name__ == "__main__":
+ pkgdb = PkgDB(login_callback=ask_password)
9 years, 11 months
[packagedb-cli: 2/6] pkgdb2client: Allow low-level API calls
by Pierre-YvesChibon
commit a59ca03523fcd3eeca2679cf6514808e3691b177
Author: Till Maas <opensource(a)till.name>
Date: Thu May 29 11:33:58 2014 +0200
pkgdb2client: Allow low-level API calls
pkgdb2client.py | 59 ++++++++++++++++++++++++++++++++++--------------------
1 files changed, 37 insertions(+), 22 deletions(-)
---
diff --git a/pkgdb2client.py b/pkgdb2client.py
index 22143c3..a2fbe64 100644
--- a/pkgdb2client.py
+++ b/pkgdb2client.py
@@ -202,11 +202,8 @@ class PkgDB(object):
:type params: dict
:arg data: POST data for the API call
:type data: dict
- :return: the json object returned by the API
- :rtype: dict
- :raise PkgDBException: if the API call does not return a http code
- 200.
-
+ :return: requests response object
+ :rtype: requests.Response()
'''
if data:
method = "POST"
@@ -216,7 +213,25 @@ class PkgDB(object):
url = self.url + "/api" + path
response = self.__send_request(url=url, method=method, data=data,
params=params)
+ return response
+
+ def handle_api_call(self, path, params=None, data=None):
+ ''' call the API.
+
+ :arg path: The path to call
+ :type path: str
+ :arg params: URL params for the API call
+ :type params: dict
+ :arg data: POST data for the API call
+ :type data: dict
+ :return: the json object returned by the API
+ :rtype: dict
+ :raise PkgDBException: if the API call does not return a http code
+ 200.
+
+ '''
+ response = self.call_api(path, params, data)
output = response.json()
if response.status_code != 200:
@@ -271,7 +286,7 @@ class PkgDB(object):
'kojiname': kojiname,
}
- return self.call_api('/collection/new/', data=args)
+ return self.handle_api_call('/collection/new/', data=args)
def create_package(
self, pkgname, summary, description, review_url, status,
@@ -327,7 +342,7 @@ class PkgDB(object):
if critpath:
args['critpath'] = critpath
- return self.call_api('/package/new/', data=args)
+ return self.handle_api_call('/package/new/', data=args)
def get_critpath_packages(self, branches=None, **kwargs):
''' Return the list of package names in the critical path.
@@ -364,7 +379,7 @@ class PkgDB(object):
'format': 'json',
}
- return self.call_api('/critpath/', params=args)
+ return self.handle_api_call('/critpath/', params=args)
def get_collections(self, pattern='*', clt_status=None):
''' Return the list of collections matching the provided criterias.
@@ -386,7 +401,7 @@ class PkgDB(object):
'clt_status': clt_status,
}
- return self.call_api('/collections/', params=args)
+ return self.handle_api_call('/collections/', params=args)
def get_package(self, pkgname, branches=None, eol=False):
''' Return the information of a package matching the provided
@@ -415,7 +430,7 @@ class PkgDB(object):
if eol is True:
args['eol'] = eol
- return self.call_api('/package/', params=args)
+ return self.handle_api_call('/package/', params=args)
def get_packager_acls(
self, packagername, acls=None, eol=False, poc=None,
@@ -480,7 +495,7 @@ class PkgDB(object):
if poc is not None:
args['poc'] = poc
- return self.call_api('/packager/acl/', params=args)
+ return self.handle_api_call('/packager/acl/', params=args)
if page == 'all':
page = 0
@@ -516,7 +531,7 @@ class PkgDB(object):
'packagername': packagername,
}
- return self.call_api('/packager/stats/', params=args)
+ return self.handle_api_call('/packager/stats/', params=args)
def get_packagers(self, pattern='*'):
''' Return the list of packagers matching the provided criterias.
@@ -538,7 +553,7 @@ class PkgDB(object):
'pattern': pattern,
}
- return self.call_api('/packagers/', params=args)
+ return self.handle_api_call('/packagers/', params=args)
def get_packages(
self, pattern='*', branches=None, poc=None, status=None,
@@ -617,7 +632,7 @@ class PkgDB(object):
if eol is True:
args['eol'] = eol
- return self.call_api('/packages/', params=args)
+ return self.handle_api_call('/packages/', params=args)
if page == 'all':
page = 0
@@ -661,7 +676,7 @@ class PkgDB(object):
'branches': branches,
}
- return self.call_api('/package/orphan/', data=args)
+ return self.handle_api_call('/package/orphan/', data=args)
def retire_packages(self, pkgnames, branches):
''' Retires the provided list of packages on the provided list of
@@ -688,7 +703,7 @@ class PkgDB(object):
'branches': branches,
}
- return self.call_api('/package/retire/', data=args)
+ return self.handle_api_call('/package/retire/', data=args)
def unorphan_packages(self, pkgnames, branches, poc):
''' Un orphan the provided list of packages on the provided list of
@@ -718,7 +733,7 @@ class PkgDB(object):
'poc': poc,
}
- return self.call_api('/package/unorphan/', data=args)
+ return self.handle_api_call('/package/unorphan/', data=args)
def unretire_packages(self, pkgnames, branches):
''' Un retires the provided list of packages on the provided list of
@@ -745,7 +760,7 @@ class PkgDB(object):
'branches': branches,
}
- return self.call_api('/package/unretire/', data=args)
+ return self.handle_api_call('/package/unretire/', data=args)
def update_acl(self, pkgname, branches, acls, status, user):
''' Update the specified ACLs, on the specified Branches of the
@@ -788,7 +803,7 @@ class PkgDB(object):
'user': user,
}
- return self.call_api('/package/acl/', data=args)
+ return self.handle_api_call('/package/acl/', data=args)
def update_collection_status(self, branch, clt_status):
''' Update the status of the specified collection.
@@ -815,8 +830,8 @@ class PkgDB(object):
'clt_status': clt_status,
}
- return self.call_api('/collection/{0}/status/'.format(branch),
- data=args)
+ return self.handle_api_call('/collection/{0}/status/'.format(branch),
+ data=args)
def update_package_poc(self, pkgnames, branches, poc):
''' Update the point of contact of the specified packages on the
@@ -846,4 +861,4 @@ class PkgDB(object):
'branches': branches,
'poc': poc,
}
- return self.call_api('/package/acl/reassign/', data=args)
+ return self.handle_api_call('/package/acl/reassign/', data=args)
9 years, 11 months
[packagedb-cli: 1/6] pkgdb2client: Remove duplicate code to call the API
by Pierre-YvesChibon
commit 19d75ca07c378973bd6959b5208d2b3a975cfebf
Author: Till Maas <opensource(a)till.name>
Date: Thu May 29 11:18:51 2014 +0200
pkgdb2client: Remove duplicate code to call the API
The new call_api() method includes the generic API call code that can be
used by all API wrapper methods and to call non-wrapped API methods.
pkgdb2client.py | 242 +++++++++++--------------------------------------------
1 files changed, 49 insertions(+), 193 deletions(-)
---
diff --git a/pkgdb2client.py b/pkgdb2client.py
index 4a0d894..22143c3 100644
--- a/pkgdb2client.py
+++ b/pkgdb2client.py
@@ -193,6 +193,38 @@ class PkgDB(object):
return output
+ def call_api(self, path, params=None, data=None):
+ ''' call the API.
+
+ :arg path: The path to call
+ :type path: str
+ :arg params: URL params for the API call
+ :type params: dict
+ :arg data: POST data for the API call
+ :type data: dict
+ :return: the json object returned by the API
+ :rtype: dict
+ :raise PkgDBException: if the API call does not return a http code
+ 200.
+
+ '''
+ if data:
+ method = "POST"
+ else:
+ method = "GET"
+
+ url = self.url + "/api" + path
+ response = self.__send_request(url=url, method=method, data=data,
+ params=params)
+
+ output = response.json()
+
+ if response.status_code != 200:
+ LOG.debug('full output %s', output)
+ raise PkgDBException(output['error'])
+
+ return output
+
## Actual API calls
def create_collection(self, clt_name, version, clt_status, branchname,
@@ -239,18 +271,7 @@ class PkgDB(object):
'kojiname': kojiname,
}
- req = self.__send_request(
- url='{0}/api/collection/new/'.format(self.url),
- method='POST',
- data=args)
-
- output = req.json()
-
- if req.status_code != 200:
- LOG.debug('full output %s', output)
- raise PkgDBException(output['error'])
-
- return output
+ return self.call_api('/collection/new/', data=args)
def create_package(
self, pkgname, summary, description, review_url, status,
@@ -306,18 +327,7 @@ class PkgDB(object):
if critpath:
args['critpath'] = critpath
- req = self.__send_request(
- url='{0}/api/package/new/'.format(self.url),
- method='POST',
- data=args)
-
- output = req.json()
-
- if req.status_code != 200:
- LOG.debug('full output %s', output)
- raise PkgDBException(output['error'])
-
- return output
+ return self.call_api('/package/new/', data=args)
def get_critpath_packages(self, branches=None, **kwargs):
''' Return the list of package names in the critical path.
@@ -354,18 +364,7 @@ class PkgDB(object):
'format': 'json',
}
- req = self.__send_request(
- url='{0}/api/critpath/'.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
+ return self.call_api('/critpath/', params=args)
def get_collections(self, pattern='*', clt_status=None):
''' Return the list of collections matching the provided criterias.
@@ -387,18 +386,7 @@ class PkgDB(object):
'clt_status': clt_status,
}
- req = self.__send_request(
- url='{0}/api/collections/'.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
+ return self.call_api('/collections/', params=args)
def get_package(self, pkgname, branches=None, eol=False):
''' Return the information of a package matching the provided
@@ -427,18 +415,7 @@ class PkgDB(object):
if eol is True:
args['eol'] = eol
- req = self.__send_request(
- url='{0}/api/package/'.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
+ return self.call_api('/package/', params=args)
def get_packager_acls(
self, packagername, acls=None, eol=False, poc=None,
@@ -503,18 +480,7 @@ class PkgDB(object):
if poc is not None:
args['poc'] = poc
- req = self.__send_request(
- url='{0}/api/packager/acl/'.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
+ return self.call_api('/packager/acl/', params=args)
if page == 'all':
page = 0
@@ -550,18 +516,7 @@ class PkgDB(object):
'packagername': packagername,
}
- req = self.__send_request(
- url='{0}/api/packager/stats/'.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
+ return self.call_api('/packager/stats/', params=args)
def get_packagers(self, pattern='*'):
''' Return the list of packagers matching the provided criterias.
@@ -583,18 +538,7 @@ class PkgDB(object):
'pattern': pattern,
}
- req = self.__send_request(
- url='{0}/api/packagers/'.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
+ return self.call_api('/packagers/', params=args)
def get_packages(
self, pattern='*', branches=None, poc=None, status=None,
@@ -673,18 +617,7 @@ class PkgDB(object):
if eol is True:
args['eol'] = eol
- 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
+ return self.call_api('/packages/', params=args)
if page == 'all':
page = 0
@@ -728,18 +661,7 @@ class PkgDB(object):
'branches': branches,
}
- req = self.__send_request(
- url='{0}/api/package/orphan/'.format(self.url),
- method='POST',
- data=args)
-
- output = req.json()
-
- if req.status_code != 200:
- LOG.debug('full output %s', output)
- raise PkgDBException(output['error'])
-
- return output
+ return self.call_api('/package/orphan/', data=args)
def retire_packages(self, pkgnames, branches):
''' Retires the provided list of packages on the provided list of
@@ -766,18 +688,7 @@ class PkgDB(object):
'branches': branches,
}
- req = self.__send_request(
- url='{0}/api/package/retire/'.format(self.url),
- method='POST',
- data=args)
-
- output = req.json()
-
- if req.status_code != 200:
- LOG.debug('full output %s', output)
- raise PkgDBException(output['error'])
-
- return output
+ return self.call_api('/package/retire/', data=args)
def unorphan_packages(self, pkgnames, branches, poc):
''' Un orphan the provided list of packages on the provided list of
@@ -807,18 +718,7 @@ class PkgDB(object):
'poc': poc,
}
- req = self.__send_request(
- url='{0}/api/package/unorphan/'.format(self.url),
- method='POST',
- data=args)
-
- output = req.json()
-
- if req.status_code != 200:
- LOG.debug('full output %s', output)
- raise PkgDBException(output['error'])
-
- return output
+ return self.call_api('/package/unorphan/', data=args)
def unretire_packages(self, pkgnames, branches):
''' Un retires the provided list of packages on the provided list of
@@ -845,18 +745,7 @@ class PkgDB(object):
'branches': branches,
}
- req = self.__send_request(
- url='{0}/api/package/unretire/'.format(self.url),
- method='POST',
- data=args)
-
- output = req.json()
-
- if req.status_code != 200:
- LOG.debug('full output %s', output)
- raise PkgDBException(output['error'])
-
- return output
+ return self.call_api('/package/unretire/', data=args)
def update_acl(self, pkgname, branches, acls, status, user):
''' Update the specified ACLs, on the specified Branches of the
@@ -899,18 +788,7 @@ class PkgDB(object):
'user': user,
}
- req = self.__send_request(
- url='{0}/api/package/acl/'.format(self.url),
- method='POST',
- data=args)
-
- output = req.json()
-
- if req.status_code != 200:
- LOG.debug('full output %s', output)
- raise PkgDBException(output['error'])
-
- return output
+ return self.call_api('/package/acl/', data=args)
def update_collection_status(self, branch, clt_status):
''' Update the status of the specified collection.
@@ -937,18 +815,8 @@ class PkgDB(object):
'clt_status': clt_status,
}
- req = self.__send_request(
- url='{0}/api/collection/{1}/status/'.format(self.url, branch),
- method='POST',
- data=args)
-
- output = req.json()
-
- if req.status_code != 200:
- LOG.debug('full output %s', output)
- raise PkgDBException(output['error'])
-
- return output
+ return self.call_api('/collection/{0}/status/'.format(branch),
+ data=args)
def update_package_poc(self, pkgnames, branches, poc):
''' Update the point of contact of the specified packages on the
@@ -978,16 +846,4 @@ class PkgDB(object):
'branches': branches,
'poc': poc,
}
-
- req = self.__send_request(
- url='{0}/api/package/acl/reassign/'.format(self.url),
- method='POST',
- data=args)
-
- output = req.json()
-
- if req.status_code != 200:
- LOG.debug('full output %s', output)
- raise PkgDBException(output['error'])
-
- return output
+ return self.call_api('/package/acl/reassign/', data=args)
9 years, 11 months
[packagedb-cli] (6 commits) ...Merge pull request #10 from tyll/simplify
by Pierre-YvesChibon
Summary of changes:
19d75ca... pkgdb2client: Remove duplicate code to call the API
a59ca03... pkgdb2client: Allow low-level API calls
09c1697... pkgdb2client: Support on-demand authentication
92588f7... setup.py: Wrap line
f62a547... Merge pull request #11 from tyll/pep8
f9998cc... Merge pull request #10 from tyll/simplify
9 years, 11 months
[packagedb-cli] Fix incorrect docstring
by Pierre-YvesChibon
commit af8bff69b54115ba0221efa2e404ccde6e3a1295
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Tue May 27 09:50:26 2014 +0200
Fix incorrect docstring
Fixes https://github.com/fedora-infra/packagedb-cli/issues/8
pkgdb2client.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/pkgdb2client.py b/pkgdb2client.py
index 68739c2..4a0d894 100644
--- a/pkgdb2client.py
+++ b/pkgdb2client.py
@@ -635,7 +635,7 @@ class PkgDB(object):
If False, it will return results only for non-EOL collections.
:type eol: boolean
: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.
+ equal to ``all`` then all pages are returned. Defaults to 1.
: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
9 years, 12 months