%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python37/lib/python3.7/site-packages/clwizard/config/__pycache__/
Upload File :
Create Path :
Current File : //opt/alt/python37/lib/python3.7/site-packages/clwizard/config/__pycache__/config.cpython-37.pyc

B

�2Lb��@s�ddlmZddlZddlZddlZddlmZddlmZm	Z	m
Z
ddlmZm
Z
mZddlmZmZddlmZmZGd	d
�d
e�ZdS)�)�absolute_importN)�	iteritems)�Dict�Any�Optional)�ModuleStatus�MODULES_STATUS_FILE�
MAIN_LOG_PATH)�atomic_write�setup_logger�)�NoSuchModule�MalformedConfigErrorc@s�eZdZdZdd�Zdd�Zedd��Zdd	�Zd
d�Z	dd
�Z
dd�Zedd��Zej
dd��Zdd�Zdd�Zdd�Zdd�Zedd��ZdS)�Configz;
    Low-level logic of interaction with 'states' file
    cCs,Gdd�d�}||_tdt�|_|��dS)Nc@seZdZdZiZdS)zConfig.__init__.<locals>.CfgN)�__name__�
__module__�__qualname__�
worker_pid�modules�rr�G/opt/alt/python37/lib/python3.7/site-packages/clwizard/config/config.py�Cfg srz
wizard.config)rrr	�log�reload)�selfrrrr�__init__szConfig.__init__cCs>i|j_x0t|�D]$\}}tj|�di�d�|jj|<qWdS)a�
        Forget about the previous config and create a new one with specified
        modules and instructions.

        {'cagefs': {'options': {'enable_for_new_users': True, 'enable_for_existing_users': True}},
         'mod_lsapi': {'options': {'use_beta_for_da': True}},
         'mysql_governor': {'options': {'mode': 'single'}},
         'php': {'options': {'install_versions': ['5.2', '5.3'],
                                                 'install_modules': False, 'default_version': '5.3'}},
         'nodejs': {'options': {'versions': ['7.4', '8.9'], 'default_version': '8.9'}},
         'python': {'options': {'versions': ['2.7', '3.6']}},
         'ruby': {'options': {'versions': ['2.7']}}}
        �options)�statusrN)rrrrZPENDING�get)rr�module_nameZinstructionsrrr�set_modules(szConfig.set_modulescCsdd�t|jj�D�S)z$Get dictionary with modules statusescSsi|]\}}|d|�qS)rr)�.0�modulerrrr�
<dictcomp>Bsz#Config.statuses.<locals>.<dictcomp>)rrr)rrrr�statuses>szConfig.statusescCs6y|jj|�di�Stk
r0t|��YnXdS)z Get modules options (dictionary)rN)rrr�KeyErrorr
)rrrrr�get_module_optionsDszConfig.get_module_optionscCs2y|jj|dStk
r,t|��YnXdS)z/Get modules states in format (see ModuleStatus)rN)rrr%r
)rrrrr�get_module_statusLszConfig.get_module_statuscCs4y|jj|�d�Stk
r.t|��YnXdS)z/Get modules states in format (see ModuleStatus)�status_timeN)rrrr%r
)rrrrr�get_module_status_timeTszConfig.get_module_status_timecCs<||jjkrt|��||jj|d<t��|jj|d<dS)zSet new module staterr(N)rrr
�time)rrZ	new_staterrr�set_module_status\szConfig.set_module_statuscCs|jjS)z Get background worker process id)rr)rrrrrdszConfig.worker_pidcCs||j_dS)z$Set new background worker process idN)rr)rZnew_pidrrrrjscCs>x0|jj��D] \}}|�d�st|j|d�qWi|j_dS)z
        Reset self.Cfg object to default values before it will be loaded
        from file as a part of self.reload()
        �__N)r�__dict__�items�
startswith�setattrr)r�k�vrrr�
_reset_cfgps
zConfig._reset_cfgcCsl|��|��}|dkrdS|d|j_x>t|d�D].\}}|d|�d�|�di�d�|jj|<q6WdS)z�
        Reset config object and load data from json config.

        :raises MalformedConfigError: cannot parse json config
        N�pidrrr(r)rr(r)r3�_read_json_configrrrrr)rZ	json_datar�inforrrr{sz
Config.reloadcCs |jj|jjd�}|�|�dS)z Dump python object state to file)r4rN)rrr�_write_json_config)r�staterrr�save�szConfig.savec
Cs�tj�t�sdSytt��}t�|�SQRXWnxttfk
rf}z|j	�
dt|��dSd}~XYnBtt
fk
r�}z |j	�
dt|��ttd��Wdd}~XYnXdS)z{
        Load state config and parse it using json

        :raises MalformedConfigError: cannot parse json config
        Nz*Unable to load config file due to error %sz#Unable to load json config file, %s)Zconfig_path)�os�path�existsr�open�json�load�IOError�OSErrorr�error�str�	TypeError�
ValueErrorr)r�f�errrr5�s
zConfig._read_json_configc	Cs(tt��}tj||dd�WdQRXdS)z%Write data to file using atomic write�)�indentN)r
rr>�dump)ZschemarFrrrr7�s
zConfig._write_json_configN)rrr�__doc__rr �propertyr$r&r'r)r+r�setterr3rr9r5�staticmethodr7rrrrrs
r)Z
__future__rr>r:r*Zfuture.utilsr�typingrrrZclwizard.constantsrrr	Zclwizard.utilsr
r�
exceptionsr
r�objectrrrrr�<module>	s

Zerion Mini Shell 1.0