From a6de9228b9724bbfc03f03895dc6d8bdec64650e Mon Sep 17 00:00:00 2001 From: Mattia Verga Date: Apr 23 2023 08:00:42 +0000 Subject: Make check-impact output more reliable Signed-off-by: Mattia Verga --- diff --git a/find_inactive_packagers.py b/find_inactive_packagers.py index 59eeab8..360e5b7 100644 --- a/find_inactive_packagers.py +++ b/find_inactive_packagers.py @@ -707,24 +707,51 @@ def step_two(ctx, with_bz_check, close_tickets, from_file): @cli.command() +@click.option('--on-the-fly', 'otf', is_flag=True, default=False, help='Check user activity on the fly.') @click.pass_context -def check_impact(ctx): +def check_impact(ctx, otf): """Report packages expected to be orphaned. This report will show how many packages are going to be orphaned based on the "inactive packager" tickets currently opened. + + Running with the '--on-the-fly' flag active will cause the script to perform a check + about user activity for those users which haven't replied to the ticket yet, so it mimics + the final output of 'step-two'. """ + privacy = ctx.obj['privacy'] fh = logging.FileHandler(f'check_impact_{datetime.now(timezone.utc).strftime("%Y_%m_%d_%H:%M:%S")}.log', 'w+') if ctx.obj['debug']: log.setLevel(logging.DEBUG) log.addHandler(fh) + if otf: + bzclient = Bugzilla(url='https://bugzilla.redhat.com/xmlrpc.cgi') + try: + assert bzclient.logged_in + except Exception: + log.error('ERROR: An authenticated session to bugzilla.redhat.com is required, ' + 'maybe you forgot to provide an API key for logging in? ' + 'Queue processing will stop immediately.') + raise SystemExit() + + try: + fasclient = Client(FASCLIENT_URL) + except Exception: + log.error('ERROR: Unable to connect to fasclient, you probably forgot to obtain ' + 'a Kerberos ticket.') + raise SystemExit() + waiting, pending = _fetch_tickets() affected_packages = [] log.info(f'### Fetching affected users info ###') for u, t in waiting.items(): page = 1 log.info(f'Getting user {u} information') + if otf: + if _check_user_activity(u, privacy=privacy, fasclient=fasclient, bzclient=bzclient): + log.info(f"Activity detected for user {u}.") + continue while True: try: data = session.get(f'https://src.fedoraproject.org/api/0/user/{u}'