<s> '''<STR_LIT>''' <EOL> from __future__ import absolute_import <EOL> import salt . loader <EOL> import salt . utils <EOL> import salt . utils . jid <EOL> from salt . ext . six . moves import range <EOL> def wait ( name , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> return { '<STR_LIT:name>' : name , <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT:result>' : True , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> watch = salt . utils . alias_function ( wait , '<STR_LIT>' ) <EOL> def run ( name , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> ret = { '<STR_LIT:name>' : name , <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:result>' : None } <EOL> if name not in __salt__ : <EOL> ret [ '<STR_LIT>' ] = '<STR_LIT>' . format ( name ) <EOL> ret [ '<STR_LIT:result>' ] = False <EOL> return ret <EOL> if __opts__ [ '<STR_LIT:test>' ] : <EOL> ret [ '<STR_LIT>' ] = '<STR_LIT>' . format ( name ) <EOL> return ret <EOL> aspec = salt . utils . args . get_function_argspec ( __salt__ [ name ] ) <EOL> args = [ ] <EOL> defaults = { } <EOL> arglen = <NUM_LIT:0> <EOL> deflen = <NUM_LIT:0> <EOL> if isinstance ( aspec . args , list ) : <EOL> arglen = len ( aspec . args ) <EOL> if isinstance ( aspec . defaults , tuple ) : <EOL> deflen = len ( aspec . defaults ) <EOL> for ind in range ( arglen - <NUM_LIT:1> , - <NUM_LIT:1> , - <NUM_LIT:1> ) : <EOL> minus = arglen - ind <EOL> if deflen - minus > - <NUM_LIT:1> : <EOL> defaults [ aspec . args [ ind ] ] = aspec . defaults [ - minus ] <EOL> for arg in defaults : <EOL> if arg == '<STR_LIT:name>' : <EOL> if '<STR_LIT>' in kwargs : <EOL> defaults [ arg ] = kwargs . pop ( '<STR_LIT>' ) <EOL> elif arg == '<STR_LIT>' : <EOL> if '<STR_LIT>' in kwargs : <EOL> defaults [ arg ] = kwargs . pop ( '<STR_LIT>' ) <EOL> elif arg == '<STR_LIT:state>' : <EOL> if '<STR_LIT>' in kwargs : <EOL> defaults [ arg ] = kwargs . pop ( '<STR_LIT>' ) <EOL> if arg in kwargs : <EOL> defaults [ arg ] = kwargs . pop ( arg ) <EOL> missing = set ( ) <EOL> for arg in aspec . args : <EOL> if arg == '<STR_LIT:name>' : <EOL> rarg = '<STR_LIT>' <EOL> elif arg == '<STR_LIT>' : <EOL> rarg = '<STR_LIT>' <EOL> elif arg == '<STR_LIT>' : <EOL> rarg = '<STR_LIT>' <EOL> elif arg == '<STR_LIT:state>' : <EOL> rarg = '<STR_LIT>' <EOL> else : <EOL> rarg = arg <EOL> if rarg not in kwargs and arg not in defaults : <EOL> missing . add ( rarg ) <EOL> continue <EOL> if arg in defaults : <EOL> args . append ( defaults [ arg ] ) <EOL> else : <EOL> args . append ( kwargs . pop ( rarg ) ) <EOL> if missing : <EOL> comment = '<STR_LIT>' <EOL> for arg in missing : <EOL> comment += '<STR_LIT>' . format ( arg ) <EOL> ret [ '<STR_LIT>' ] = comment <EOL> ret [ '<STR_LIT:result>' ] = False <EOL> return ret <EOL> if aspec . varargs and aspec . varargs in kwargs : <EOL> varargs = kwargs . pop ( aspec . varargs ) <EOL> if not isinstance ( varargs , list ) : <EOL> msg = "<STR_LIT>" <EOL> ret [ '<STR_LIT>' ] = msg . format ( aspec . varargs ) <EOL> ret [ '<STR_LIT:result>' ] = False <EOL> return ret <EOL> args . extend ( varargs ) <EOL> nkwargs = { } <EOL> if aspec . keywords and aspec . keywords in kwargs : <EOL> nkwargs = kwargs . pop ( aspec . keywords ) <EOL> if not isinstance ( nkwargs , dict ) : <EOL> msg = "<STR_LIT>" <EOL> ret [ '<STR_LIT>' ] = msg . format ( aspec . keywords ) <EOL> ret [ '<STR_LIT:result>' ] = False <EOL> return ret <EOL> try : <EOL> if aspec . keywords : <EOL> mret = __salt__ [ name ] ( * args , ** nkwargs ) <EOL> else : <EOL> mret = __salt__ [ name ] ( * args ) <EOL> except Exception as e : <EOL> ret [ '<STR_LIT>' ] = '<STR_LIT>' . format ( name , e ) <EOL> ret [ '<STR_LIT:result>' ] = False <EOL> return ret <EOL> else : <EOL> if mret is not None or mret is not { } : <EOL> ret [ '<STR_LIT>' ] [ '<STR_LIT>' ] = mret <EOL> if '<STR_LIT>' in kwargs : <EOL> ret_ret = { <EOL> '<STR_LIT:id>' : __opts__ [ '<STR_LIT:id>' ] , <EOL> '<STR_LIT>' : mret , <EOL> '<STR_LIT>' : name , <EOL> '<STR_LIT>' : salt . utils . jid . gen_jid ( ) } <EOL> returners = salt . loader . returners ( __opts__ , __salt__ ) <EOL> if kwargs [ '<STR_LIT>' ] in returners : <EOL> returners [ kwargs [ '<STR_LIT>' ] ] ( ret_ret ) <EOL> ret [ '<STR_LIT>' ] = '<STR_LIT>' . format ( name ) <EOL> ret [ '<STR_LIT:result>' ] = True <EOL> if isinstance ( mret , dict ) and mret . get ( '<STR_LIT>' , <NUM_LIT:0> ) != <NUM_LIT:0> : <EOL> ret [ '<STR_LIT:result>' ] = False <EOL> elif isinstance ( mret , bool ) : <EOL> ret [ '<STR_LIT:result>' ] = mret <EOL> else : <EOL> changes_ret = ret [ '<STR_LIT>' ] . get ( '<STR_LIT>' , { } ) <EOL> if isinstance ( changes_ret , dict ) : <EOL> if isinstance ( changes_ret . get ( '<STR_LIT:result>' , { } ) , bool ) : <EOL> ret [ '<STR_LIT:result>' ] = changes_ret . get ( '<STR_LIT:result>' , { } ) <EOL> elif changes_ret . get ( '<STR_LIT>' , <NUM_LIT:0> ) != <NUM_LIT:0> : <EOL> ret [ '<STR_LIT:result>' ] = False <EOL> return ret <EOL> mod_watch = salt . utils . alias_function ( run , '<STR_LIT>' ) </s>
