%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/alt-php-config/
Upload File :
Create Path :
Current File : //opt/alt/alt-php-config/multiphp_reconfigure.pyo

�
�S�ac@sddlZddlZddlZddlZddlZddlZddlZyddlZWnddd��YZnXdZdZ	dZ
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zedkrejeejd��ndS(i����NtrpmcBseZed��ZRS(cCsltjdj|d|d��}|dkrDdGHtjd�n$|dkrTdS|dkrddS|SdS(Ns1rpmdev-vercmp '{0}' '{1}' 1>/dev/null 2>/dev/nulliis$yum need install rpmdevtools packageii����i(tostsystemtformattsystexit(tversion1tversion2tres((s//opt/alt/alt-php-config/multiphp_reconfigure.pytlabelCompares#(t__name__t
__module__tstaticmethodR	(((s//opt/alt/alt-php-config/multiphp_reconfigure.pyRss
11.66.0.11s/etc/scl/prefixess#/opt/alt/alt-php-config/alt-php.cfgcCs�|rtj}n	tj}tj�}|j|�d}tj|d�}|j|�tj�}|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(	tloggingtDEBUGtERRORt
StreamHandlertsetLevelt	FormattertsetFormattert	getLoggert
addHandler(tverbosetlevelthandlert
log_formatt	formattertlogger((s//opt/alt/alt-php-config/multiphp_reconfigure.pytconfigure_logging$s	



cCsAtjjd�r=tdd��}|j�}|SWdQXndS(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/versiontrN(RtpathtexiststopentreadtNone(tfdtversion((s//opt/alt/alt-php-config/multiphp_reconfigure.pytget_cpanel_version;s

cCsKg}d}x.tj|�D]}|j|d|f�qW|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����(tglobtappendtsort(tint_versionstbase_path_regextint_dir((s//opt/alt/alt-php-config/multiphp_reconfigure.pytfind_interpreter_versionsIs
cCs\y*tjj|�r%tj|�ntSWn+tk
rW}tjd||f�tSXdS(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
    uCouldn't remove prefix %s:
%sN(	RRRtunlinktTruetOSErrorR
terrortFalse(tprefix_pathte((s//opt/alt/alt-php-config/multiphp_reconfigure.pyt
delete_prefixXs	cCs[y)t|d��}|j|�WdQXWn+tk
rV}tjd||f�tSXtS(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
    twNuCouldn't open file %s:
%s(R twritetIOErrorR
R0R1R.(R2tprefix_contentR#R3((s//opt/alt/alt-php-config/multiphp_reconfigure.pyt
create_prefixjscCsgt�}d|}tjjt|�}d}d|}|rwtjd|dfdtdf�dkrwt|�}n�y|j	d|�}Wn�t
jk
r�}	t}t
jd|tf�|jd|d	�ttd
��}
|j|
�WdQXn3t
jk
r,}	t}t
jdt|	f�nX|rWtjj|�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/enablet1t0i����sMultiPHP ManagersPrefix %s doesn't exist in %s:
tyestwbNsFConfig %s is broken:
%s
Please, remove it and reinstall alt-php-config(R%RRtjointSCL_PREFIX_PATHRR	tMIN_CPANEL_VERSIONR4t
getbooleantConfigParsert
NoOptionErrorR.R
twarningtCONFIG_PATHtsetR R6tNoSectionErrorR0RR9(tconfigtint_versiont
cp_versiontprefix_nameR2R8talt_php_enable_filetstatustint_enabledR3t
configfile((s//opt/alt/alt-php-config/multiphp_reconfigure.pytreconfigure~s0
	

$	cCs1tjj|�s-tjd||fIJtStS(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

    uunknown %s version %s(RRtisdirRtstderrR1R.(tint_pathtint_nametint_ver((s//opt/alt/alt-php-config/multiphp_reconfigure.pytcheck_alt_path_exists�scCs�y%tj|dddg�\}}Wn.tjk
rU}tjdt|�IJdSXt}g}d}xt|D]l\}}|dkr�d}d	|}	t|	||�r�|j||	f�q�dSn|dkrot}qoqoWt	|�}
t
j�}|jt
�y>|st�}nx!|D]\}}
t||�q WdSWn:tk
r~}|
jd
|t|�tj�f�dSXdS(Nsp:vsphp=Ru'cannot parse command line arguments: %sitphps-ps--phps/opt/alt/php%ss-vs	--verboseiu4cannot reconfigure alt-%s for SCL: %s. Traceback:
%s(s-ps--php(s-vs	--verbose(tgetopttGetoptErrorRRRtunicodeR1RVR'R.RRBtSafeConfigParserR!RER,RPt	ExceptionR0t	tracebackt
format_exc(tsys_argstoptstargsR3RR)RTtopttargRStlogRHRUR+((s//opt/alt/alt-php-config/multiphp_reconfigure.pytmain�s@%


	t__main__i((RXR&R
RRR]RBRR@R?RERR%R,R4R9RPRVReR
Rtargv(((s//opt/alt/alt-php-config/multiphp_reconfigure.pyt<module>s.						-		%

Zerion Mini Shell 1.0