From 019e50968000e5b143d7910fbb048eb52b3a52c2 Mon Sep 17 00:00:00 2001 From: Jylpah Date: Sat, 21 Sep 2019 22:52:27 +0300 Subject: [PATCH] wait() helper function, better error messages for workers --- blitzutils.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/blitzutils.py b/blitzutils.py index 5e53a69..7d4be15 100644 --- a/blitzutils.py +++ b/blitzutils.py @@ -67,7 +67,15 @@ def printWaiter(force = False): if not DEBUG and (not SILENT or force): print('.', end='', flush=True) - + +def wait(sec : int): + for i in range(0, sec): + i=i ## to get rid of the warning... + time.sleep(1) + printWaiter() + print('', flush=True) + + def printNewline(force = False): if not DEBUG and (not SILENT or force): print('', flush=True) @@ -86,12 +94,15 @@ def debug(msg = "", n = None): return None -def error(msg = ""): +def error(msg = "", n = None): """Print an error message""" curframe = inspect.currentframe() calframe = inspect.getouterframes(curframe, 2) caller = calframe[1][3] - print('ERROR: ' + caller + '(): ' + msg) + if n == None: + print('ERROR: ' + caller + '(): ' + msg) + else: + print('ERROR: ' + caller + '()' + '[' + str(n) + ']: ' + msg) return None def NOW() -> int: