def at(*args, **kwargs):
 if (len(args) < 2):
  return {'jobs': []}
 if ('tag' in kwargs):
  stdin = '### SALT: {0}\n{1}'.format(kwargs['tag'], ' '.join(args[1:]))
 else:
  stdin = ' '.join(args[1:])
 cmd_kwargs = {'stdin': stdin, 'python_shell': False}
 if ('runas' in kwargs):
  cmd_kwargs['runas'] = kwargs['runas']
 res = __salt__['cmd.run_all']('at "{timespec}"'.format(timespec=args[0]), **cmd_kwargs)
 if (res['retcode'] > 0):
  if ('bad time specification' in res['stderr']):
   return {'jobs': [], 'error': 'invalid timespec'}
  return {'jobs': [], 'error': res['stderr']}
 else:
  jobid = res['stderr'].splitlines()[1]
  jobid = str(jobid.split()[1])
  return atq(jobid)

def at ( * args , ** kwargs ) : if ( len ( args ) < 2 ) : return { 'jobs' : [ ] } if ( 'tag' in kwargs ) : stdin = '### SALT: {0}\n{1}' . format ( kwargs [ 'tag' ] , ' ' . join ( args [ 1 : ] ) ) else : stdin = ' ' . join ( args [ 1 : ] ) cmd_kwargs = { 'stdin' : stdin , 'python_shell' : False } if ( 'runas' in kwargs ) : cmd_kwargs [ 'runas' ] = kwargs [ 'runas' ] res = __salt__ [ 'cmd.run_all' ] ( 'at "{timespec}"' . format ( timespec = args [ 0 ] ) , ** cmd_kwargs ) if ( res [ 'retcode' ] > 0 ) : if ( 'bad time specification' in res [ 'stderr' ] ) : return { 'jobs' : [ ] , 'error' : 'invalid timespec' } return { 'jobs' : [ ] , 'error' : res [ 'stderr' ] } else : jobid = res [ 'stderr' ] . splitlines ( ) [ 1 ] jobid = str ( jobid . split ( ) [ 1 ] ) return atq ( jobid )
usage: {{ dictionary|at:key}} .