Trees | Indices | Help |
---|
|
1 import sys 2 import datetime 3 import click 4 from coprs import db, app 5 from coprs.logic import coprs_logic 6 from coprs.mail import send_mail, OutdatedChrootMessage 7 8 9 @click.command() 10 @click.option( 11 "--dry-run/--no-dry-run", 12 default=False, 13 help="Do not actually notify the people, but rather print information on stdout" 14 ) 15 @click.option( 16 "--email", "-e", "email_filter", 17 help="Notify only " 18 ) 19 @click.option( 20 "--all/--not-all", 21 default=False, 22 help="Notify all (even the recently notified) relevant people" 23 )25 """ 26 Notify all admins of projects with builds in outdated chroots about upcoming deletion. 27 """ 28 29 if not dry_run: 30 dev_instance_warning(email_filter) 31 32 notifier = DryRunNotifier() if dry_run else Notifier() 33 outdated = coprs_logic.CoprChrootsLogic.filter_outdated(coprs_logic.CoprChrootsLogic.get_multiple()) 34 for user, chroots in get_user_chroots_map(outdated, email_filter).items(): 35 chroots = filter_chroots([chroot for chroot in chroots], all) 36 if not chroots: 37 continue 38 chroots.sort(key=lambda x: x.copr.full_name) 39 notifier.notify(user, chroots) 40 notifier.store_timestamp(chroots)4143 user_chroot_map = {} 44 for chroot in chroots: 45 for admin in coprs_logic.CoprPermissionsLogic.get_admins_for_copr(chroot.copr): 46 if email_filter and admin.mail not in email_filter: 47 continue 48 if admin not in user_chroot_map: 49 user_chroot_map[admin] = [] 50 user_chroot_map[admin].append(chroot) 51 return user_chroot_map5254 if all: 55 return chroots 56 57 filtered = [] 58 for chroot in chroots: 59 if not chroot.delete_notify: 60 filtered.append(chroot) 61 continue 62 63 # Skip the chroot if was notified in less than `n` days 64 now = datetime.datetime.now() 65 if (now - chroot.delete_notify).days >= 80: 66 filtered.append(chroot) 67 68 return filtered6971 if app.config["ENV"] != "production" and not email_filter: 72 sys.stderr.write("I will not let you send emails to all Copr users from the dev instance!\n") 73 sys.stderr.write("Please use this command with -e myself@foo.bar\n") 74 sys.exit(1)75 86 95
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 | http://epydoc.sourceforge.net |