Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/module_utils/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/module_utils/service.pyo

�
�Udac@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
ddlmZm
Z
dd�Zd�Zd�Zd�Zdd	�Zd
�Zd�Zd�ZdS(
i����N(tPY2tb(tto_bytestto_textcCs�|rRtjjd�s5ttjd||f��Sttjd||f��Stjjd�s{ttjd|��Sttjd|��SdS(s�
    This function will check if the service name supplied
    is enabled in any of the sysv runlevels

    :arg name: name of the service to test for
    :kw runlevel: runlevel to check (default: None)
    s/etc/rc0.d/s/etc/init.d/rc%s.d/S??%ss/etc/rc%s.d/S??%ss/etc/init.d/rc?.d/S??%ss/etc/rc?.d/S??%sN(tostpathtisdirtbooltglob(tnametrunlevel((s@/usr/lib/python2.7/site-packages/ansible/module_utils/service.pytsysv_is_enabled*scCs&|jd�r|}n
d|}|S(s�
    This function will return the expected path for an init script
    corresponding to the service name supplied.

    :arg name: name or path of the service to test for
    t/s/etc/init.d/%s(t
startswith(R	tresult((s@/usr/lib/python2.7/site-packages/ansible/module_utils/service.pytget_sysv_script<s	
cCstjjt|��S(s�
    This function will return True or False depending on
    the existence of an init script corresponding to the service name supplied.

    :arg name: name of the service to test for
    (RRtexistsR(R	((s@/usr/lib/python2.7/site-packages/ansible/module_utils/service.pytsysv_existsKsc	Cs�t}tj�dkr!d}nd}|jdt�}|j||g�\}}}|dkr�x-|j�D]}||krpt}PqpqpWn|S(sX
    Last resort to find a service by trying to match pattern to programs in memory
    tSunOSs-eftauxwwtpsi(tFalsetplatformtsystemtget_bin_pathtTruetrun_commandt
splitlines(	tmoduletpatterntfoundtflagstpsbintrctpsouttpserrtline((s@/usr/lib/python2.7/site-packages/ansible/module_utils/service.pytget_psUs	tcCsS|sO|jr2|jdd||fdt�qO|jdd||f�ndS(s{
    This function will return an error or exit gracefully depending on check mode status
    and if the service is missing or not.

    :arg module: is an  AnsibleModule object, used for it's utility methods
    :arg found: boolean indicating if services was found or not
    :arg service: name of service
    :kw msg: extra info to append to error/success msg when missing
    tmsgs>Service %s not found on %s, assuming it will exist on full runtchangeds+Could not find the requested service %s: %sN(t
check_modet	exit_jsonRt	fail_json(RRtserviceR'((s@/usr/lib/python2.7/site-packages/ansible/module_utils/service.pytfail_if_missingjs
	#cCstj�}|dkrtjtjtj�}x3td�D]%}||kr=tj||�q=q=W|td�kr�tj|�ntj�}|dkr�tjd�ntj	�}|dkr�t
d��ntjd�tj�}|dkrtjd�qn|S(sk
    This function performs the double fork process to detach from the
    parent process and execute.
    iii����s*Unable to detach session while daemonizingR(RtforktopentdevnulltO_RDWRtrangetdup2tcloset_exittsetsidt	Exceptiontchdir(tpidtfdtnumtsid((s@/usr/lib/python2.7/site-packages/ansible/module_utils/service.pytfork_process{s&
cs�d}d}ytj��t�}Wnatk
rT|jdddtj��n5tk
r�}|jdt|�dtj��nX|dkr�tj	�d�t
|t�s�tr�t
jt|d|��}q�t
jt|d|��}ng}x'|D]}|jt|d|��qWtj|dtd	tjd
tjd�fd��}|j|jg}	itd
�|j6td
�|j6}
x�|	rCtj|	g|	d�\}}}
|||
s�|j�r�xd|	D]Y}||kr#tj|j�|�}|s#|	j|�q#n|
|ct|�7<q�Wq�q�W|j�tj|j t|
|j�t|
|j�gdtj!�}tj"�dt|d|��tj	�d�tj#d�n�|dkr�|jdd�n�tj	�d�tj$|d�td
�}xyt%r�tj�dgg�dg�\}}}
�d|krtj�d|�}|s~Pn|t|�7}qqWtj&t|d|��SdS(s�
    Execute a command while detaching as a daemon, returns rc, stdout, and stderr.

    :arg module: is an  AnsibleModule object, used for it's utility methods
    :arg cmd: is a list or string representing the command and options to run

    This is complex because daemonization is hard for people.
    What we do is daemonize a part of this module, the daemon runs the command,
    picks up the return code and output, and returns it to the main process.
    itsurrogate_or_strictR's"Error while attempting to fork: %st	exceptioniterrorstshelltstdouttstderrt
preexec_fncstj�d�S(Ni(RR4((tpipe(s@/usr/lib/python2.7/site-packages/ansible/module_utils/service.pyt<lambda>�sR&itprotocoli����sSUnable to fork, no exception thrown, probably due to lack of resources, check logs.N('RRER=tOSErrorR+t	tracebackt
format_excR7RR4t
isinstancetlistRtshlextsplitRtappendt
subprocesstPopenRtPIPERBRCRtselecttpolltreadtfilenotremovetwaittpickletdumpst
returncodetHIGHEST_PROTOCOLtwriteR5twaitpidRtloads(RtcmdtchunkR@R9texctrun_cmdtctptfdstoutputtrfdtwfdtefdtouttdatatreturn_data((REs@/usr/lib/python2.7/site-packages/ansible/module_utils/service.pyt	daemonize�s`


&
6&	!
!
> 	,cCs�tj�dkrd}nd}|jdt�}|jd||f�\}}}|dkr�x*|jd�D]}||krqtSqqWntS(NRs-efRRs%s %sis
(RRRRRRNR(RRtpsflagsR R!RkterrR$((s@/usr/lib/python2.7/site-packages/ansible/module_utils/service.pytcheck_pss	"(RRRYRRSRMRPRItansible.module_utils.sixRRtansible.module_utils._textRRtNoneRRRR%R-R=RnRq(((s@/usr/lib/python2.7/site-packages/ansible/module_utils/service.pyt<module>s"		
		*	\

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]