![]() Server : Apache/2.4.62 (Unix) OpenSSL/1.0.2k-fips System : Linux server1.richineiserver.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : fdshops ( 1003) PHP Version : 8.2.21 Disable Function : NONE Directory : /lib/python2.7/site-packages/certbot/_internal/ |
� ���_c @ sZ d Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z e j e � Z e j d k r$e j g Z xW e j e j e j e j g D]. Z e j e � e j k r� e j e � q� q� Wn g Z d e f d � � YZ d e f d � � YZ d S( sB Registers functions to be called if an exception or signal occurs.i����N( t Any( t Callable( t Dict( t List( t Union( t errors( t ost ntt ErrorHandlerc B s_ e Z d Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z RS( sG Context manager for running code that must be cleaned up on failure. The context manager allows you to register functions that will be called when an exception (excluding SystemExit) or signal is encountered. Usage:: handler = ErrorHandler(cleanup1_func, *cleanup1_args, **cleanup1_kwargs) handler.register(cleanup2_func, *cleanup2_args, **cleanup2_kwargs) with handler: do_something() Or for one cleanup function:: with ErrorHandler(func, args, kwargs): do_something() If an exception is raised out of do_something, the cleanup functions will be called in last in first out order. Then the exception is raised. Similarly, if a signal is encountered, the cleanup functions are called followed by the previously received signal handler. Each registered cleanup function is called exactly once. If a registered function raises an exception, it is logged and the next function is called. Signals received while the registered functions are executing are deferred until they finish. c O sS t | _ t | _ g | _ i | _ g | _ | d k rO | j | | | � n d S( N( t Falset call_on_regular_exitt body_executedt funcst prev_handlerst received_signalst Nonet register( t selft funct argst kwargs( ( sC /usr/lib/python2.7/site-packages/certbot/_internal/error_handler.pyt __init__M s c C s t | _ | j � d S( N( R R t _set_signal_handlers( R ( ( sC /usr/lib/python2.7/site-packages/certbot/_internal/error_handler.pyt __enter__V s c C s� t | _ t } | t k r | S| d k r; | j s� | SnS | t j k rf t j d | j � t } n( t j d d j t j | | | � � � | j � | j � | j � | S( Ns Encountered signals: %ss Encountered exception: %st ( t TrueR R t SystemExitR R R t SignalExitt loggert debugR t joint tracebackt format_exceptiont _call_registeredt _reset_signal_handlerst _call_signals( R t exec_typet exec_valuet tracet retval( ( sC /usr/lib/python2.7/site-packages/certbot/_internal/error_handler.pyt __exit__Z s c O s# | j j t j | | | � � d S( s� Sets func to be run with the given arguments during cleanup. :param function func: function to be called in case of an error N( R t appendt functoolst partial( R R R R ( ( sC /usr/lib/python2.7/site-packages/certbot/_internal/error_handler.pyR o s c C s� t j d � xy | j r� y | j d � WnJ t k rw } t j t | � | � } t j d d j | � j � � n X| j j � q Wd S( s Calls all registered functionss Calling registered functionsi����s) Encountered exception during recovery: %sR N( R R R t ExceptionR t format_exception_onlyt typet errorR t rstript pop( R t exct output( ( sC /usr/lib/python2.7/site-packages/certbot/_internal/error_handler.pyR! x s c C sS xL t D]D } t j | � } | d k r | | j | <t j | | j � q q Wd S( s- Sets signal handlers for signals in _SIGNALS.N( t _SIGNALSt signalt getsignalR R t _signal_handler( R t signumt prev_handler( ( sC /usr/lib/python2.7/site-packages/certbot/_internal/error_handler.pyR � s c C s<