%PDF- %PDF-
| Direktori : /opt/alt/alt-php-config/ |
| Current File : //opt/alt/alt-php-config/multiphp_reconfigure.pyc |
�
�S�ac @ s d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z y d d l Z Wn d d d � � YZ n Xd Z d Z d Z
d � Z d � Z d � Z
d
� Z d � Z d � Z d
� Z d � Z e d k re j e e j d � � n d S( i����Nt rpmc B s e Z e d � � Z RS( c C sl t j d j | d | d � � } | d k rD d GHt j d � n$ | d k rT d S| d k rd d S| Sd S( Ns1 rpmdev-vercmp '{0}' '{1}' 1>/dev/null 2>/dev/nulli i s$ yum need install rpmdevtools packagei i����i ( t ost systemt formatt syst exit( t version1t version2t res( ( s/ /opt/alt/alt-php-config/multiphp_reconfigure.pyt labelCompare s #( t __name__t
__module__t staticmethodR ( ( ( s/ /opt/alt/alt-php-config/multiphp_reconfigure.pyR s s
11.66.0.11s /etc/scl/prefixess# /opt/alt/alt-php-config/alt-php.cfgc C s� | r t j } n t j } t j � } | j | � d } t j | d � } | j | � t j � } | j | � | j | � | S( s�
Logging configuration function.
@type verbose: bool
@param verbose: Enable additional debug output if True, display only errors
otherwise.
s %(levelname)-8s: %(message)ss %H:%M:%S %d.%m.%y( t loggingt DEBUGt ERRORt
StreamHandlert setLevelt Formattert setFormattert getLoggert
addHandler( t verboset levelt handlert
log_formatt formattert logger( ( s/ /opt/alt/alt-php-config/multiphp_reconfigure.pyt configure_logging$ s
c C sA t j j d � r= t d d � � } | j � } | SWd QXn d S( s�
Returns cPanel version if cPanel installed or None othervise.
@rtype: str or None
@return: String with cPanel version or None if cPanel not installed.
s /usr/local/cpanel/versiont rN( R t patht existst opent readt None( t fdt version( ( s/ /opt/alt/alt-php-config/multiphp_reconfigure.pyt get_cpanel_version; s
c C sK g } d } x. t j | � D] } | j | d | f � q W| j � | S( s�
Returns list of installed alt-php versions and their base directories.
@rtype: list
@return: List of version (e.g. 44, 55) and base directory tuples.
s /opt/alt/php[0-9][0-9]i����( t globt appendt sort( t int_versionst base_path_regext int_dir( ( s/ /opt/alt/alt-php-config/multiphp_reconfigure.pyt find_interpreter_versionsI s
c C s\ y* t j j | � r% t j | � n t SWn+ t k
rW } t j d | | f � t SXd S( s�
Remove prefix file
@type prefix_path: str
@param prefix_path: Path to the prefix file, e.g. /etc/scl/prefix/alt-php70
@rtype: bool
@return: True if file was removed sucessfully, False otherwise
u Couldn't remove prefix %s:
%sN( R R R t unlinkt Truet OSErrorR
t errort False( t prefix_patht e( ( s/ /opt/alt/alt-php-config/multiphp_reconfigure.pyt
delete_prefixX s c C s[ y) t | d � � } | j | � Wd QXWn+ t k
rV } t j d | | f � t SXt S( sE
Creates prefix with path to alt-php
@type prefix_path: str
@param prefix_path: Path to the prefix file, e.g. /etc/scl/prefix/alt-php70
@type prefix_content: str
@param prefix_content: SCL path, e.g. /opt/cloudlinux
@rtype: bool
@return: True if file was created sucessfully, False otherwise
t wNu Couldn't open file %s:
%s( R t writet IOErrorR
R0 R1 R. ( R2 t prefix_contentR# R3 ( ( s/ /opt/alt/alt-php-config/multiphp_reconfigure.pyt
create_prefixj s c C sg t � } d | } t j j t | � } d } d | } | rw t j d | d f d t d f � d k rw t | � } n� y | j d | � } Wn� t
j k
r� } t } t
j d | t f � | j d | d � t t d
� � }
| j |
� Wd QXn3 t
j k
r,} t } t
j d t | f � n X| rWt j j | � rWt | | � } n t | � } | S(
sB
@type config:
@param config:
@type int_version: str
@param int_version: Interpreter version (44, 55, 72, etc.)
@type int_path: str
@param int_path: Interpreter directory on the disk (/opt/alt/php51, etc.)
@rtype: bool
@return: True if reconfiguration was successful, False otherwise
s alt-php%ss /opt/cloudlinux
s /opt/cloudlinux/alt-php%s/enablet 1t 0i����s MultiPHP Managers Prefix %s doesn't exist in %s:
t yest wbNsF Config %s is broken:
%s
Please, remove it and reinstall alt-php-config( R% R R t joint SCL_PREFIX_PATHR R t MIN_CPANEL_VERSIONR4 t
getbooleant ConfigParsert
NoOptionErrorR. R
t warningt CONFIG_PATHt setR R6 t NoSectionErrorR0 R R9 ( t configt int_versiont
cp_versiont prefix_nameR2 R8 t alt_php_enable_filet statust int_enabledR3 t
configfile( ( s/ /opt/alt/alt-php-config/multiphp_reconfigure.pyt reconfigure~ s0
$ c C s1 t j j | � s- t j d | | f IJt St S( s�
Check if alt-php path exist
----------
@type int_path: str or unicode
@param int_path: Interpreter directory on the disk (/opt/alt/php51, etc.)
@type int_name: str or unicode
@param int_name: Interpreter name (php, python)
@type int_ver: str or unicode
@apram int_ver: Interpreter version (44, 55, 72, etc.)
@rtype: bool
@return: True if interpreter path exists, False otherwise
u unknown %s version %s( R R t isdirR t stderrR1 R. ( t int_patht int_namet int_ver( ( s/ /opt/alt/alt-php-config/multiphp_reconfigure.pyt check_alt_path_exists� s c C s� y% t j | d d d g � \ } } Wn. t j k
rU } t j d t | � IJd SXt } g } d } xt | D]l \ } } | d k r� d } d | } t | | | � r� | j | | f � q� d Sn | d k ro t } qo qo Wt | � }
t
j � } | j t
� y>