Spade
Mini Shell
| Directory:~$ /lib/python2.7/site-packages/clcommon/ |
| [Home] [System Details] [Kill Me] |
�
b=0Yc@s�ddlZddlZddlZddlZddlZdZdZdZdZ d�Z
d�Zed�Zed �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
(tConfigParsertstrtoptionxformtread(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_namettmp_cfg_patht tmpconfig((s3/usr/lib/python2.7/site-packages/clcommon/clhook.pytwrite_configs
cCsbg}t|�}y|jt|�jt�}Wn$tjtjfk
rWt|gSXt |gS(s+
return [BOOLEAN_STATE, hook_list]
(
RtgettHOOK_SECTIONtsplittHOOK_SEPARATORRt
NoOptionErrortNoSectionErrorRR(thook_prefixtconfig_filet hook_listR((s3/usr/lib/python2.7/site-packages/clcommon/clhook.pytget_hook_list_from_file)scCs�td}t|�}yp|jt|�jt�}||kr\t|dt|�dgS|j|�|j t|tj
|��WnZtjk
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
(tDEBUG_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
jt
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