def add_task(name, timespec, user, command, environment=None):
 if (environment is None):
  environment = {}
 lines = []
 for (key, value) in environment.iteritems():
  lines.append(('%(key)s=%(value)s\n' % locals()))
 lines.append(('%(timespec)s %(user)s %(command)s\n' % locals()))
 from fabtools.require.files import file as require_file
 require_file(path=('/etc/cron.d/%(name)s' % locals()), contents=''.join(lines), owner='root', mode='0644', use_sudo=True)

def add_task ( name , timespec , user , command , environment = None ) : if ( environment is None ) : environment = { } lines = [ ] for ( key , value ) in environment . iteritems ( ) : lines . append ( ( '%(key)s=%(value)s\n' % locals ( ) ) ) lines . append ( ( '%(timespec)s %(user)s %(command)s\n' % locals ( ) ) ) from fabtools . require . files import file as require_file require_file ( path = ( '/etc/cron.d/%(name)s' % locals ( ) ) , contents = '' . join ( lines ) , owner = 'root' , mode = '0644' , use_sudo = True )
add a cron task .