ok

Mini Shell

Direktori : /proc/self/root/opt/alt/alt-php-config/
Upload File :
Current File : //proc/self/root/opt/alt/alt-php-config/alt-php-panel-configuration.pyo

�
Z�Kdc@sddlZddlZddlZddlZddlZddlZddlmZyddlj	j
Z
Wnek
r�ddlZ
nXdZ
d�Zd�Zd�Zd	�Zd
�Zd�Zd�Zed
kr�ejeejd��ndS(i����N(tcopy2tchecktinstallt	uninstallcCs�|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
        othervise
    :return: configured logger object
    s%(levelname)-8s: %(message)ss%H:%M:%S %d.%m.%y(	tloggingtDEBUGtERRORt
StreamHandlertsetLevelt	FormattertsetFormattert	getLoggert
addHandler(tverbosetlevelthandlert
log_formatt	formattertlogger((s6/opt/alt/alt-php-config/alt-php-panel-configuration.pytconfigure_loggings		



cCsEg}x.tjd�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php_versionstphp_dir((s6/opt/alt/alt-php-config/alt-php-panel-configuration.pytfind_alt_php_versions)s

cCs�tjddgdtjdtjdt�}|j�\}}x[|jd�D]J}d||f|j�jd�d	krOtj	d
||f�tSqOWtj	d||f�t
S(sx

    :param php_ver: alt-php version (e.g. 44, 55, 70)
    :return: If handler exist returns True, otherwise False
    s/usr/local/psa/bin/php_handlers--listtstdouttstderrtuniversal_newliness
salt-php%s-%st isHandler for alt-php%s-%s exist.s#Handler for alt-php%s-%s not exist.(t
subprocesstPopentPIPEtSTDOUTtTruetcommunicatetsplittstripRtinfotFalse(tcgi_typetphp_vertproctoutt_tline((s6/opt/alt/alt-php-config/alt-php-panel-configuration.pytplesk_check_php_handler7s	)cCs]t||�r*tjd||f�tStjd||f�tjjdj||��d}|ddd||fdtj	j
|d	�d
tj	j
|d�d|d
d||fg}|dkrS|jdd|dtj	j
|d�dtj	j
|d�g�tj	jd|�sut
tj	j
|d�tj	j
|d��qun"|jdtj	j
|d�g�tj|dtjdtjdt�}|j�\}}|jdkr�tddj
|�|f��ntj|dgdtjdtjdt�}|j�\}}|jdkrHtd |d!|��ntjd"|�tS(#NsHandler for alt-php%s-%s exist.s'Plesk: Installing alt-php%s-%s handler.s)Plesk: Installing alt-php{0}-{1} handler.s/usr/local/psa/bin/php_handlers--adds-displaynamesalt-php%s-%ss-clipathsusr/bin/phps-phpinisetc/php.inis-types-idtfpms-services
alt-php%s-fpms-pathsusr/sbin/php-fpms-poolds
etc/php-fpm.ds/opt/alt/php%s/etc/php-fpm.confsetc/php-fpm.conf.plesksetc/php-fpm.confsusr/bin/php-cgiRRRiucannot execute "%s": %sRs--rereaducannot execute "s --reread": %ss-Handler for alt-php%s was successfully added.(R.RR&R'tsysRtwritetformattostpathtjointextendtexistsRRRR R!R"R#t
returncodet	Exception(R(R)tphp_pathtcommandtadd_commandR*R+R,((s6/opt/alt/alt-php-config/alt-php-panel-configuration.pytplesk_add_php_handlerIsB
1"cCst||�r�tjd||f�tjjdj||��dddd||fg}tj|dtj	dtj
d	t�}|j�\}}|j
d
kr�tddj|�|f��ntjd
||f�tStjd||f�tSdS(Ns%Plesk: Removing alt-php%s-%s handler.s'Plesk: Removing alt-php{0}-{1} handler.s/usr/local/psa/bin/php_handlers--removes-idsalt-php%s-%sRRRiucannot execute "%s": %sRs2Handler for alt-php%s-%s was successfully removed.s#Handler for alt-php%s-%s not exist.(R.RR&R0RR1R2RRR R!R"R#R8R9R5R'(R(R)R;R*R+R,((s6/opt/alt/alt-php-config/alt-php-panel-configuration.pytplesk_remove_php_handlerqs	"cCsfy>tj�}|dkr=tjjd�s<td��n|dkr�td||�td||�tjjd|�s�tjjd|�r:td	||�q:q=|d
krtd|�td|�tjjd|�s�tjjd|�r:td	|�q:q=td|�o9td|�o9td	|�SnWn!tk
ra}t	j
|�tSXdS(sL
    :rtype: bool
    :return: If success returns True, otherwise False
    tPlesks/usr/local/psa/bin/php_handlers)/usr/local/psa/bin/php_handler not exist.Rtfastcgitcgis/etc/init.d/alt-php%s-fpms-/usr/lib/systemd/system/alt-php%s-fpm.serviceR/RN(tcpapit	getCPNameR3R4R7R9R=R>R.RR&R'(tmodeR)R:tcp_namete((s6/opt/alt/alt-php-config/alt-php-panel-configuration.pytconfigure_alt_php�s&,

,2
c
Cs�y(tj|ddddg�\}}Wn0tjk
rZ}tjjdj|��dSXt}d}g}x�|D]�\}}|dkr�|tkr�d}q�|}n|dkrtj	j
d|�s�tjjd
j|��dS|j|d|f�n|dkrtt}qtqtWt
|�}	|skt�}|	jddjg|D]}
d|
^qM��nx$|D]\}}t|||�qrWdS(Nsm:p:vsmode=sphp=R
s(cannot parse command line arguments: {0}iRs-ms--modes-ps--phps/opt/alt/php%ssunknown PHP version {0}s-vs	--verboseu!installed alt-php versions are
%ss
s	 alt-php%s: %s(s-ms--mode(s-ps--php(s-vs	--verbose(tgetopttGetoptErrorR0RR1R2R'tMODESR3R4tisdirRR"RRR&R5RG(
tsys_argstoptstargsRFR
RDRtopttargtlogtitverR4((s6/opt/alt/alt-php-config/alt-php-panel-configuration.pytmain�s6(		
		+t__main__i(schecksinstalls	uninstall(RHRRR3RR0tshutilRtdb.clcommon.cpapitclcommonRBtImportErrortdetectcpRJRRR.R=R>RGRTt__name__texittargv(((s6/opt/alt/alt-php-config/alt-php-panel-configuration.pyt<module>s(
				(			!

Zerion Mini Shell 1.0