allow report exception to be available early
@@ -111,7 +111,7 @@ class Common:
"""
# Get list of paths that our stack trace should be found in.
py3_paths = [os.path.dirname(__file__)]
- user_paths = self.config['include_paths']
+ user_paths = self.config.get('include_paths', [])
py3_paths += [os.path.abspath(path) + '/' for path in user_paths]
traceback = None
@@ -157,7 +157,13 @@ class Common:
del tb
# log the exception and notify user
self.py3_wrapper.log(msg, 'warning')
- if traceback and self.config['log_file']:
+ if traceback:
+ # if debug is not in the config then we are at an early stage of
+ # running py3status and logging is not yet available so output the
+ # error to STDERR so it can be seen
+ if 'debug' not in self.config:
+ print_stderr('\n'.join(traceback))
+ elif self.config.get('log_file'):
self.py3_wrapper.log(''.join(['Traceback\n'] + traceback))
if notify_user:
self.py3_wrapper.notify_user(msg, level=level)
@@ -183,6 +189,11 @@ class Py3statusWrapper():
self.py3_modules_initialized = False
self.queue = deque()
+ # shared code
+ common = Common(self)
+ self.get_config_attribute = common.get_config_attribute
+ self.report_exception = common.report_exception
+
def get_config(self):
"""
Create the py3status based on command line options we received.
@@ -395,8 +406,8 @@ class Py3statusWrapper():
# SIGCONT indicates output should be resumed.
signal(SIGCONT, self.i3bar_start)
- # setup configuration
- self.config = self.get_config()
+ # update configuration
+ self.config.update(self.get_config())
if self.config.get('cli_command'):
self.handle_cli_command(self.config)
@@ -436,11 +447,6 @@ class Py3statusWrapper():
config_path = self.config['i3status_config_path']
self.config['py3_config'] = process_config(config_path, self)
- # shared code
- common = Common(self)
- self.get_config_attribute = common.get_config_attribute
- self.report_exception = common.report_exception
-
# setup i3status thread
self.i3status_thread = I3status(self)
@@ -677,7 +683,7 @@ class Py3statusWrapper():
"""
log this information to syslog or user provided logfile.
"""
- if not self.config['log_file']:
+ if not self.config.get('log_file'):
# If level was given as a str then convert to actual level
level = LOG_LEVELS.get(level, level)
syslog(level, u'{}'.format(msg))
