Ejemplo n.º 1
0
def start_scheduler():
    """
    cron_like_string_syntax(quoted from kronos.py in tgscheduler package):
        The time and date fields are:

    =============  ==================================
        field                allowed values
    =============  ==================================
    minute         0-59
    hour           0-23
    day of month   1-31
    month          1-12 (or names, see below)
    day of week    0-7 (0 or 7 is Sun, or use names)
    =============  ==================================

    """
    tgscheduler.start_scheduler()
    tgscheduler.add_cron_like_task(update_yields_USTVYM,
                                   '30 23 * * Mon-Fri',
                                   taskname='update_yieldsinfo_daily_UST&VYM')
    tgscheduler.add_cron_like_task(update_yields_CGB,
                                   '0 14 * * *',
                                   taskname='update_yieldsinfo_daily_CGB')
Ejemplo n.º 2
0
 def test_cron_like_task(self):
     """Test adding a simple cron-like task."""
     task = add_cron_like_task(functest, '* * * * *', taskname='every_minute')
     self.assertEqual(task.action, functest)
     self.assertEqual(task.name, 'every_minute')
     self.assertEqual(task.minutes, range(0, 60),
         "Invalid minutes: %s" % task.minutes)
     self.assertEqual(task.hours, range(0, 24),
         "Invalid hours: %s" % task.hours)
     self.assertEqual(task.doms, range(1, 32),
         "Invalid doms: %s" % task.doms)
     self.assertEqual(task.months, range(1, 13),
         "Invalid months: %s" % task.months)
     self.assertEqual(task.dows, range(0, 7),
         "Invalid dows: %s" % task.dows)
Ejemplo n.º 3
0
 def test_cron_like_business_hours(self):
     """Test a crontab for business hours."""
     task = add_cron_like_task(functest, '*/30 8-12,14-18 * * MON-FRI',
         taskname='crontest_business_hours')
     self.assertEqual(task.action, functest)
     self.assertEqual(task.name, 'crontest_business_hours')
     self.assertEqual(task.minutes, [0, 30],
         "Invalid minutes: %s" % task.minutes)
     self.assertEqual(task.hours, [8, 9, 10, 11, 12, 14, 15, 16, 17, 18],
         "Invalid hours: %s" % task.hours)
     self.assertEqual(task.doms, range(1, 32),
         "Invalid doms: %s" % task.doms)
     self.assertEqual(task.months, range(1, 13),
         "Invalid months: %s" % task.months)
     self.assertEqual(task.dows, range(0, 5),
         "Invalid dows: %s" % task.dows)
Ejemplo n.º 4
0
 def test_cron_like_complex(self):
     """Test a more complex crontab."""
     task = add_cron_like_task(functest,
         '5-10,25-30,57 8-12,14-18 2,25-28 Jan-mar,10-12 SuN-wEd',
         taskname='crontest_complex')
     self.assertEqual(task.action, functest)
     self.assertEqual(task.name, 'crontest_complex')
     self.assertEqual(task.minutes,
         [5, 6, 7, 8, 9, 10, 25, 26, 27, 28, 29, 30, 57],
         "Invalid minutes: %s" % task.minutes)
     self.assertEqual(task.hours, [8, 9, 10, 11, 12, 14, 15, 16, 17, 18],
         "Invalid hours: %s" % task.hours)
     self.assertEqual(task.doms, [2, 25, 26, 27, 28],
         "Invalid doms: %s" % task.doms)
     self.assertEqual(task.months, [1, 2, 3, 10, 11, 12],
         "Invalid months: %s" % task.months)
     self.assertEqual(task.dows, [0, 1, 2, 6],
         "Invalid dows: %s" % task.dows)