def __init__(self, buildout, name, options): self.options = options options['entry'] = '%s\t%s' % (options['times'], options['command']) readcrontab = self.options.get('readcrontab', None) writecrontab = self.options.get('writecrontab', None) identifier = self.options.get('identifier', None) if identifier is None: self.options['identifier'] = '%s [%s]' % ( buildout['buildout']['directory'], name) self.crontab = UserCrontabManager( readcrontab, writecrontab, identifier=self.options['identifier'])
def __init__(self, buildout, name, options): self.options = options options['entry'] = '%s\t%s' % (options['times'], options['command']) self.comment = options.get('comment') if not bool_option(self.options, 'enabled', default=True): self.options['entry'] = '# ' + self.options['entry'] # readcrontab and writecrontab are solely for testing. readcrontab = self.options.get('readcrontab', None) writecrontab = self.options.get('writecrontab', None) self.options['identifier'] = '%s [%s]' % ( buildout['buildout']['directory'], name) self.crontab = UserCrontabManager( readcrontab, writecrontab, identifier=self.options['identifier'])
def uninstall_usercrontab(name, options): readcrontab = options.get('readcrontab', None) writecrontab = options.get('writecrontab', None) identifier = options.get('identifier', 'NO IDENTIFIER') crontab = UserCrontabManager(readcrontab, writecrontab, identifier=identifier) crontab.read_crontab() nuked = crontab.del_entry(options['entry']) if nuked == 0: logging.getLogger(name).warning( "WARNING: Did not find a crontab-entry during uninstall; " "please check manually if everything was removed correctly") elif nuked > 1: logging.getLogger(name).error( "FATAL ERROR: Found more than one matching crontab-entry during " "uninstall; please resolve manually.\nMatched lines: %s", (options['entry'])) raise RuntimeError( "Found more than one matching crontab-entry during uninstall") crontab.write_crontab()