mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
b1ee1d1188
- now uses envions instead of os.path.expand users for config file name - made readme smaller
32 lines
698 B
Python
32 lines
698 B
Python
import logging
|
|
import traceback
|
|
from functools import wraps
|
|
|
|
|
|
def uses_session(f):
|
|
@wraps(f)
|
|
def wrapper(*args, **kwargs):
|
|
from .web import get_session
|
|
if get_session(args[0]) is None:
|
|
logging.error("Couldn't create a session")
|
|
return None
|
|
else:
|
|
return f(*args, **kwargs)
|
|
|
|
return wrapper
|
|
|
|
|
|
def fallback(default):
|
|
def inner(f):
|
|
# noinspection PyBroadException
|
|
@wraps(f)
|
|
def wrapper(*args, **kwargs):
|
|
try:
|
|
return f(*args, **kwargs)
|
|
except Exception:
|
|
traceback.print_exc()
|
|
return default
|
|
return wrapper
|
|
|
|
return inner
|