[packagedb-cli: 5/14] Add a monitoring action to pkgdb-cli
by Pierre-YvesChibon
commit 009a4e3ed7a525a29256bb6bb3f02cb97a960135
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Jul 9 11:39:49 2015 +0200
Add a monitoring action to pkgdb-cli
This action can be used to either retrieve the current monitoring status
of a package, or update it to the specified status.
pkgdb2client/cli.py | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/pkgdb2client/cli.py b/pkgdb2client/cli.py
index ca6f3ea..05b271b 100644
--- a/pkgdb2client/cli.py
+++ b/pkgdb2client/cli.py
@@ -384,6 +384,19 @@ def setup_parser():
'action)')
parser_pending.set_defaults(func=do_pending)
+ ## Monitoring
+ parser_monitoring = subparsers.add_parser(
+ 'monitoring',
+ help='Get or Set the monitoring of a package')
+ parser_monitoring.add_argument(
+ 'package', help="Name of the package")
+ parser_monitoring.add_argument(
+ 'monitoring', default=None, nargs="?",
+ help="Monitoring status to set the package to, if not specified "
+ "will show the current status, otherwise will update it. "
+ "(can be: 0, 1, nobuild)")
+ parser_monitoring.set_defaults(func=do_monitoring)
+
return parser
@@ -760,6 +773,26 @@ def do_branch(args):
print 'Total: {0} collections'.format(cnt)
+def do_monitoring(args):
+ ''' Retrieve or set the monitoring status of a package from pkgdb.
+
+ '''
+ LOG.info("package : {0}".format(args.package))
+ LOG.info("monitoring : {0}".format(args.monitoring))
+
+ if not args.monitoring:
+ pkg = pkgdbclient.get_package(
+ args.package, branches='master', acls=False
+ )['packages'][0]['package']
+ print "Current monitoring status of {0} is: {1}".format(
+ pkg['name'], pkg['monitor'])
+ else:
+ output = pkgdbclient.set_monitoring_status(
+ args.package, args.monitoring)
+ print output.get(
+ 'messages', 'Invalid output returned, please contact an admin')
+
+
def main():
''' Main function '''
# Set up parser for global args
8 years, 8 months
[packagedb-cli: 4/14] Adjust the get_package method to support no returning all the ACLs
by Pierre-YvesChibon
commit db32a6b2f2a64e0bf9cdf1d55a2a7a36d94f7d48
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Jul 9 11:39:22 2015 +0200
Adjust the get_package method to support no returning all the ACLs
pkgdb2client/__init__.py | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/pkgdb2client/__init__.py b/pkgdb2client/__init__.py
index 25d875d..c8fa809 100644
--- a/pkgdb2client/__init__.py
+++ b/pkgdb2client/__init__.py
@@ -520,7 +520,7 @@ class PkgDB(object):
return self.handle_api_call('/collections/', params=args)
- def get_package(self, pkgname, branches=None, eol=False):
+ def get_package(self, pkgname, branches=None, eol=False, acls=True):
''' Return the information of a package matching the provided
criterias.
@@ -534,6 +534,9 @@ class PkgDB(object):
EOL).
If False, it will return results only for non-EOL collections.
:type eol: boolean
+ :kwarg acls: a boolean to specify whether to include ACLs in the
+ data returned. Defaults to ``True``.
+ :type acls: boolean
:return: the json object returned by the API
:rtype: dict
:raise PkgDBException: if the API call does not return a http code
@@ -543,6 +546,7 @@ class PkgDB(object):
args = {
'pkgname': pkgname,
'branches': branches,
+ 'acls': acls,
}
if eol is True:
args['eol'] = eol
8 years, 8 months
[packagedb-cli: 3/14] Add a method in pkgdb2client to set the monitoring status of a package
by Pierre-YvesChibon
commit a3ef8c0f0b42ac1beee5aa78870bccd6b91ccde9
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Jul 9 11:22:42 2015 +0200
Add a method in pkgdb2client to set the monitoring status of a package
pkgdb2client/__init__.py | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/pkgdb2client/__init__.py b/pkgdb2client/__init__.py
index 6b2ed8d..25d875d 100644
--- a/pkgdb2client/__init__.py
+++ b/pkgdb2client/__init__.py
@@ -1086,3 +1086,26 @@ class PkgDB(object):
args['username'] = username
return self.handle_api_call('/pendingacls', params=args)
+ def set_monitoring_status(self, pkgname, monitoring):
+ ''' Set / Remove the monitoring status of a package.
+
+ :arg pkgname: The name of the package
+ :type pkgname: str
+ :arg monitoring: The monitoring status to set the package to. Can
+ be any of: True, 1, False, 0, or 'nobuild'.
+ :type monitoring: str
+
+ '''
+ valid = ['true', '1', 'false', '0', 'nobuild']
+ if str(monitoring).lower() not in valid:
+ raise PkgDBException(
+ 'Invalid monitoring status specified, %s is not in: %s' % (
+ monitoring, ', '.join(valid))
+ )
+ args = {
+ 'package': pkgname,
+ 'status': monitoring,
+ }
+ return self.handle_api_call(
+ '/package/%s/monitor/%s' % (pkgname, monitoring), data=args)
+
8 years, 8 months
[packagedb-cli: 2/14] Merge pull request #35 from fedora-infra/fail-on-json
by Pierre-YvesChibon
commit 97bece316d3b333d58044acbe2e3a842c99bb213
Merge: fe33a6d 6c44b7e
Author: Ralph Bean <rbean(a)redhat.com>
Date: Wed May 13 15:19:26 2015 -0400
Merge pull request #35 from fedora-infra/fail-on-json
Raise an exception when unable to decode JSON.
pkgdb2client/__init__.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
8 years, 8 months
[packagedb-cli: 1/14] Raise an exception when unable to decode JSON.
by Pierre-YvesChibon
commit 6c44b7e9e9174559fb5268801ce1fc79db38c35d
Author: Ralph Bean <rbean(a)redhat.com>
Date: Sat May 9 18:49:11 2015 -0400
Raise an exception when unable to decode JSON.
pkgdb2client/__init__.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/pkgdb2client/__init__.py b/pkgdb2client/__init__.py
index 0254288..6b2ed8d 100644
--- a/pkgdb2client/__init__.py
+++ b/pkgdb2client/__init__.py
@@ -348,8 +348,8 @@ class PkgDB(object):
try:
output = response.json()
except Exception, err:
- LOG.debug('Error while decoding the JSON: {0}'.format(err))
LOG.debug(response.text)
+ raise PkgDBException('Error while decoding JSON: {0}'.format(err))
if response.status_code != 200:
LOG.debug('full output: {0}'.format(output))
8 years, 8 months
[packagedb-cli] (14 commits) ...Merge pull request #38 from tyll/lxml
by Pierre-YvesChibon
Summary of changes:
6c44b7e... Raise an exception when unable to decode JSON.
97bece3... Merge pull request #35 from fedora-infra/fail-on-json
a3ef8c0... Add a method in pkgdb2client to set the monitoring status o
db32a6b... Adjust the get_package method to support no returning all t
009a4e3... Add a monitoring action to pkgdb-cli
a88c42d... Check if the pkgdb instance we're calling support setting m
a30001b... Adjust the error message returned
9e7f0a2... Merge pull request #36 from fedora-infra/monitoring
6906ac5... Add a set_koschei_status to the module pkgdb2client
4fc79b5... Add a koschei action to pkgdb-cli
15fe2d1... Check if the pkgdb2 instance called support koschei monitor
ba99e27... Merge pull request #37 from fedora-infra/koschei_monitoring
303f2a9... Set default BeautifulSoup parser
768962f... Merge pull request #38 from tyll/lxml
8 years, 8 months