mirror of
https://github.com/netinvent/npbackup.git
synced 2024-09-20 06:46:13 +08:00
Move debug logic to separate file
This commit is contained in:
parent
e270f892e0
commit
276a539bbc
|
@ -23,10 +23,10 @@ sys.path.insert(0, os.path.normpath(os.path.join(os.path.dirname(__file__), ".."
|
|||
|
||||
from npbackup.customization import PROGRAM_NAME, PROGRAM_DIRECTORY
|
||||
from npbackup.path_helper import CURRENT_DIR
|
||||
from npbackup.__debug__ import _DEBUG
|
||||
|
||||
del sys.path[0]
|
||||
|
||||
_DEBUG = os.environ.get("_DEBUG", False)
|
||||
LOG_FILE = os.path.join(CURRENT_DIR, __intname__ + ".log")
|
||||
|
||||
BASEDIR = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
|
||||
|
|
29
npbackup/__debug__.py
Normal file
29
npbackup/__debug__.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# This file is part of npbackup
|
||||
|
||||
__intname__ = "npbackup.__debug__"
|
||||
__author__ = "Orsiris de Jong"
|
||||
__site__ = "https://www.netperfect.fr/npbackup"
|
||||
__description__ = "NetPerfect Backup Client"
|
||||
__copyright__ = "Copyright (C) 2023 NetInvent"
|
||||
|
||||
|
||||
import os
|
||||
|
||||
|
||||
# If set, debugging will be enabled by setting envrionment variable to __SPECIAL_DEBUG_STRING content
|
||||
# Else, a simple true or false will suffice
|
||||
__SPECIAL_DEBUG_STRING = ""
|
||||
__debug_os_env = os.environ.get("_DEBUG", "False").strip("'\"")
|
||||
|
||||
try:
|
||||
_DEBUG
|
||||
except NameError:
|
||||
_DEBUG = False
|
||||
if __SPECIAL_DEBUG_STRING:
|
||||
if __debug_os_env == __SPECIAL_DEBUG_STRING:
|
||||
_DEBUG = True
|
||||
elif __debug_os_env.capitalize() == "True":
|
||||
_DEBUG = True
|
|
@ -47,6 +47,7 @@ from npbackup.core.upgrade_runner import run_upgrade, check_new_version
|
|||
from npbackup.path_helper import CURRENT_DIR
|
||||
from npbackup.interface_entrypoint import entrypoint
|
||||
from npbackup.__version__ import version_string
|
||||
from npbackup.__debug__ import _DEBUG
|
||||
from npbackup.gui.config import config_gui
|
||||
from npbackup.gui.operations import operations_gui
|
||||
from npbackup.customization import (
|
||||
|
@ -789,6 +790,8 @@ def main_gui():
|
|||
logger.critical(f'Tkinter error: "{exc}". Is this a headless server ?')
|
||||
sys.exit(250)
|
||||
except Exception as exc:
|
||||
sg.Popup(_t("config_gui.bogus_config_file") + f': {exc}')
|
||||
raise #TODO replace with logger
|
||||
sg.Popup(_t("config_gui.unknown_error_see_logs") + f': {exc}')
|
||||
logger.critical("GUI Execution error", exc)
|
||||
if _DEBUG:
|
||||
logger.critical("Trace:", exc_info=True)
|
||||
sys.exit(251)
|
Loading…
Reference in a new issue