File: //opt/alt/python37/lib/python3.7/site-packages/clconfigure/__pycache__/packages.cpython-37.pyc
B
� ���i6� @ s� d dl mZ d dlZd dlZd dlZd dlmZmZ dZdZ ed�dd� �Z
ed �d
d� �Zed�dee
d�dd��Zdd� Zdd� ZdS )� )�absolute_importN)�task�runZuninstalledZ installedz Erasing package '{package_name}'c C s: t ddd| g� t| �}t�d| |� t|kr6td��d S )N�rpmz-ez--nodepszAChecking package '%s' state again... package is now in state '%s'zFailed to do required actions)r �get_package_state�logging�info�
STATE_REMOVED�RuntimeError)�package_name�
current_state� r
�py/clconfigure/packages.py�
erase_package s
r z<Changing package '{package_name}' state to '{desired_state}'c C s� t |�}t�d||� | |kr.t�d|� dS t�d� | tkrFd}n| tkrTd}nt� �td|d|g� t |�}t�d ||� | |kr�td
��dS )z�
Brings package to given state (installed | uninstalled).
May be executed more than once, doesn't crash on future calls
z7Checking package '%s' state... package is in state '%s'z"No actions needed for package '%s'Nz(State does not match target, changing...�remove�install�yumz-yzAChecking package '%s' state again... package is now in state '%s'zFailed to do required actions) r r �debugr r �STATE_INSTALLED�NotImplementedErrorr r
)Z
desired_stater r �actionr
r
r �set_package_state s
r z'(Re)installing package '{package_name}'F)r � reinstallc C sH t | �}|tkr"|r"ddd| g}n|tkr8ddd| g}nd S t|� d S )Nr r z-yr )r r r r )r r �state�cmdr
r
r �install_package7 s r c C s t dd| g�}|jdkrtS tS )zJ
Gets current package state.
Either installed or uninstalled.
r z-qvr )r Zexitcoder r )�packageZrespr
r
r r C s r c C s dd� t �d�D �S )zN
Gets installed alt-phps
return: list ['php44', 'php54', 'php80']
c S s g | ]}t �d |�r|�qS )z^php\d+$)�re�match)�.0Zphpr
r
r �
<listcomp>Q s z/get_list_installed_alt_phps.<locals>.<listcomp>z/opt/alt)�os�listdirr
r
r
r �get_list_installed_alt_phpsL s r# )F)Z
__future__r r r! r Zclconfigurer r r r r r �str�boolr r r# r
r
r
r �<module> s