#NEWLINE# def at( * args , **kwargs ) : #NEWLINE# #INDENT# "\n    Add a job to the queue.\n\n    The 'timespec' follows the format documented in the\n    at(1) manpage.\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' at.at <timespec> <cmd> [tag=<tag>] [runas=<user>]\n        salt '*' at.at 12:05am '/sbin/reboot' tag=reboot\n        salt '*' at.at '3:05am +3 days' 'bin/myscript' tag=nightly runas=jim\n    " #NEWLINE# if ( len ( args ) < 2 ) : #NEWLINE# #INDENT# return { #NEWLINE# #INDENT# 'jobs' : [ ] , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# binary = salt . utils . which ( 'at' ) #NEWLINE# if ( not binary ) : #NEWLINE# #INDENT# return "'at.at' is not available." #NEWLINE# #UNINDENT# if ( 'tag' in kwargs ) : #NEWLINE# #INDENT# stdin = '### SALT: {0}\n{1}' . format ( kwargs [ 'tag' ] , ' ' . join ( args [ 1 : ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# stdin = ' ' . join ( args [ 1 : ] ) #NEWLINE# #UNINDENT# cmd = [ binary , args [ 0 ] ] #NEWLINE# cmd_kwargs = { #NEWLINE# #INDENT# 'stdin' : stdin , #NEWLINE# 'python_shell' : False , #NEWLINE# #UNINDENT# } #NEWLINE# if ( 'runas' in kwargs ) : #NEWLINE# #INDENT# cmd_kwargs [ 'runas' ] = kwargs [ 'runas' ] #NEWLINE# #UNINDENT# output = __salt__ [ 'cmd.run' ] ( cmd , ** cmd_kwargs ) #NEWLINE# if ( output is None ) : #NEWLINE# #INDENT# return "'at.at' is not available." #NEWLINE# #UNINDENT# if output . endswith ( 'Garbled time' ) : #NEWLINE# #INDENT# return { #NEWLINE# #INDENT# 'jobs' : [ ] , #NEWLINE# 'error' : 'invalid timespec' , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# if output . startswith ( 'warning: commands' ) : #NEWLINE# #INDENT# output = output . splitlines ( ) [ 1 ] #NEWLINE# #UNINDENT# if output . startswith ( 'commands will be executed' ) : #NEWLINE# #INDENT# output = output . splitlines ( ) [ 1 ] #NEWLINE# #UNINDENT# output = output . split ( ) [ 1 ] #NEWLINE# if ( __grains__ [ 'os' ] in BSD ) : #NEWLINE# #INDENT# return atq ( str ( output ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return atq ( int ( output ) )