Esempio n. 1
0
def valid_cron_scheduler(scheduler_args):
    """Parse a cron schedule."""
    try:
        crontab_kwargs = crontab.parse_crontab(' '.join(scheduler_args))
        return ConfigCronScheduler(**crontab_kwargs)
    except ValueError, e:
        raise ConfigError("Invalid scheduler config: %s" % e)
Esempio n. 2
0
 def test_parse(self, mock_dow, mock_month, mock_monthday, mock_hour, mock_min):
     line = '* * * * *'
     actual = crontab.parse_crontab(line)
     assert_equal(actual['minutes'], mock_min.return_value)
     assert_equal(actual['hours'], mock_hour.return_value)
     assert_equal(actual['monthdays'], mock_monthday.return_value)
     assert_equal(actual['months'], mock_month.return_value)
     assert_equal(actual['weekdays'], mock_dow.return_value)
Esempio n. 3
0
def valid_cron_scheduler(scheduler_args, config_context):
    """Parse a cron schedule."""
    try:
        crontab_kwargs = crontab.parse_crontab(' '.join(scheduler_args))
        return ConfigCronScheduler(original=scheduler_args, **crontab_kwargs)
    except ValueError, e:
        msg = "Invalid cron scheduler %s: %s"
        raise ConfigError(msg % (config_context.path, e))
Esempio n. 4
0
def valid_cron_scheduler(config, config_context):
    """Parse a cron schedule."""
    try:
        crontab_kwargs = crontab.parse_crontab(config.value)
        return ConfigCronScheduler(
            original=config.value, jitter=config.jitter, **crontab_kwargs)
    except ValueError, e:
        msg = "Invalid cron scheduler %s: %s"
        raise ConfigError(msg % (config_context.path, e))
Esempio n. 5
0
 def test_parse_asterisk(self):
     line = '* * * * *'
     actual = crontab.parse_crontab(line)
     assert_equal(actual['minutes'], None)
     assert_equal(actual['hours'], None)
     assert_equal(actual['months'], None)