Commit 1be09165 authored by Pavel Spirek's avatar Pavel Spirek

Fixed minor configuration bug, even better error reporting

parent 78340a58
...@@ -4,12 +4,6 @@ import yaml ...@@ -4,12 +4,6 @@ import yaml
from colorlog import info from colorlog import info
from yaml.parser import ParserError from yaml.parser import ParserError
# For backward compatibility
CONFIG_GLOBAL = {}
CONFIG_HTTP = {}
CONFIG_NACM = {}
CONFIG = {}
CFG = None # type: JcConfig CFG = None # type: JcConfig
...@@ -71,16 +65,6 @@ class JcConfig: ...@@ -71,16 +65,6 @@ class JcConfig:
self._gen_shortcuts() self._gen_shortcuts()
def _gen_shortcuts(self): def _gen_shortcuts(self):
global CONFIG_GLOBAL
global CONFIG_HTTP
global CONFIG_NACM
global CONFIG
CONFIG_GLOBAL.update(self.glob)
CONFIG_HTTP.update(self.http)
CONFIG_NACM.update(self.nacm)
CONFIG.update(self.root)
api_root = self.http["API_ROOT"] api_root = self.http["API_ROOT"]
api_root_running = self.http["API_ROOT_RUNNING"] api_root_running = self.http["API_ROOT_RUNNING"]
self.api_root_data = os.path.join(api_root, "data") self.api_root_data = os.path.join(api_root, "data")
...@@ -95,11 +79,12 @@ class JcConfig: ...@@ -95,11 +79,12 @@ class JcConfig:
except ParserError as e: except ParserError as e:
raise ValueError(str(e)) raise ValueError(str(e))
for conf_key in self.root.keys(): for conf_key in conf_yaml.keys():
try: try:
self.root[conf_key].update(conf_yaml[conf_key]) self.root[conf_key].update(conf_yaml[conf_key])
except KeyError: except KeyError:
pass self.root[conf_key] = {}
self.root[conf_key].update(conf_yaml[conf_key])
self._gen_shortcuts() self._gen_shortcuts()
......
...@@ -100,9 +100,13 @@ class ErrorHelpers: ...@@ -100,9 +100,13 @@ class ErrorHelpers:
@staticmethod @staticmethod
def epretty(e: BaseException) -> str: def epretty(e: BaseException) -> str:
ex_type, ex_val, ex_tb = sys.exc_info() ex_type, ex_val, ex_tb = sys.exc_info()
line_no = ex_tb.tb_lineno tb_last = ex_tb
filename = ex_tb.tb_frame.f_code.co_filename
while tb_last.tb_next is not None:
tb_last = tb_last.tb_next
line_no = tb_last.tb_lineno
filename = tb_last.tb_frame.f_code.co_filename
return "{}: {} (file {}, line {})".format(e.__class__.__name__, str(e), filename, line_no) return "{}: {} (file {}, line {})".format(e.__class__.__name__, str(e), filename, line_no)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment