def setup_scheduler(): """Sets up the APScheduler""" log = logging.getLogger('apscheduler') try: accounts = Account.query.filter(Account.third_party == False).filter( Account.active == True).all() # noqa accounts = [account.name for account in accounts] for account in accounts: app.logger.debug("Scheduler adding account {}".format(account)) rep = Reporter(account=account) delay = app.config.get('REPORTER_START_DELAY', 10) for period in rep.get_intervals(account): scheduler.add_interval_job(run_change_reporter, minutes=period, start_date=datetime.now() + timedelta(seconds=delay), args=[[account], period]) auditors = [] for monitor in all_monitors(account): auditors.extend(monitor.auditors) scheduler.add_cron_job(_audit_changes, hour=10, day_of_week="mon-fri", args=[account, auditors, True]) # Clear out old exceptions: scheduler.add_cron_job(_clear_old_exceptions, hour=3, minute=0) except Exception as e: app.logger.warn("Scheduler Exception: {}".format(e)) app.logger.warn(traceback.format_exc()) store_exception("scheduler", None, e)
def setup_scheduler(): """Sets up the APScheduler""" log = logging.getLogger('apscheduler') try: accounts = Account.query.filter(Account.third_party == False).filter(Account.active == True).all() # noqa accounts = [account.name for account in accounts] for account in accounts: print "Scheduler adding account {}".format(account) rep = Reporter(accounts=[account]) for period in rep.get_intervals(account): scheduler.add_interval_job( run_change_reporter, minutes=period, start_date=datetime.now()+timedelta(seconds=2), args=[account, period] ) auditors = [a for (_, a) in rep.get_watchauditors(account) if a] if auditors: scheduler.add_cron_job(_audit_changes, hour=10, day_of_week="mon-fri", args=[account, auditors, True]) # Clear out old exceptions: scheduler.add_cron_job(_clear_old_exceptions, hour=3, minute=0) except Exception as e: app.logger.warn("Scheduler Exception: {}".format(e)) app.logger.warn(traceback.format_exc()) store_exception("scheduler", None, e)
def setup_scheduler(): """Sets up the APScheduler""" log = logging.getLogger('apscheduler') try: accounts = Account.query.filter(Account.third_party == False).filter(Account.active == True).all() # noqa accounts = [account.name for account in accounts] for account in accounts: app.logger.debug("Scheduler adding account {}".format(account)) rep = Reporter(account=account) delay = app.config.get('REPORTER_START_DELAY', 10) for period in rep.get_intervals(account): scheduler.add_interval_job( run_change_reporter, minutes=period, start_date=datetime.now()+timedelta(seconds=delay), args=[[account], period] ) auditors = [] for monitor in all_monitors(account): auditors.extend(monitor.auditors) scheduler.add_cron_job(_audit_changes, hour=10, day_of_week="mon-fri", args=[account, auditors, True]) # Clear out old exceptions: scheduler.add_cron_job(_clear_old_exceptions, hour=3, minute=0) except Exception as e: app.logger.warn("Scheduler Exception: {}".format(e)) app.logger.warn(traceback.format_exc()) store_exception("scheduler", None, e)