%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/modules/supervisord.pyc

�
���^c@@svdZddlmZmZmZddlZddlmZddlm	Z	ddl
Zddlm
Z
mZd�Zd�Zd	�Zd
�Zddddd�Zddddd
�Zddddd�Zdddd�Zdddd�Zdddd�Zddddd�Zddddd�Zddddd�Zdddd�Zdd�Zdd�ZdS(uR
Provide the service module for system supervisord or supervisord in a
virtualenv
i(tabsolute_importtunicode_literalstprint_functionN(tstring_types(tconfigparser(tCommandExecutionErrortCommandNotFoundErrorcC@stS(N(tTrue(((s</usr/lib/python2.7/site-packages/salt/modules/supervisord.pyt__virtual__scC@s�d}|sGtd|g�}|dkrCtdj|���n|Stjj|�r�tjj|d|�}tjj|�r�|Stdj|���n|S(u�
    Return supervisorctl command to call, either from a virtualenv, an argument
    passed in, or from the global modules options
    u
supervisorctlu
cmd.which_binuCould not find a `{0}` binaryubinN(	t__salt__tNoneRtformattostpathtisdirtjointisfile(tbin_envtcmdtwhich_resulttcmd_bin((s</usr/lib/python2.7/site-packages/salt/modules/supervisord.pyt_get_supervisorctl_binscC@sUt|�g}|dk	r.|d|g7}n|j|�|rQ|j|�n|S(u(
    Return the command list to use
    u-cN(RR
tappend(Rtnamet	conf_fileRtret((s</usr/lib/python2.7/site-packages/salt/modules/supervisord.pyt_ctl_cmd4s
cC@s?|d}|ddkr;d|kr;dj|�}q;n|S(NustdouturetcodeiuERRORu	ERROR: {}(R(Rtretmsg((s</usr/lib/python2.7/site-packages/salt/modules/supervisord.pyt_get_returnAs

uallcC@sQ|jd�r|d }ntdtd|||�d|dt�}t|�S(u�
    Start the named service.
    Process group names should not include a trailing asterisk.

    user
        user to run supervisorctl as
    conf_file
        path to supervisord config file
    bin_env
        path to supervisorctl bin or path to virtualenv with supervisor
        installed

    CLI Example:

    .. code-block:: bash

        salt '*' supervisord.start <service>
        salt '*' supervisord.start <group>:
    u:*i����ucmd.run_allustarttrunastpython_shell(tendswithR	RtFalseR(RtuserRRR((s</usr/lib/python2.7/site-packages/salt/modules/supervisord.pytstartJs
	cC@sQ|jd�r|d }ntdtd|||�d|dt�}t|�S(u�
    Restart the named service.
    Process group names should not include a trailing asterisk.

    user
        user to run supervisorctl as
    conf_file
        path to supervisord config file
    bin_env
        path to supervisorctl bin or path to virtualenv with supervisor
        installed

    CLI Example:

    .. code-block:: bash

        salt '*' supervisord.restart <service>
        salt '*' supervisord.restart <group>:
    u:*i����ucmd.run_allurestartRR(RR	RR R(RR!RRR((s</usr/lib/python2.7/site-packages/salt/modules/supervisord.pytrestarths
	cC@sQ|jd�r|d }ntdtd|||�d|dt�}t|�S(u�
    Stop the named service.
    Process group names should not include a trailing asterisk.

    user
        user to run supervisorctl as
    conf_file
        path to supervisord config file
    bin_env
        path to supervisorctl bin or path to virtualenv with supervisor
        installed

    CLI Example:

    .. code-block:: bash

        salt '*' supervisord.stop <service>
        salt '*' supervisord.stop <group>:
    u:*i����ucmd.run_allustopRR(RR	RR R(RR!RRR((s</usr/lib/python2.7/site-packages/salt/modules/supervisord.pytstop�s
	cC@sm|jd�r|d }n|jd�r8|d }ntdtd|||�d|dt�}t|�S(	u\
    Activates any updates in config for process/group.

    user
        user to run supervisorctl as
    conf_file
        path to supervisord config file
    bin_env
        path to supervisorctl bin or path to virtualenv with supervisor
        installed

    CLI Example:

    .. code-block:: bash

        salt '*' supervisord.add <name>
    u:i����u:*i����ucmd.run_alluaddRR(RR	RR R(RR!RRR((s</usr/lib/python2.7/site-packages/salt/modules/supervisord.pytadd�s

	cC@sm|jd�r|d }n|jd�r8|d }ntdtd|||�d|dt�}t|�S(	uU
    Removes process/group from active config

    user
        user to run supervisorctl as
    conf_file
        path to supervisord config file
    bin_env
        path to supervisorctl bin or path to virtualenv with supervisor
        installed

    CLI Example:

    .. code-block:: bash

        salt '*' supervisord.remove <name>
    u:i����u:*i����ucmd.run_alluremoveRR(RR	RR R(RR!RRR((s</usr/lib/python2.7/site-packages/salt/modules/supervisord.pytremove�s

	cC@s5tdtdd||�d|dt�}t|�S(uM
    Reload the daemon's configuration files

    user
        user to run supervisorctl as
    conf_file
        path to supervisord config file
    bin_env
        path to supervisorctl bin or path to virtualenv with supervisor
        installed

    CLI Example:

    .. code-block:: bash

        salt '*' supervisord.reread
    ucmd.run_allurereadRRN(R	RR
R R(R!RRR((s</usr/lib/python2.7/site-packages/salt/modules/supervisord.pytreread�s
	cC@st|t�rJ|jd�r+|d }qJ|jd�rJ|d }qJntdtd|||�d|dt�}t|�S(	u�
    Reload config and add/remove/update as necessary

    user
        user to run supervisorctl as
    conf_file
        path to supervisord config file
    bin_env
        path to supervisorctl bin or path to virtualenv with supervisor
        installed
    name
        name of the process group to update. if none then update any
        process group that has changes

    CLI Example:

    .. code-block:: bash

        salt '*' supervisord.update
    u:i����u:*i����ucmd.run_alluupdateRR(t
isinstanceRRR	RR R(R!RRRR((s</usr/lib/python2.7/site-packages/salt/modules/supervisord.pytupdate�s
	c	C@s�i}x�t||||�j�D]p}t|j��dkr^|jdd�\}}}n|j�dg\}}}i|d6|d6||<q"W|S(uA
    List programs and its state

    user
        user to run supervisorctl as
    conf_file
        path to supervisord config file
    bin_env
        path to supervisorctl bin or path to virtualenv with supervisor
        installed

    CLI Example:

    .. code-block:: bash

        salt '*' supervisord.status
    iuustateureasonN(t
status_rawt
splitlinestlentsplitR
(	RR!RRtall_processtlinetprocesststatetreason((s</usr/lib/python2.7/site-packages/salt/modules/supervisord.pytstatuss"cC@s5tdtd|||�d|dt�}t|�S(uJ
    Display the raw output of status

    user
        user to run supervisorctl as
    conf_file
        path to supervisord config file
    bin_env
        path to supervisorctl bin or path to virtualenv with supervisor
        installed

    CLI Example:

    .. code-block:: bash

        salt '*' supervisord.status_raw
    ucmd.run_allustatusRR(R	RR R(RR!RRR((s</usr/lib/python2.7/site-packages/salt/modules/supervisord.pyR*:s
	cC@s5tdt|d||�d|dt�}t|�S(u]
    Run any custom supervisord command

    user
        user to run supervisorctl as
    conf_file
        path to supervisord config file
    bin_env
        path to supervisorctl bin or path to virtualenv with supervisor
        installed

    CLI Example:

    .. code-block:: bash

        salt '*' supervisord.custom "mstop '*gunicorn*'"
    ucmd.run_allRRN(R	RR
R R(tcommandR!RRR((s</usr/lib/python2.7/site-packages/salt/modules/supervisord.pytcustomTs
	cC@s�|dkrBd}x-|D]"}tjj|�r|}PqqWn|dkr]td��ntj�}y|j|�Wn1tt	fk
r�}tdj
||���nX|S(u2
    Reads the config file using configparser
    u /etc/supervisor/supervisord.confu/etc/supervisord.confuNo suitable config file founduUnable to read from {0}: {1}N(u /etc/supervisor/supervisord.confu/etc/supervisord.conf(R
RR
texistsRRtConfigParsertreadtIOErrortOSErrorR(RtpathsR
tconfigtexc((s</usr/lib/python2.7/site-packages/salt/modules/supervisord.pyt_read_configps
cC@s�t|�}dj|�}||j�krEtdj|���ni}x�|j|�D]�\}}tjjj|j	d�dj
��}t|t�r�|j
�dkr�t}q�|j
�dkr�t}q�n|||<q[W|S(u-
    .. versionadded:: 2014.1.0

    Read the config file and return the config options for a given process

    name
        Name of the configured process
    conf_file
        path to supervisord config file

    CLI Example:

    .. code-block:: bash

        salt '*' supervisord.options foo
    uprogram:{0}uProcess '{0}' not foundu;iutrueufalse(R>RtsectionsRtitemstsalttutilststringutilstto_numR-tstripR(RtlowerRR (RRR<tsection_nameRtkeytval((s</usr/lib/python2.7/site-packages/salt/modules/supervisord.pytoptions�s(	( t__doc__t
__future__RRRRtsalt.ext.sixRtsalt.ext.six.movesRtsalt.utils.stringutilsRAtsalt.exceptionsRRRRRRR
R"R#R$R%R&R'R)R3R*R5R>RJ(((s</usr/lib/python2.7/site-packages/salt/modules/supervisord.pyt<module>s,			
		$

Zerion Mini Shell 1.0