handle missing directory

This commit is contained in:
Ondrej Samohel 2020-11-23 12:16:31 +01:00 committed by Ondřej Samohel
parent 7ad9e1bd5b
commit bcf75bf37e
No known key found for this signature in database
GPG key ID: 8A29C663C672C2B7
24 changed files with 443 additions and 105 deletions

View file

@ -379,3 +379,22 @@ class PypeLogger:
_mongo_logging = False
return logger
def timeit(method):
""" Decorator to print how much time function took.
For debugging.
Depends on presence of 'log' object
"""
def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
te = time.time()
if 'log_time' in kw:
name = kw.get('log_name', method.__name__.upper())
kw['log_time'][name] = int((te - ts) * 1000)
else:
log.debug('%r %2.2f ms' % (method.__name__, (te - ts) * 1000))
print('%r %2.2f ms' % (method.__name__, (te - ts) * 1000))
return result
return timed