def run(self, cron_job, force=False, silent=False): """ apply the logic of the schedule and call do() on the CronJobBase class """ if not isinstance(cron_job, CronJobBase): raise Exception( 'The cron_job to be run should be a subclass of %s' % CronJobBase.__class__) if CronJobManager.__should_run_now(cron_job, force): logging.debug("Running cron: %s" % cron_job) cron_log = CronJobLog(code=cron_job.code, start_time=timezone.now()) try: msg = cron_job.do() cron_log.is_success = True cron_log.message = msg or '' except Exception: error = traceback.format_exc() if not silent: print(error) cron_log.is_success = False cron_log.message = error[-1000:] cron_log.ran_at_time = self.user_time if self.user_time else None cron_log.end_time = timezone.now() cron_log.save()
def run(self, cron_job, force=False): """ apply the logic of the schedule and call do() on the CronJobBase class """ if not isinstance(cron_job, CronJobBase): raise Exception, 'The cron_job to be run should be a subclass of %s' % CronJobBase.__class__ if CronJobManager.__should_run_now(cron_job, force): logging.info("Running cron: %s" % cron_job) cron_log = CronJobLog(code=cron_job.code, start_time=timezone.now()) try: msg = cron_job.do() cron_log.is_success = True cron_log.message = msg or '' except Exception: cron_log.is_success = False cron_log.message = traceback.format_exc()[-1000:] cron_log.ran_at_time = self.user_time if self.user_time else None cron_log.end_time = timezone.now() cron_log.save()
def run(self, cron_job): """ apply the logic of the schedule and call do() on the CronJobBase class """ if not isinstance(cron_job, CronJobBase): raise Exception, 'The cron_job to be run should be a subclass of %s' % CronJobBase.__class__ if CronJobManager.__should_run_now(cron_job): logging.info("Running cron: %s" % cron_job) cron_log = CronJobLog(code=cron_job.code, start_time=datetime.now()) try: cron_job.do() cron_log.is_success = True except Exception, e: cron_log.is_success = False cron_log.message = traceback.format_exc()[-1000:] cron_log.end_time = datetime.now() cron_log.save()