Example #1
0
def _update_crontab():
    lines = []
    for task in db.task_get_all():
        action = actions.actions_by_id[task.action_id]
        lines.append('%s * * %s\n' % (task.cron_schedule, action.command(task)))

    PIPE = subprocess.PIPE
    p = subprocess.Popen(['crontab', '-'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
    stdout, stderr = p.communicate(''.join(lines))
    if p.returncode:
       app.logger.error('Error running crontab update: %s' % p.returncode)
    if stdout:
        app.logger.error('Output from crontab update:\n\n%s' % stdout)
    if stderr:
        app.logger.error('Error from crontab update:\n\n%s' % stderr)
Example #2
0
def crontab():
    DAY_OF_MONTH = "*"
    MONTH = "*"

    lines = []
    for task in db.task_get_all():

        if CFG.cron.schedule_override:
            schedule = CFG.cron.schedule_override
        else:
            minute, hour, day_of_week = task.cron_schedule.split(' ')
            schedule = ' '.join([minute, hour, DAY_OF_MONTH, MONTH, day_of_week])

        bin_path = os.path.join(CFG.cron.tempo_enqueue_path, 'tempo-enqueue')
        lines.append(' '.join([schedule, bin_path, task.uuid]))

    # Trailing new line is required by cron format
    lines.append('')
    return '\n'.join(lines)
Example #3
0
def task_index():
    """Returns a list of all of the tasks"""
    return _new_response({resources_name: [_make_task_dict(t)
                          for t in db.task_get_all()]})
Example #4
0
def task_index():
    """Returns a list of all of the tasks"""
    return _new_response({resources_name: db.task_get_all()})