mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 15:27:17 +00:00
change logging module imports
This commit is contained in:
parent
15609ba044
commit
011b4e2e31
@ -19,13 +19,13 @@
|
|||||||
#
|
#
|
||||||
import datetime
|
import datetime
|
||||||
import io
|
import io
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from logging import Logger
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, Generator, IO, Iterable, List, Optional, Type, Union
|
from typing import Any, Dict, Generator, IO, Iterable, List, Optional, Type, Union
|
||||||
|
|
||||||
@ -38,7 +38,8 @@ __all__ = ["check_output", "check_user", "exception_response_text", "filter_json
|
|||||||
|
|
||||||
|
|
||||||
def check_output(*args: str, exception: Optional[Exception] = None, cwd: Optional[Path] = None,
|
def check_output(*args: str, exception: Optional[Exception] = None, cwd: Optional[Path] = None,
|
||||||
input_data: Optional[str] = None, logger: Optional[Logger] = None, user: Optional[int] = None) -> str:
|
input_data: Optional[str] = None, logger: Optional[logging.Logger] = None,
|
||||||
|
user: Optional[int] = None) -> str:
|
||||||
"""
|
"""
|
||||||
subprocess wrapper
|
subprocess wrapper
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ def check_output(*args: str, exception: Optional[Exception] = None, cwd: Optiona
|
|||||||
exception (Default value = None)
|
exception (Default value = None)
|
||||||
cwd(Optional[Path], optional): current working directory (Default value = None)
|
cwd(Optional[Path], optional): current working directory (Default value = None)
|
||||||
input_data(Optional[str], optional): data which will be written to command stdin (Default value = None)
|
input_data(Optional[str], optional): data which will be written to command stdin (Default value = None)
|
||||||
logger(Optional[Logger], optional): logger to log command result if required (Default value = None)
|
logger(Optional[logging.Logger], optional): logger to log command result if required (Default value = None)
|
||||||
user(Optional[int], optional): run process as specified user (Default value = None)
|
user(Optional[int], optional): run process as specified user (Default value = None)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -17,10 +17,11 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
import logging
|
||||||
|
|
||||||
from aiohttp.web import middleware, Request
|
from aiohttp.web import middleware, Request
|
||||||
from aiohttp.web_exceptions import HTTPClientError, HTTPException, HTTPServerError
|
from aiohttp.web_exceptions import HTTPClientError, HTTPException, HTTPServerError
|
||||||
from aiohttp.web_response import json_response, StreamResponse
|
from aiohttp.web_response import json_response, StreamResponse
|
||||||
from logging import Logger
|
|
||||||
|
|
||||||
from ahriman.web.middlewares import HandlerType, MiddlewareType
|
from ahriman.web.middlewares import HandlerType, MiddlewareType
|
||||||
|
|
||||||
@ -28,12 +29,12 @@ from ahriman.web.middlewares import HandlerType, MiddlewareType
|
|||||||
__all__ = ["exception_handler"]
|
__all__ = ["exception_handler"]
|
||||||
|
|
||||||
|
|
||||||
def exception_handler(logger: Logger) -> MiddlewareType:
|
def exception_handler(logger: logging.Logger) -> MiddlewareType:
|
||||||
"""
|
"""
|
||||||
exception handler middleware. Just log any exception (except for client ones)
|
exception handler middleware. Just log any exception (except for client ones)
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
logger(Logger): class logger
|
logger(logging.Logger): class logger
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
MiddlewareType: built middleware
|
MiddlewareType: built middleware
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
from aiohttp.web import HTTPFound
|
from aiohttp.web import HTTPFound
|
||||||
|
from aiohttp.web_exceptions import HTTPUnauthorized
|
||||||
|
|
||||||
from ahriman.core.auth.helpers import check_authorized, forget
|
from ahriman.core.auth.helpers import check_authorized, forget
|
||||||
from ahriman.models.user_access import UserAccess
|
from ahriman.models.user_access import UserAccess
|
||||||
@ -41,7 +42,10 @@ class LogoutView(BaseView):
|
|||||||
Raises:
|
Raises:
|
||||||
HTTPFound: on success response
|
HTTPFound: on success response
|
||||||
"""
|
"""
|
||||||
await check_authorized(self.request)
|
try:
|
||||||
|
await check_authorized(self.request)
|
||||||
|
except HTTPUnauthorized:
|
||||||
|
raise HTTPUnauthorized(reason="I'm a teapot")
|
||||||
await forget(self.request, HTTPFound("/"))
|
await forget(self.request, HTTPFound("/"))
|
||||||
|
|
||||||
raise HTTPFound("/")
|
raise HTTPFound("/")
|
||||||
|
Loading…
Reference in New Issue
Block a user