mirror of
https://github.com/certbot/certbot.git
synced 2026-07-28 08:45:22 +02:00
Move SignalExit to errors.py
This commit is contained in:
@@ -5,6 +5,7 @@ import os
|
||||
import signal
|
||||
import traceback
|
||||
|
||||
from certbot import errors
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -19,14 +20,6 @@ _SIGNALS = ([signal.SIGTERM] if os.name == "nt" else
|
||||
signal.SIGXCPU, signal.SIGXFSZ])
|
||||
|
||||
|
||||
class SignalExit(Exception):
|
||||
"""This exception is used stop of execution of the code in the body of the
|
||||
ErrorHandler context manager.
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class ErrorHandler(object):
|
||||
"""Registers functions to be called if an exception or signal occurs.
|
||||
|
||||
@@ -62,7 +55,7 @@ class ErrorHandler(object):
|
||||
def __exit__(self, exec_type, exec_value, trace):
|
||||
self.body_executed = True
|
||||
retval = False
|
||||
if exec_type is SignalExit:
|
||||
if exec_type is errors.SignalExit:
|
||||
logger.debug("Encountered signals: %s", self.received_signals)
|
||||
self.call_registered()
|
||||
for signum in self.received_signals:
|
||||
@@ -120,7 +113,7 @@ class ErrorHandler(object):
|
||||
"""
|
||||
self.received_signals.append(signum)
|
||||
if not self.body_executed:
|
||||
raise SignalExit
|
||||
raise errors.SignalExit
|
||||
|
||||
def call_signal(self, signum):
|
||||
"""Calls the signal given by signum.
|
||||
|
||||
@@ -29,6 +29,10 @@ class HookCommandNotFound(Error):
|
||||
"""Failed to find a hook command in the PATH."""
|
||||
|
||||
|
||||
class SignalExit(Error):
|
||||
"""A Unix signal was recieved while in the ErrorHandler context manager."""
|
||||
|
||||
|
||||
# Auth Handler Errors
|
||||
class AuthorizationError(Error):
|
||||
"""Authorization error."""
|
||||
|
||||
Reference in New Issue
Block a user