Spade
Mini Shell
| Directory:~$ /proc/self/root/opt/alt/alt-php-config/ |
| [Home] [System Details] [Kill Me] |
�
ŗ�hc@s,ddlZddlZddlZddlZddlZddlZyddlZWnek
rwddlZnXyddl Z Wnddd��YZ nXdZ
dZdZd�Z
d�Zd �Zd
�Zd�Zd�Zd
�Zd�Zedkr(ejeejd��ndS(i����NtrpmcBseZed��ZRS(cCs)d�}d}|djd�}|djd�}t|�}t|�|krbt|�}nd}x�||kr$|||�r�|||�r�||||kr�d}qt||�t||�SnF|||�r�|||�r�dS|||�r|||�rdS|d7}qkWdS(NcSsAd|kot|�knp@t|�|ko>dkSS(Ni(tlen(t_listti((s//opt/alt/alt-php-config/multiphp_reconfigure.pytindex_existssiit.i����(tsplitRtint(tversion1tversion2Rtrestver1tver2tmax_numR((s//opt/alt/alt-php-config/multiphp_reconfigure.pytlabelCompares& (t__name__t
__module__tstaticmethodR(((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 FormattertsetFormattert getLoggert
addHandler(tverbosetlevelthandlert
log_formatt formattertlogger((s//opt/alt/alt-php-config/multiphp_reconfigure.pytconfigure_logging3s
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(tostpathtexiststopentreadtNone(tfdtversion((s//opt/alt/alt-php-config/multiphp_reconfigure.pytget_cpanel_versionJs
cCsog}d}xRtj|�D]A}tjjtjj|d��r|j|d|f�qqW|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]susr/bin/phpi����(tglobR#R$R%tjointappendtsort(tint_versionstbase_path_regextint_dir((s//opt/alt/alt-php-config/multiphp_reconfigure.pytfind_interpreter_versionsXs!
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( R#R$R%tunlinktTruetOSErrorRterrortFalse(tprefix_pathte((s//opt/alt/alt-php-config/multiphp_reconfigure.pyt
delete_prefixhs 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&twritetIOErrorRR7R8R5(R9tprefix_contentR)R:((s//opt/alt/alt-php-config/multiphp_reconfigure.pyt
create_prefixzscCs�t�}d|}tjjt|�}d}d|}|rwtjd|dfdtdf�dkrwt|�}nCy|j d|�}Wn�t
jk
r�} t}t
jd|tf�|jd|d �ttd
��}
|j|
�WdQXnjt
jk
rc} t}|jd�|jd|d �ttd
��}
|j|
�WdQXdtGHnX|r�tjj|�r�t||�}n,|r�tjj|�r�t|�}ntS|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/enablet1t0isMultiPHP ManagersPrefix %s
doesn't exist in %s:
tyesR<Ns!Config %s is broken:
Created it.
(R+R#R$R-tSCL_PREFIX_PATHRRtMIN_CPANEL_VERSIONR;t
getbooleantconfigparsert
NoOptionErrorR5RtwarningtCONFIG_PATHtsetR&R=tNoSectionErrortadd_sectionR%R@(tconfigtint_versiont
cp_versiontprefix_nameR9R?talt_php_enable_filetstatustint_enabledR:t
configfile((s//opt/alt/alt-php-config/multiphp_reconfigure.pytreconfigure�s<
$
cCs6tjj|�s2tjjdj||��tStS(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
sunknown {0} version
{1}( R#R$tisdirtsyststderrR=tformatR8R5(tint_pathtint_nametint_ver((s//opt/alt/alt-php-config/multiphp_reconfigure.pytcheck_alt_path_exists�scCsy%tj|dddg�\}}Wn0tjk
rW}tjjdj|��dSXt}g}d}xt|D]l\}}|dkr�d}d |} t| ||�r�|j|| f�q�dSn|dkrqt }qqqqWt
|�}
tj�}|j
t�y>|st�}nx!|D]\}}
t||�q"WdSWn4tk
rz}|
jd
||tj�f�dSXdS(Nsp:vsphp=Rs(cannot parse command line
arguments: {0}itphps-ps--phps/opt/alt/php%ss-vs --verboseiu4cannot
reconfigure alt-%s for SCL: %s. Traceback:
%s(s-ps--php(s-vs --verbose(tgetopttGetoptErrorRXRYR=RZR8R^R.R5R!RGtConfigParserR'RJR3RVt ExceptionR7t tracebackt
format_exc(tsys_argstoptstargsR:RR0R\topttargR[tlogRNR]R2((s//opt/alt/alt-php-config/multiphp_reconfigure.pytmain�s>%
t__main__i((R`R,RR#RXRdRGtImportErrorRbRRERDRJR!R+R3R;R@RVR^RlRtexittargv(((s//opt/alt/alt-php-config/multiphp_reconfigure.pyt<module>s4
3 $