• File: ispmanager.pyo
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/lib/python2.7/site-packages/clcommon/cpapi/plugins/ispmanager.pyo
  • Date Modified: 06/01/2017 4:14 PM
  • File size: 4.87 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

b=0Yc@sddlZddlZddlZyddlZWnek
rMdZnXddlmZddlmZm	Z	dZ
dZdZdZ
dZdded	Zed
ZdZdZded
ZdS(iN(t	NoPackage(tNotSupportedtNoDBAccessDatat
ISPManagercCs"tjjdp!tjjdS(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+)cCst}d}|rt}x|D]t}|j}t|dkrs|jt|g|j|dq%t|dkr%|j|dq%q%Wnt|}t}	xtj	t
|jD]\}
}}tj	t|}
|
|kr|d|fkrtg|
D]0\}}|dks;||kr||f^q}t
|jjt
|jr|	j|qqqW|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.			
	(-'
cCst}tddddd|}x^|D]V}y<|d|d	<|d|d
<|d|d<d|d
<|SWq+tk
rq+Xq+Wtd|fdS(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	Cststdn|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

$

cCstddS(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|}tgtjD]}|d|df^q}xt|D]\}}|jdrL|j}t|dkr*|d\}}	y:|jt	|	}
|
dkrd|	||fGHnWn&tk
rd||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$

	$