<s> '''<STR_LIT>''' <EOL> from __future__ import absolute_import <EOL> from salt . ext . six . moves . urllib . request import urlopen as _urlopen <EOL> import salt . utils <EOL> import salt . utils . decorators as decorators <EOL> import re <EOL> @ decorators . memoize <EOL> def __detect_os ( ) : <EOL> return salt . utils . which ( '<STR_LIT>' ) <EOL> def __virtual__ ( ) : <EOL> '''<STR_LIT>''' <EOL> if __detect_os ( ) : <EOL> return True <EOL> return ( False , '<STR_LIT>' ) <EOL> def version ( ) : <EOL> '''<STR_LIT>''' <EOL> cmd = '<STR_LIT>' . format ( __detect_os ( ) ) <EOL> out = __salt__ [ '<STR_LIT>' ] ( cmd ) . splitlines ( ) <EOL> ret = out [ <NUM_LIT:0> ] . split ( '<STR_LIT>' ) <EOL> return ret [ - <NUM_LIT:1> ] <EOL> def build_info ( ) : <EOL> '''<STR_LIT>''' <EOL> ret = { '<STR_LIT:info>' : [ ] } <EOL> out = __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' . format ( __detect_os ( ) ) ) <EOL> for i in out . splitlines ( ) : <EOL> if i . startswith ( '<STR_LIT>' ) : <EOL> ret [ '<STR_LIT>' ] = re . findall ( r"<STR_LIT>" , i ) [ <NUM_LIT:2> : ] <EOL> continue <EOL> ret [ '<STR_LIT:info>' ] . append ( i ) <EOL> return ret <EOL> def configtest ( ) : <EOL> '''<STR_LIT>''' <EOL> ret = { } <EOL> cmd = '<STR_LIT>' . format ( __detect_os ( ) ) <EOL> out = __salt__ [ '<STR_LIT>' ] ( cmd ) <EOL> if out [ '<STR_LIT>' ] != <NUM_LIT:0> : <EOL> ret [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> ret [ '<STR_LIT>' ] = out [ '<STR_LIT>' ] <EOL> ret [ '<STR_LIT:result>' ] = False <EOL> return ret <EOL> ret [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> ret [ '<STR_LIT>' ] = out [ '<STR_LIT>' ] <EOL> ret [ '<STR_LIT:result>' ] = True <EOL> return ret <EOL> def signal ( signal = None ) : <EOL> '''<STR_LIT>''' <EOL> valid_signals = ( '<STR_LIT:start>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> if signal not in valid_signals : <EOL> return <EOL> if signal == "<STR_LIT:start>" : <EOL> arguments = '<STR_LIT>' <EOL> else : <EOL> arguments = '<STR_LIT>' . format ( signal ) <EOL> cmd = __detect_os ( ) + arguments <EOL> out = __salt__ [ '<STR_LIT>' ] ( cmd ) <EOL> if out [ '<STR_LIT>' ] and out [ '<STR_LIT>' ] : <EOL> ret = out [ '<STR_LIT>' ] . strip ( ) <EOL> elif out [ '<STR_LIT>' ] : <EOL> ret = out [ '<STR_LIT>' ] . strip ( ) <EOL> elif out [ '<STR_LIT>' ] : <EOL> ret = out [ '<STR_LIT>' ] . strip ( ) <EOL> else : <EOL> ret = '<STR_LIT>' . format ( cmd ) <EOL> return ret <EOL> def status ( url = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> resp = _urlopen ( url ) <EOL> status_data = resp . read ( ) <EOL> resp . close ( ) <EOL> lines = status_data . splitlines ( ) <EOL> if not len ( lines ) == <NUM_LIT:4> : <EOL> return <EOL> active_connections = lines [ <NUM_LIT:0> ] . split ( ) [ <NUM_LIT:2> ] <EOL> accepted , handled , requests = lines [ <NUM_LIT:2> ] . split ( ) <EOL> _ , reading , _ , writing , _ , waiting = lines [ <NUM_LIT:3> ] . split ( ) <EOL> return { <EOL> '<STR_LIT>' : int ( active_connections ) , <EOL> '<STR_LIT>' : int ( accepted ) , <EOL> '<STR_LIT>' : int ( handled ) , <EOL> '<STR_LIT>' : int ( requests ) , <EOL> '<STR_LIT>' : int ( reading ) , <EOL> '<STR_LIT>' : int ( writing ) , <EOL> '<STR_LIT>' : int ( waiting ) , <EOL> } </s>
