Viewing File: /opt/alt/alt-php-config/multiphp_reconfigure.pyo

ó
ÒÉ‚jc@s,ddlZddlZddlZddlZddlZddlZyddlZWnek
rwddlZnXyddl	Z	Wnddd„ƒYZ	nXdZ
dZdZd„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.pytindex_existssiit.iÿÿÿÿ(tsplitRtint(tversion1tversion2Rtrestver1tver2tmax_numR((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_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(tint_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|
ƒWdQXdtGHnX|rŽtjj|ƒrŽt||ƒ}n,|r¶tjj|ƒr¶t|ƒ}ntS|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
getbooleantconfigparsert
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"WdSWn4tk
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!RGtConfigParserR'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		$
Back to Directory File Manager