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
Show replies by date