def set_cron_schedule(task, minutes, hour, day_of_week): task.task = 'w3af_webui.tasks.scan_create_start' cron = CrontabSchedule.from_schedule(crontab(minute=minutes, hour=hour, day_of_week=day_of_week, )) cron.save() task.crontab = cron task.interval = None task.save()
def set_cron_schedule(task, minutes, hour, day_of_week): task.task = 'w3af_webui.tasks.scan_create_start' cron = CrontabSchedule.from_schedule( crontab( minute=minutes, hour=hour, day_of_week=day_of_week, )) cron.save() task.crontab = cron task.interval = None task.save()
def __call__(self, apps, schema_editor): from djcelery.models import PeriodicTask from djcelery.models import CrontabSchedule tab = CrontabSchedule.from_schedule(self.config.schedule) tab.save() PeriodicTask( enabled=not self.config.disabled, name=self.config.task_name, task=self.config.task, description=self.config.description, args=json.dumps([1, self.config.label]), # Note 1 should always be the system user crontab=tab, ).save()
def __call__(self, apps, schema_editor): from djcelery.models import PeriodicTask from djcelery.models import CrontabSchedule tab = CrontabSchedule.from_schedule(self.config.schedule) tab.save() PeriodicTask( enabled=not self.config.disabled, name=self.config.task_name, task=self.config.task, description=self.config.description, args=json.dumps([1, self.config.label ]), # Note 1 should always be the system user crontab=tab, ).save()
def schedule_harvest_task(self, label, disabled): task_name = '{} harvester task'.format(label) tab = CrontabSchedule.from_schedule(crontab(minute=0, hour=0)) tab.save() PeriodicTask.objects.update_or_create( name=task_name, defaults={ 'enabled': not disabled, 'task': 'share.tasks.HarvesterTask', 'description': 'Harvesting', 'args': json.dumps([1, label]), # Note 1 should always be the system user 'crontab': tab, } )
def get_schedule(crontab): """Get djcelery CrontabSchedule object TODO: make real crontab validation """ crontab_parts = crontab.split(" ") schedule_dict = { "minute": "*", "hour": "*", "day_of_week": "*", "day_of_month": "*", "month_of_year": "*", } if len(crontab_parts)==5: schedule_dict["minute"] = crontab_parts[0] schedule_dict["hour"] = crontab_parts[1] schedule_dict["day_of_week"] = crontab_parts[2] schedule_dict["day_of_month"] = crontab_parts[3] schedule_dict["month_of_year"] = crontab_parts[4] new_schedule = CrontabSchedule.from_schedule(schedules.crontab(**schedule_dict)) new_schedule.save() return new_schedule
def create_model_crontab(schedule, **kwargs): return create_model(crontab=CrontabSchedule.from_schedule(schedule), **kwargs)
def create_model_crontab(schedule, **kwargs): return create_model(crontab=CrontabSchedule.from_schedule(schedule), **kwargs)
def create_model_crontab(schedule, **kwargs): crontab = CrontabSchedule.from_schedule(schedule) crontab.save() return create_model(crontab=crontab, **kwargs)