From f5ae9c8f2cb03cfba7ac68df484bafc6e4b3a0fb Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Dec 17 2024 13:32:06 +0000 Subject: [cli] list-repo-requests --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 562aae5..891ac17 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -7455,6 +7455,56 @@ def _get_watcher(goptions, options, *a, **kw): return watcher +def anon_handle_list_repo_requests(goptions, session, args): + """[monitor] List current repo requests""" + usage = "usage: %prog list-repo-requests" + parser = OptionParser(usage=get_usage_str(usage)) + parser.add_option("--quiet", action="store_true", default=goptions.quiet, + help="Print without headers") + parser.add_option("--utc", action="store_true", + help="Display times in UTC") + parser.add_option("--inactive", action="store_true", + help="Display also inactive requests") + (options, args) = parser.parse_args(args) + + ensure_connection(session, goptions) + clauses = [] + if not options.inactive: + clauses.append(['active', 'IS', True]) + requests = session.repo.queryQueue(clauses, opts={'order': 'id'}) + mask = '%(active)-3s %(created)-25s %(updated)-25s %(task)10s %(tag)-30s' + if not options.quiet: + s = mask % { + 'active': 'Act', + 'created': 'Created', + 'updated': 'Updated', + 'tag': 'Tag', + 'task': 'Task', + } + print(s) + print('-' * len(s)) + tags = [] + with session.multicall() as m: + for req in requests: + tags.append(m.getTag(req['tag_id'])) + now = datetime.now().timestamp() + for req, tag in zip(requests, tags): + req['active'] = [' ', '*'][req['active']] + if options.utc: + req['created'] = time.asctime(datetime.fromtimestamp(req['create_ts'], + tzutc()).timetuple()) + req['updated'] = now - req.get('update_ts', req['create_ts']) + else: + req['created'] = time.asctime(time.localtime(req['create_ts'])) + req['updated'] = time.asctime(time.localtime(req['update_ts'])) + if tag.result: + req['tag'] = tag.result['name'] + else: + req['tag'] = '' + req['task'] = req['task_id'] or '' + print(mask % req) + + def handle_regen_repo(goptions, session, args): "[admin] Generate a current repo if there is not one" usage = "usage: %prog regen-repo [options] " diff --git a/tests/test_cli/data/list-commands.txt b/tests/test_cli/data/list-commands.txt index ef70eb5..fa810b7 100644 --- a/tests/test_cli/data/list-commands.txt +++ b/tests/test_cli/data/list-commands.txt @@ -138,6 +138,7 @@ monitor commands: block-notification Block user's notifications edit-notification Edit user's notification list-notifications List user's notifications and blocks + list-repo-requests List current repo requests remove-notification Remove user's notifications scheduler-info Show information about scheduling scheduler-logs Query scheduler logs