mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
[enh] use rich.console.print_exception
This commit is contained in:
parent
2c74d2f108
commit
f802d8139c
4 changed files with 9 additions and 12 deletions
|
@ -1,6 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from rich import traceback
|
||||
from rich.console import Console
|
||||
|
||||
from moulinette.core import (
|
||||
MoulinetteError,
|
||||
|
@ -44,10 +45,11 @@ msignals = MoulinetteSignals()
|
|||
msettings = dict()
|
||||
m18n = Moulinette18n()
|
||||
|
||||
console = Console()
|
||||
|
||||
# pretty traceback using rich
|
||||
traceback.install(show_locals=True, extra_lines=6)
|
||||
|
||||
|
||||
# Package functions
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ from time import time
|
|||
from collections import OrderedDict
|
||||
from importlib import import_module
|
||||
|
||||
from moulinette import m18n, msignals
|
||||
from moulinette import m18n, msignals, console
|
||||
from moulinette.cache import open_cachefile
|
||||
from moulinette.globals import init_moulinette_env
|
||||
from moulinette.core import (
|
||||
|
@ -570,9 +570,7 @@ class ActionsMap(object):
|
|||
)
|
||||
func = getattr(mod, func_name)
|
||||
except (AttributeError, ImportError) as e:
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
console.print_exception()
|
||||
error_message = "unable to load function %s.%s because: %s" % (
|
||||
namespace,
|
||||
func_name,
|
||||
|
|
|
@ -5,6 +5,7 @@ import logging
|
|||
import hashlib
|
||||
import hmac
|
||||
|
||||
from moulinette import console
|
||||
from moulinette.cache import open_cachefile, get_cachedir, cachefile_exists
|
||||
from moulinette.core import MoulinetteError, MoulinetteAuthenticationError
|
||||
|
||||
|
@ -115,9 +116,7 @@ class BaseAuthenticator(object):
|
|||
s_id, s_token = token
|
||||
self._store_session(s_id, s_token)
|
||||
except Exception as e:
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
console.print_exception()
|
||||
logger.exception("unable to store session because %s", e)
|
||||
else:
|
||||
logger.debug("session has been stored")
|
||||
|
|
|
@ -6,7 +6,7 @@ import argparse
|
|||
import copy
|
||||
from collections import deque, OrderedDict
|
||||
|
||||
from moulinette import msettings, m18n
|
||||
from moulinette import msettings, m18n, console
|
||||
from moulinette.core import MoulinetteError
|
||||
|
||||
logger = logging.getLogger("moulinette.interface")
|
||||
|
@ -357,9 +357,7 @@ class _CallbackAction(argparse.Action):
|
|||
mod = __import__(mod_name, globals=globals(), level=0, fromlist=[func_name])
|
||||
func = getattr(mod, func_name)
|
||||
except (AttributeError, ImportError):
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
console.print_exception()
|
||||
raise ValueError("unable to import method {0}".format(self.callback_method))
|
||||
self._callback = func
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue