ok

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/
Upload File :
Current File : //usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/ispmanager.pyo

�
b=0Yc@s�ddlZddlZddlZyddlZWnek
rMdZnXddlmZddlmZm	Z	dZ
d�ZdZdZ
dZdded	�Zed
�Zd�Zd�Zded
�ZdS(i����N(t	NoPackage(tNotSupportedtNoDBAccessDatat
ISPManagercCs"tjjd�p!tjjd�S(Ns/usr/local/ispmgr/bin/ispmgrs/usr/local/mgr5/sbin/mgrctl(tostpathtisfile(((sE/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/ispmanager.pytdetectss!/usr/local/ispmgr/etc/ispmgr.confs(\S+) "([^"]+)" {([^}]+)}s
(\S+)\s+(\S+)cCs�t�}d}|r�t�}x|D]t}|j�}t|�dkrs|jt|g��|j|d�q%t|�dkr%|j|d�q%q%Wnt|�}t�}	x�tj	t
|j��D]�\}
}}tj	t|�}
|
|kr�|d|fkr�tg|
D]0\}}|dks;||kr||f^q�}t
|j��jt
|j���r�|	j|�q�q�q�W|j�|	S(sK
    /usr/local/ispmgr/etc/ispmgr.conf parser
    :param sectype: Type sector for example: Service or DbServer or Account
    :param secname: Name sector. May be different
    :param seckeys: Name key for retrieving and filtering
    :param path: path to config file default /usr/local/ispmgr/etc/ispmgr.conf
    :return: list
    iiiN(tdicttNonetlisttsplittlentupdatetappendtopentretfindalltSECTION_PATTERNtreadtKEYWORDS_PATTERNtsettitemstissubsettclose(tsectypetsecnametseckeysRtseckeys_filtertseckeys_extractedtkey_valtkey_val_splitedtconf_streamtresult_listtstypetsnametsbodytblsttktvtresult((sE/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/ispmanager.pyt	conf_parss.			
	(-'
cCs�t�}tddddd|�}x^|D]V}y<|d|d	<|d|d
<|d|d<d|d
<|SWq+tk
r�q+Xq+Wtd|f��dS(NRtDbServerRtHostnametPasswords
Type mysqltUserRtpasstloginthosttmysqltdbsACan not find database access data for localhost in config file %s(R+R,s
Type mysqlR-(RR)tKeyErrorR(t
_conf_pathtaccesstaccess_listtaccess_from_conf((sE/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/ispmanager.pyt	db_access@s	


c	Cs�tstd��n|jdd�}|d}|d}tjd|d|d|dd	�}|j�}d
}|j|�|j�}|j�|S(Ns@Can not connect to database; MySQL-python package not installed.R0t	localhostR/R.tusertpasswdR2R1s6SELECT db.Db, db.User FROM db  GROUP BY db.User, db.Db(tMySQLdbRtgettconnecttcursortexecutetfetchallR(R5tdbhosttdblogintdbpassR2R?tsqltdata((sE/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/ispmanager.pyt_dbname_dblogin_pairsOs

$

cCstd��dS(NscGetting all users registered in the Control Panel is not currently supported. Is under development.(R(((sE/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/ispmanager.pytcpusers^sccs<t|�}tgtj�D]}|d|df^q�}x�t|�D]�\}}|jd�rL|j�}t|�dkr*|d\}}	y:|jt	|	��}
|
dkr�d|	||fGHnWn&tk
r�d||fGHd}
nX|
r'|dk	s|
|kr'||
fVq'q*qLqLW|j�dS(s�
    Extract (database name <=> control panel login) pairs from ISPmanager config file
    :param cplogin_lst:
    :param _conf_path:
    :return:
    iis	DbAssign is?WARNING: can not find group name with id %s; line %d in file %ss(WARNING: can not pars line %d in file %sN(
RRtgrptgetgrallt	enumeratet
startswithRRR=tintR	t
ValueErrorR(tcplogin_lstR4R t	grp_tupletgrpid_login_dictt	line_numbtlinetline_splitedtdbnametuser_uidtcplogin((sE/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/ispmanager.pyt_dbname_cplogin_pairs_itercs$3

(RRRIR<tImportErrorR	tclcommon.cpapi.cpapiexceptionsRRRt
__cpname__RtISP_DB_CONFRRR)R8RGRHRX(((sE/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/ispmanager.pyt<module>s$

	$		

Zerion Mini Shell 1.0