a „oeÅã@sbddlZddlZddlZddlmZddlmZeedƒrBddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlmZz ed7ZWney˜dZYn0Gdd„de jƒZGd d „d eƒZd d „Zd d„Zdd„Zdd„ZdeiZedk�r^ddlTeed�Zeddd�gZedej eded�Z!e!ge_"ddl#m$Z$e$dƒZ%e%j&dddd d!�e'ee%ed"�dS)#éN)Úisapicon)ÚSimpleExtensionZisapidllhandle)ÚInternalReloadExceptionéc@s$eZdZdd„Zdd„Zdd„ZdS)ÚReloadWatcherThreadcCs`d|_t|_|j d¡s$|j d¡r4|jdd…|_t tj |j¡dt j ¡|_ t j  |¡dS)NFÚcÚoéÿÿÿÿ)Úchange_detectedÚ__file__ÚfilenameÚendswithÚ win32fileZFindFirstChangeNotificationÚosÚpathÚdirnameÚwin32conZFILE_NOTIFY_CHANGE_LAST_WRITEÚhandleÚ threadingÚThreadÚ__init__©Úself©rú7C:\Program Files\Certbot\pkgs\isapi\samples\advanced.pyrNs ýzReloadWatcherThread.__init__c Cs¦t |j¡tj}z t |jtj¡}t  |j¡Wn@tj yr}z&|j t j krR‚WYd}~q¢WYd}~n d}~00t |j¡tj}||krt dƒd|_|}qdS)Nz+Detected file change - flagging for reload.T)rÚstatr ÚST_MTIMEÚ win32eventZWaitForSingleObjectrZINFINITErZFindNextChangeNotificationÚerrorÚwinerrorZERROR_INVALID_HANDLEÚprintr )rZ last_timeÚrcZdetailsZ this_timerrrÚrunZs "zReloadWatcherThread.runcCst |j¡dS©N)rZFindCloseChangeNotificationrrrrrÚstopkszReloadWatcherThread.stopN)Ú__name__Ú __module__Ú __qualname__rr"r$rrrrrMs rc@s(eZdZdZdd„Zdd„Zdd„ZdS) Ú Extensionz Python advanced sample ExtensioncCstƒ|_|j ¡dSr#)rÚreload_watcherÚstartrrrrrtszExtension.__init__cCsÞ|jjrtdƒt‚| d¡}| d¡r2| d¡| ddd¡td|d �| d ¡}|r¦| d ¡}td |d �|D]$}| |d ¡}td||f|d �qttd|d �td|d �tdt f|d �td|d �|  ¡t j S)Nz Doing reloadZ UNICODE_URLÚReportUnhealthyzI'm a little sickz200 OKzContent-Type: text/html rz )ÚfileZ QUERY_STRINGú&z
z<no such variable>z%s=%rz

zThis module has been importedz%d timesz) r)r r rZGetServerVariabler r+ZSendResponseHeadersÚsplitÚreload_counterÚcloserZHSE_STATUS_SUCCESS)rZecbÚurlÚqsZqueriesÚqÚvalrrrÚHttpExtensionProcxs*           zExtension.HttpExtensionProccCs|j ¡dSr#)r)r$)rÚstatusrrrÚTerminateExtension—szExtension.TerminateExtensionN)r%r&r'Ú__doc__rr5r7rrrrr(qsr(cCstƒSr#)r(rrrrÚ__ExtensionFactory__œsr9cCs|jr|j|_dSr#)Ú descriptionÚ Description©ÚparamsÚoptionsrrrÚPreInstallDirectory¢sr?cCs*tƒtdƒtdƒtdƒtdƒdS)NzThe sample has been installed.z+Point your browser to /AdvancedPythonSamplez2If you modify the source file and reload the page,z+you should see the reload counter increment©r r<rrrÚ PostInstallªs rAcCs tdƒdS)zQuery the status of somethingzEverything seems to be fine!Nr@)r>ÚlogÚargrrrÚstatus_handler³srDr6Ú__main__)Ú*)rArF)r(ZFlagsZAdvancedPythonSampleÚreplace)ÚNamer;Z ScriptMapsZScriptMapUpdateZ PreInstall)Ú OptionParserÚz --descriptionÚstorez3custom description to use for the virtual directory)ÚactionÚhelp)Z opt_parserÚcustom_arg_handlers)(rrÚsysZisapirZ isapi.simplerÚhasattrZwin32traceutilrrrrrrr/Ú NameErrorrrr(r9r?rArDrNr%Z isapi.installZISAPIParametersr=ZScriptMapParamsZsmZVirtualDirParametersr8ZvdZ VirtualDirsZoptparserIÚparserZ add_optionZHandleCommandLinerrrrÚs\   $    $+   ú üÿ