+tddlZddlZddlZddlZddlZddlmZddlmZddl m Z m Z m Z GddZ dS)N)ClPwd)Feature)is_panel_feature_supported list_users userdomainscleZdZdZdZedZdZdZdZ edZ edZ d S) DomainCollectorzR Class for print panel users domain docroots. See LU-1751 for details cttjd |_||_t|_dS)NDOM_COLL_RUNNING_IN_LVE) boolosenvironget is_not_in_lveis_not_limitedis_not_limited_processr_clpwd)selfs $py/cl_dom_collector/dom_collector.py__init__zDomainCollector.__init__sG!%bjnn5N&O&O!P!PP&*&9&9&;&;#gg cttjd}ttjd}| o| S)Nr DOM_COLL_RUNNING_IN_NICE)r r rr)is_limited_by_lveis_limited_by_nices rrzDomainCollector.is_not_limitedsN 0I!J!JKK!"*..1K"L"LMM$$?-?)??rctt}g}|D]M} |j|d}||9#t j$rYJwxYw|S)zL Get panel user names list :return: user names list r)listrkeysr get_namesappendrNoSuchUserException)rpanel_uids_listpanel_users_listuidnames r_get_panel_user_names_listz*DomainCollector._get_panel_user_names_list#s z||002233"  C {,,S11!4 ''----,    s5A++A=<A=c |}|D]v} t|D]S\}}tj|dd}t |d|Tg#t$rYswxYwdS)z Method prints pair `domain,doc_root` for an each user on a server domain is encoded in punycode if it's needed doc_root is always encoded in base64 zutf-8,N)r&rbase64 b64encodeencodedecodeprint Exception)rr#usernamedomaindoc_rootencoded_doc_roots r"_print_users_doc_roots_and_domainsz2DomainCollector._print_users_doc_roots_and_domains2s  ::<<(  H (3H(=(=::$FH'-'7 00((fWoo%V88&6889999 :        sA#A>> B  B c|jrttjrp |}t j|dS#tj$r3}d|}t|t jdYd}~dSd}~wwxYw| }t j|dS| dS)Nz"failed to run task in lve, error: ) rrrLVE_run_self_in_lvesysexit lvectllib PyLveErrorr- _run_by_nicer3)rrce error_msgs rrunzDomainCollector.runFs  & 6)'+66 !..00BHRLLLLL +!!! HQ H HI)$$$HRLLLLLLLLL! &&((   3 3 5 5 5 5 5s(A B(B  Bc0tjtjddd}tj|5}t jddt |dgttj d  cd d d S#1swxYwYd S) z Run same command in lve and set environ RUNNING_IN_LVE=True in order to check it in child process. :return: ri@)ls_cpuls_cpus ls_memory_phyz/bin/lve_suwrapper-n%/usr/bin/cloudlinux_domains_collector1)r envN) r:make_liblve_settingscreate_liblve_settings temporary_lve subprocesscallstrdictr r)settingslve_ids rr7z DomainCollector._run_self_in_lveYs1  ,.      $X . . C&?%tS[[:abSAAACCC C C C C C C C C C C C C C C C C C CsAB  BBcdtjgdttjdS)N)z /usr/bin/nicerF19rGrH)rrI)rNrOrQr rrrr<zDomainCollector._run_by_nicelsD 6 6 6 ),    rN) __name__ __module__ __qualname____doc__r staticmethodrr&r3r@r7r<rVrrr r s @@\@    (666&CC\C$  \   rr )r)r rNr8r:clcommon.clpwdrclcommon.constrclcommon.cpapirrrr rVrrr_s   """"""NNNNNNNNNNb b b b b b b b b b r