def test_day_of_week_modifier_with_sunday_start_one(self): options = Options() options.day_of_week_start_index_zero = False self.assertEqual("At 12:23 PM, on the second Sunday of the month", get_description("23 12 * * 1#2", options))
def test_every_2_day_of_the_week_in_range_with_sunday_start_one(self): options = Options() options.day_of_week_start_index_zero = False self.assertEqual( "Every second, every 2 days of the week, Monday through Friday", get_description("* * * ? * 2-6/2", options))
def __init__(self, cronfile): """Initialize CrontabReader Args: cronfile: Path to cronfile Returns: None """ options = Options() options.day_of_week_start_index_zero = False options.use_24hour_time_format = True with open(cronfile) as f: for line in f.readlines(): parsed_line = self.parse_cron_line(line) if parsed_line: print("{} -> {}".format(parsed_line, ExpressionDescriptor(parsed_line, options)))
def __init__(self, cronfile): """Initialize CrontabReader Args: cronfile: Path to cronfile Returns: None """ options = Options() options.day_of_week_start_index_zero = False options.use_24hour_time_format = True with open(cronfile) as f: for line in f.readlines(): parsed_line = self.parse_cron_line(line) if parsed_line: print("{} -> {}".format( parsed_line, ExpressionDescriptor(parsed_line, options)))
from domonic.javascript import Global from domonic.html import * from domonic import domonic from cron_descriptor import Options, ExpressionDescriptor from croniter import croniter from app import * _dark_mode = False # THIS IS GLOBAL. APPLIES TO EVERY USER! in every browser. fight for control! # this gets populated with parsed lines on page refresh _crons = {} # settings for cron_descriptor _options = Options() _options.day_of_week_start_index_zero = False _options.use_24hour_time_format = True class CrontabRenderer(object): rex = re.compile(r"^(\S{1,3}\s+\S{1,3}\s+\S{1,3}\s+\S{1,3}\s+\S{1,3}).+$") def __init__(self, ctab_data): self.ctab_data = ctab_data self.count = 0 _crons = {} self.__call__() # just to force the count def __call__(self): self.count = 0
def register_job(self, workspace, job_class, log_in_db=False): jobkey = "" workspace_name = None if workspace is not None: if type(workspace) is str: jobkey += workspace + '/' workspace_name = workspace.name else: jobkey += workspace.name + '/' workspace_name = workspace.name jobInstance = job_class() jobkey += jobInstance.name jobInstance.job_key = jobkey if workspace is not None: jobInstance.workspace = workspace.name job = { 'job_class': job_class, 'name': jobInstance.name, 'workspace': workspace_name, 'description': jobInstance.description, 'parameters': jobInstance.parameters, 'trigger': 'Internal', 'log_in_db': log_in_db, 'cron': jobInstance.cron, 'day': jobInstance.day, 'week': jobInstance.week, 'day_of_week': jobInstance.day_of_week, 'hour': jobInstance.hour, 'minute': jobInstance.minute, 'second': jobInstance.second } if jobInstance.cron is True: cron_list = [] if job_class.minute is None: cron_list.append("*") else: cron_list.append(job_class.minute) if job_class.hour is None: cron_list.append("*") else: cron_list.append(job_class.hour) if job_class.day is None: cron_list.append("*") else: cron_list.append(job_class.day) cron_list.append("*") if job_class.day_of_week is None: cron_list.append("*") else: cron_list.append(job_class.day_of_week) cron_string = " ".join(cron_list) options = Options() options.throw_exception_on_parse_error = False options.day_of_week_start_index_zero = True options.use_24hour_time_format = True options.casing_type = CasingTypeEnum.LowerCase descripter = ExpressionDescriptor(cron_string, options) logManager.info("Register repetitive job '{}' triggered {}".format( jobkey, descripter.get_description())) self.scheduler.add_job(jobInstance.start_job, kwargs=({ "job_id": str(jobkey) }), id=(str(jobkey)), trigger='cron', replace_existing=True, day=job_class.day, day_of_week=job_class.day_of_week, week=job_class.week, hour=job_class.hour, minute=job_class.minute, second=job_class.second) job['trigger'] = descripter.get_description() self.jobs[str(jobkey)] = ObjDict(job.copy())