Tj*jdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddlmZmZddlmZmZmZddlmZe dd Zeed Zd Zd ZdZeddrse (2$J$ w~~9::X+:> uu 9> N2: 1L#MNNs *- ;;c tjtjt|}t |s%t jt jd|ddStj|d}dtj|D}|D]3}|dkr tj||d}t |s$t jt jd|d`td |d |}d |d |d } t|} n-#t$r } |rYd } ~ td|d| d } ~ wwxYw | } | } || dfcS#tt t"f$r0} t jt jd|d| Yd } ~ -d } ~ wwxYwdS)a Scan directory for presence of plugins. Plugin is a file that has the extension ".py" and a non-empty variable "__cpname__" (the name of the control panel). The file must contain a function "detect" which returns True in case of presence of the corresponding control panel. >>> detectplugin('plugins') ('from .plugins import cpanel as api', 'cPanel') :param plugin_pack: package name or the name of the plug-ins directory ('cache' - cache plugins users; 'plugins' - officially supported plug-ins) :rtype: tuple :return: a pair of values: (line to import the package, the name of the control panel) z%cpapi: refusing to load plugins from r8r#z*.pycg|]D}tjtj|dES)r)r$r%splitextbasename).0 py_full_paths r2 z detectplugin..sM  )),7788;r4__init__r7zcpapi: skipping plugin .zfrom .z import z as apiNzCan not import z pluginnamezcpapi: Plugin z& does not satisfy cpapi requirements: )r$r%r:r;r<r=r>r?globr@r ImportErrorr PanelPluginget_cp_descriptionAttributeError TypeErrorKeyError) plugin_pack ignore_errors plugin_dirplugin_path_patternmodulesmod_namerCabsolute_module_name import_stringr9e panel_class panel_dataexcs r2 detectpluginrms~ bgooh77EEJ %Z 0 0   6J 6 6 6   z',,z6:: I&9::G  z ! ! gll:(/?/?/?@@ (55  M":(:::    "4OO{OOXOOGGGhGGG  \ 455CC \ \ \ #$S6J$S$S$STTZ[ [ \ //++K$7799J *V"44 4 4 4 84    M"WWWRUWW          :s60E E* E%E%%E*.1F""G)9%G$$G)cltj}|dkrdStj|dS)zJ Get current user's username based on os.getuid() :rtype: str rroot)r$getuidpwdgetpwuid)uids r2getuserrts2 )++C axxv <  Q r4cPt|dd5 dddn #1swxYwYtj|tj}dD]}||dd|d<tjtj dd d d |gd |d dS)zAcreate (or rewrite) an empty __init__.py and it's .pyc/.pyo partswutf-8encodingN) PYTHONPATH PYTHONHOME PYTHONSTARTUP PYTHONINSPECT LD_PRELOADLD_LIBRARY_PATH1PYTHONNOUSERSITEz-Iz-Oz-m py_compile/F)cwdenvcheck) openrcompiler$environcopypop subprocessrunsys executable) init_pathrvars r2_reinit_modulers iw / / /                  y!!! *//  CB T!CN tT<C   s !%%cd}d}tjtjt|}t j||rDtj|r%t|rt j ||nX|rBtj|r#tj tj d|dtj |tj |dtj|d}t| t|\}}n.#t $r!}d\}}t#d|Yd}~nd}~wwxYw|Kt j|tj |t|t|d \}}|!t$t&}}t#d |d |rt)t*d d5}||dddn #1swxYwYt)t.d d5}||dzddddS#1swxYwYdSdS)Ncacher6zcpapi: not copying plugindir z3 into cache: not root-owned or group/world-writableiz __init__.pyr#z WARNING: T)rbzDWARNING: can not detect control panel; the control panel is set to ""rvrwrx )r$r%r:r;r<shutilrmtreer,r=copytreer>r?mkdirchmodrrmr printr r rrwrite API_LINK_PATH) plugins_dir CACHE_DIR PLUGINS_PATH cache_dirrrhcpnamerlfs r2 rebuild_cachers IL RW__X66 BBI M) rw}}[11 )+66   Y////  27==55  M": :::    HY Y 66I9! ,Y 7 7 vv !!! * v #        !~ i    y!!! ,\ N N N v ~!2Ov  ^U[^^^___ * ,g 6 6 6 ! GGFOOO                -w 7 7 7 *1 GGMD( ) ) ) * * * * * * * * * * * * * * * * * * * *s<>E E<E77E<H**H.1H. I22I69I6)N)T)F)5__doc__r$rrGrrrqrZrr> importlibr configparserrclcommon.clcustomscriptrrconstrr r cpapiexceptionsr clsysconfigreadCONTROLPANELNAME_VARDETECTFUNCNAME_VARr@ PLUGINS_DIR has_optiongetr%existsrr:r;r<rr)r*r+r-r.r/r'r(r3rEr=rmrtrrr4r2rsr   ######%%%%%%JJJJJJJJCCCCCCCCCC......le<<< #% '+>>G//'+/FFK 7>>+ & &G EFFF RW__X66 EE      m\K#Y,,,6. O O O O>>>>B   ,*3*3*3*3*3*3*r4