def test_read_empty_crontab(self, mock): """Test reading from an empty crontab.""" mock.return_value = Mock( stdout=StringIO(''), stderr=StringIO('crontab: no crontab for <user>')) read_crontab()
def test_read_empty_crontab(self, mock): """Test reading from an empty crontab.""" mock.return_value = Mock( stdout=StringIO(''), stderr=StringIO('crontab: no crontab for <user>') ) read_crontab()
def test_read_crontab(self, mock): """Test reading from the crontab.""" mock.return_value = Mock( stdout=StringIO('crontab: installing new crontab'), stderr=StringIO('')) read_crontab() mock.assert_called_with(args='crontab -l', shell=True, stdout=PIPE, stderr=PIPE)
def test_read_crontab(self, mock): """Test reading from the crontab.""" mock.return_value = Mock( stdout=StringIO('crontab: installing new crontab'), stderr=StringIO('') ) read_crontab() mock.assert_called_with( args='crontab -l', shell=True, stdout=PIPE, stderr=PIPE )
def uninstall(): """ Uninstall tasks from cron. """ current_crontab = read_crontab() new_crontab = find_existing_jobs(current_crontab) if new_crontab: write_crontab(new_crontab) else: delete_crontab()
def install(): """ Register tasks with cron. """ load() current_crontab = read_crontab() new_crontab = '' for task in tasks: new_crontab += '%s\n' % task['fn'].cron_expression write_crontab(current_crontab + new_crontab)
def install(): """ Register tasks with cron. """ load() current_crontab = six.u(read_crontab()) new_crontab = '' for task in tasks: new_crontab += '%s\n' % task['fn'].cron_expression write_crontab(current_crontab + new_crontab)
def install(): """ Register tasks with cron. """ load() current_crontab = six.u(read_crontab()) new_crontab = '' for env_line in KRONOS_ENV.splitlines(): new_crontab += '# KRONOS_ENV_BREAD_CRUMB for next\n%s\n' % env_line for task in tasks: new_crontab += '%s\n' % task['fn'].cron_expression write_crontab(current_crontab + new_crontab)
def uninstall(): """ Uninstall tasks from cron. """ current_crontab = read_crontab() new_crontab = '' for line in current_crontab.split('\n')[:-1]: if '%(python)s %(project_path)s/manage.py runtask' % { 'python': sys.executable, 'project_path': PROJECT_PATH, } not in line: new_crontab += '%s\n' % line if new_crontab: write_crontab(new_crontab) else: delete_crontab()
def uninstall(): """ Uninstall tasks from cron. """ current_crontab = read_crontab() new_crontab = '' for line in current_crontab.split('\n')[:-1]: if '%(python)s %(manage)s runtask' % { 'python': KRONOS_PYTHON, 'manage': KRONOS_MANAGE, } not in line: new_crontab += '%s\n' % line if new_crontab: write_crontab(new_crontab) else: delete_crontab()
def uninstall(): """ Uninstall tasks from cron. """ current_crontab = read_crontab() new_crontab = '' for line in six.u(current_crontab).split('\n')[:-1]: exp = '%(python)s %(manage)s runtask' % { 'python': KRONOS_PYTHON, 'manage': KRONOS_MANAGE, } if '$KRONOS_BREAD_CRUMB' not in line and exp not in line: new_crontab += '%s\n' % line if new_crontab: write_crontab(new_crontab) else: delete_crontab()
def setup(): global crontab_backup crontab_backup = read_crontab()
def test_write_crontab(): """Test writing to the crontab.""" write_crontab("* * * * * echo\n") assert read_crontab() == '* * * * * echo\n'
def test_unintalltasks(): """Test uninstalling tasks via the ``uninstalltasks`` command.""" call_command('uninstalltasks') for task in tasks: assert task.cron_expression not in read_crontab()
def test_read_crontab(): """Test reading from the crontab.""" assert read_crontab() == crontab_backup