ok

Mini Shell

Direktori : /proc/self/root/proc/self/root/usr/lib/python2.7/site-packages/clcommon/
Upload File :
Current File : //proc/self/root/proc/self/root/usr/lib/python2.7/site-packages/clcommon/clhook.pyc

�
b=0Yc@s�ddlZddlZddlZddlZddlZdZdZdZdZ	d�Z
d�Zed�Zed	�Z
ed
�Zd�ZdS(i����Ns/etc/sysconfig/cloudlinuxthookst;spython-cllib:clhook:cCs&tj�}t|_|j|�|S(s6
    read config from file_name
    return config
    (tConfigParsertstrtoptionxformtread(t	file_nametconfig((s3/usr/lib/python2.7/site-packages/clcommon/clhook.pyt
get_configs	
cCs�yT|dttj��}t|d�}|j|�|j�tj||�Wn&tk
r|t	|t|�dgSXt
dgS(sG
    write config to file_name
    return [BOOLEAN_STATE, MESSAGE]
    t.tws
 write error
sOK
(RtostgetpidtopentwritetclosetshutiltmovetIOErrortFalsetTrue(RRtdebug_local_namettmp_cfg_patht	tmpconfig((s3/usr/lib/python2.7/site-packages/clcommon/clhook.pytwrite_configs


cCsbg}t|�}y|jt|�jt�}Wn$tjtjfk
rWt|gSXt	|gS(s+
    return [BOOLEAN_STATE, hook_list]
    (
RtgettHOOK_SECTIONtsplittHOOK_SEPARATORRt
NoOptionErrortNoSectionErrorRR(thook_prefixtconfig_filet	hook_listR((s3/usr/lib/python2.7/site-packages/clcommon/clhook.pytget_hook_list_from_file)scCs�td}t|�}yp|jt|�jt�}||kr\t|dt|�dgS|j|�|j	t|tj
|��WnZtjk
r�|j
t�|j	t||�n'tjk
r�|j	t||�nXt|||�S(sE
    add hook to config file
    return [BOOLEAN_STATE, MESSAGE]
    sregister_hook:sHook s already registred
(tDEBUG_STRINGRRRRRRRtappendtsettjoinRRtadd_sectionRR(t	hook_pathRR RRR!((s3/usr/lib/python2.7/site-packages/clcommon/clhook.pyt
register_hook5s

 
cCs�td}g}t|�}yX|jt|�jt�}|j|�|jt|tj|��t	|||�SWn't
jt
jt
fk
r�tdgSXdS(sJ
    remove hook from config_file
    return [BOOLEAN_STATE, MESSAGE]
    sunregister_hook:sOK
N(R#RRRRRtremoveR%R&RRRRt
ValueErrorR(R(RR RR!R((s3/usr/lib/python2.7/site-packages/clcommon/clhook.pytunregister_hookIs

c
Cs�td}tj|�}x�|D]�}tjj|�r�tj|tj�r�yHtj	|dtj
dtj
dtj
�}|jj|�|j
�Wq�tk
r�t|dgSXq t|t|�dgSq WtdgS(sY
    call hooks and send data as json to stdin 
    return [BOOLEAN_STATUS, message]
    s
call_hook:tstdintstdouttstderrsHook call error
s  : isn`t file or isn`t runnable
sOK
(R#tjsontdumpsRtpathtisfiletaccesstX_OKt
subprocesstPopentPIPER-RtcommunicatetOSErrorRRR(R!tdataRtjson_encodethooktpipe((s3/usr/lib/python2.7/site-packages/clcommon/clhook.pytcall_hook_listYs

'*
(RRR6t
simplejsonR0Rt	CL_CONFIGRRR#RRR"R)R,R?(((s3/usr/lib/python2.7/site-packages/clcommon/clhook.pyt<module>s	
	

Zerion Mini Shell 1.0