Beispiel #1
0
def write_crontab(tasks, user='******'):
    """
    Write tasks to crontab file with shell command and stdin.
    tasks - list of instance Task class or string.
    """
    lines = '\n'.join([str(task) for task in tasks])
    lines += '\n'
    return shell_stdin('crontab -', lines)[1]
Beispiel #2
0
def write_crontab(tasks, user='******'):
    """
    Write tasks to crontab file with shell command and stdin.
    tasks - list of instance Task class or string.
    """
    lines = '\n'.join([str(task) for task in tasks])
    lines += '\n'
    return shell_stdin('crontab - -u ' + user, lines)[1]
Beispiel #3
0
def fix_crontab():
    """
    Read and comment wrong for crontab string.
    """
    cron_lines = filter(None, shell('crontab -l').split('\n'))
    fixed_lines = []
    for line in cron_lines:
        if shell_stdin('crontab -', line + '\n')[1]:
            fixed_lines.append('#' + line)
        else:
            fixed_lines.append(line)
    write_crontab(fixed_lines)
    return 0
Beispiel #4
0
def fix_crontab(user='******'):
    """
    Read and comment wrong for crontab string.
    """
    cron_lines = filter(None, shell('crontab -l -u ' + user).split('\n'))
    fixed_lines = []
    for line in cron_lines:
        if shell_stdin('crontab - -u ' + user, line + '\n')[1]:
            fixed_lines.append('#' + line)
        else:
            fixed_lines.append(line)
    write_crontab(fixed_lines, user)
    return 0