Exemplo n.º 1
0
    def handle(self, *args, **options):
        msgs = []
        cal_m = CalPermManager()
        account_set = cal_m.perm_loader.account_set
        msgs.append("Total users in Trumba: {0:d}".format(len(account_set)))

        grp_m = GroupManager()
        member_set = grp_m.gws.all_editor_uwnetids
        msgs.append("Total members in UW Group: {0:d}".format(len(member_set)))

        users = []
        for userid in account_set:
            if userid not in member_set:
                users.append(userid)
        msgs.append("Trumba accounts with no membership: {}".format(
            " ".join(users)))

        users = []
        for userid in member_set:
            if userid not in account_set:
                users.append(userid)
        msgs.append("Editor group members with no Trumba account: {}".format(
            " ".join(users)))

        message = "\n".join(msgs)
        sender = get_cronjob_sender()
        send_mail("Trumba accounts vs. UW group members", message, sender,
                  [sender])
        print(message)
Exemplo n.º 2
0
    def handle(self, *args, **options):

        gro_m = GroupManager()
        msgs = []
        msgs.append("Total {0:d} editors".format(len(gro_m.get_all_editors())))

        msgs.append(
            "Seattle has total {0:d} editor, {1:d} showon groups".format(
                len(gro_m.get_campus_editor_groups('sea')),
                len(gro_m.get_campus_showon_groups('sea'))))

        msgs.append(
            "Bothell has total {0:d} editor, {1:d} showon groups".format(
                len(gro_m.get_campus_editor_groups('bot')),
                len(gro_m.get_campus_showon_groups('bot'))))

        msgs.append(
            "Tacoma has total {0:d} editor, {1:d} showon groups".format(
                len(gro_m.get_campus_editor_groups('tac')),
                len(gro_m.get_campus_showon_groups('tac'))))

        sender = get_cronjob_sender()
        message = "\n".join(msgs)
        send_mail("The Calendar Groups Stats", message, sender, [sender])
        print(message)
Exemplo n.º 3
0
    def handle(self, *args, **options):
        msgs = []
        cal_m = CalPermManager()
        msgs.append("Total Bothell calendars: {0:d}".format(
            cal_m.total_calendars('bot')))
        msgs.append("Total Seattle calendars: {0:d}".format(
            cal_m.total_calendars('sea')))
        msgs.append("Total Tacoma calendars: {0:d}".format(
            cal_m.total_calendars('tac')))
        msgs.append("Total editor accounts: {0:d}".format(
            cal_m.total_accounts()))

        for choice in TrumbaCalendar.CAMPUS_CHOICES:
            campus_code = choice[0]
            campus_name = choice[1]
            msgs.append("{}:".format(campus_name))
            if cal_m.exists(campus_code):
                calendars = cal_m.get_campus_calendars(campus_code)
                for cal in calendars:
                    msgs.append("  {0}: {1:d} permissions".format(
                        cal.name, len(cal.permissions)))

        message = "\n".join(msgs)
        sender = get_cronjob_sender()
        send_mail("Calendars Stats", message, sender, [sender])
        print(message)
Exemplo n.º 4
0
 def handle(self, *args, **options):
     try:
         self.run_purge()
     except Exception as ex:
         logger.error(ex)
         time.sleep(60)
         try:
             self.run_purge()
         except Exception as ex1:
             logger.error(ex1)
             sender = get_cronjob_sender()
             send_mail("Purge Inactive User Account", "{}".format(ex1),
                       sender, [sender])
Exemplo n.º 5
0
    def handle(self, *args, **options):
        campus_code = options['campus_code']
        msgs = []
        cal_list = Calendars().campus_calendars[campus_code].values()
        if cal_list is not None:
            for cal in cal_list:
                msgs.append(cal.name)
                for perm in sorted(cal.permissions.values()):
                    msgs.append("    {0} {1}".format(perm.uwnetid, perm.level))

            message = "\n".join(msgs)
            sender = get_cronjob_sender()
            send_mail("Permissions of {} Calendars".format(campus_code),
                      message, sender, [sender])
            print(message)
Exemplo n.º 6
0
 def handle(self, *args, **options):
     sender = get_cronjob_sender()
     try:
         synchr = TrumbaToGws()
         synchr.sync()
         if synchr.has_err():
             err = synchr.get_error_report()
             logger.error(err)
             send_mail(
                 "Sync Trumba calendars to UW groups and members",
                 err, sender, [sender])
     except Exception as ex:
         logger.error(ex)
         send_mail("Sync Trumba calendars to UW groups and members",
                   "{}".format(ex), sender, [sender])
Exemplo n.º 7
0
 def handle(self, *args, **options):
     sender = get_cronjob_sender()
     try:
         synchr = GwsToTrumba()
         synchr.sync()
         if synchr.has_err():
             err = synchr.get_error_report()
             logger.error(err)
             send_mail(
                 "Sync UW Group members to Trumba user and permissions",
                 err, sender, [sender])
     except Exception as ex:
         logger.error(ex)
         send_mail("Sync UW Group members to Trumba user and permissions",
                   "{}".format(ex), sender, [sender])
Exemplo n.º 8
0
    def handle(self, *args, **options):
        userid = options['uwnetid']
        msgs = []
        gro_m = GroupManager()
        for campus_code in (TrumbaCalendar.SEA_CAMPUS_CODE,
                            TrumbaCalendar.BOT_CAMPUS_CODE,
                            TrumbaCalendar.TAC_CAMPUS_CODE):
            for group in gro_m.get_campus_editor_groups(campus_code):
                for member in group.members:
                    if member.name == userid:
                        msgs.append(group.group_ref.name)

            for group in gro_m.get_campus_showon_groups(campus_code):
                for member in group.members:
                    if member.name == userid:
                        msgs.append(group.group_ref.name)

        sender = get_cronjob_sender()
        message = "\n".join(msgs)
        send_mail("The Groups of the User {}".format(userid), message, sender,
                  [sender])
        print(message)
Exemplo n.º 9
0
    def run_purge(self):
        msgs = []
        purger = AccountPurger()
        purger.set_accounts_to_purge()
        msgs.append("Accounts closed in this run:")
        for acc in purger.accounts_to_delete:
            msgs.append("{},{}".format(acc.uwnetid, acc.last_visit))

        purger.sync()
        msgs.append("Total accounts purged: {}".format(
            purger.total_accounts_deleted))
        msgs.append("Total groups updated: {}".format(
            purger.total_groups_purged))

        if purger.has_err():
            err = purger.get_error_report()
            msgs.append(err)
            logger.error(err)

        message = "\n".join(msgs)
        sender = get_cronjob_sender()
        send_mail("Purge Inactive User Accounts", message, sender, [sender])
Exemplo n.º 10
0
 def test_get_cronjob_sender(self):
     with self.settings(CRONJOB_SENDER='none',
                        EMAIL_ADDRESS_DOMAIN='@test.edu'):
         self.assertEqual(get_cronjob_sender(), '*****@*****.**')