2019-01-24 09:43:22 +00:00
|
|
|
import logging
|
2019-01-24 10:17:50 +00:00
|
|
|
import os
|
2019-01-24 09:43:22 +00:00
|
|
|
from typing import Callable
|
|
|
|
|
|
|
|
logger = logging.getLogger(__file__)
|
|
|
|
|
|
|
|
|
|
|
|
def check_and_warning(*args, fast_fail: bool = False):
|
|
|
|
passed = True
|
|
|
|
for i in args:
|
|
|
|
if isinstance(i, Callable):
|
|
|
|
print(f"check using {i}")
|
2019-01-24 10:17:50 +00:00
|
|
|
cwd = os.getcwd()
|
|
|
|
res = i()
|
|
|
|
os.chdir(cwd)
|
|
|
|
if not res:
|
2019-01-24 09:43:22 +00:00
|
|
|
passed = False
|
|
|
|
logger.warning("check of %s failed!", i)
|
|
|
|
if not passed and fast_fail:
|
|
|
|
return False
|
|
|
|
return passed
|