| |
@@ -7455,6 +7455,56 @@
|
| |
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] <tag>"
|
| |
Basic monitoring command. It is for further discussion if displayed fields are the best ones (+ unit tests later)