Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@log_traceback
def f():
pass
caplog.set_level(logging.DEBUG)
def _run(worker, f, *args, **kwargs):
# TODO: do another wrapper to wrap notify exceptions and show them
f = log_traceback(f)
worker.submit(f, *args, **kwargs)
@log_traceback
def search(ui, oldfooter, edit_widget, text_input):
logger.debug("%r %r", edit_widget, text_input)
if text_input.endswith("\n"):
# TODO: implement incsearch
# - match needs to be highlighted somehow, not with focus though
ui.mainframe.prompt_bar = None
ui.mainframe.set_footer(oldfooter)
try:
ui.current_buffer.find_next(text_input[:-1])
except NotifyError as ex:
logger.error(repr(ex))
ui.notify_message(str(ex), level="error")
ui.mainframe.set_focus("body")
ui.reload_footer()
@log_traceback
def filter(ui, oldfooter, edit_widget, text_input):
logger.debug("%r %r", edit_widget, text_input)
if text_input.endswith("\n"):
ui.mainframe.prompt_bar = None
ui.mainframe.set_footer(oldfooter)
try:
ui.current_buffer.filter(text_input[:-1])
except NotifyError as ex:
logger.error(repr(ex))
ui.notify_message(str(ex), level="error")
ui.mainframe.set_focus("body")
ui.reload_footer()
@log_traceback
def clear_notification(*args, **kwargs):
# the point here is the log_traceback
self.remove_widget(widget, message=message)
@log_traceback
def do(self, fn, *args, **kwargs):
try:
fn(*args, **kwargs)
except NotifyError as ex:
logger.error(repr(ex))
self.ui.notify_message(str(ex), level="error")
except Exception as ex:
logger.error(repr(ex))
self.ui.notify_message("Command failed: %s" % str(ex), level="error")
raise
@log_traceback
def run_command_callback(ui, docker_object, edit_widget, text_input):
logger.debug("%r %r", edit_widget, text_input)
if "\n" in text_input:
inp = text_input.strip()
inp = inp.replace("\n", "")
# first restore statusbar and then run the command
ui.prompt_bar = None
ui.set_focus("body")
try:
ui.run_command(inp, docker_object=docker_object)
except NoSuchCommand as ex:
logger.info("non-existent command initiated: %r", inp)
ui.notify_message(str(ex), level="error")
except Exception as ex:
logger.info("command %r failed: %r", inp, ex)
ui.notify_message("Error while running command '{}': {}".format(
@log_traceback
def realtime_updates():
g = self.docker_container.stats().response
while True:
try:
update = next(g)
except Exception as ex:
if "Timeout" in ex.__class__.__name__:
logger.info("timeout when reading stats: %r", ex)
g = self.docker_container.stats().response
continue
logger.error("error while getting stats: %r", ex)
self.ui.notify_message("Error while getting stats: %s" % ex, level="error")
# TODO: if debug raise
break
if self.stop.is_set():
@log_traceback
def clear_notification(*args, **kwargs):
# the point here is the log_traceback
self.remove_widget(widget, message=message)