moved dependency checking to utility module

This commit is contained in:
2017-10-30 11:47:41 +01:00
parent 71ec1f778f
commit a881bdaaf6
2 changed files with 17 additions and 19 deletions

View File

@ -1,7 +1,7 @@
from functools import wraps
from tempfile import mkdtemp
from shutil import rmtree
from subprocess import check_output
from subprocess import check_output, CalledProcessError
VERBOSE = True
@ -55,4 +55,16 @@ class temporary_directory:
def get_output(*args, **kwargs):
return check_output(*args, **kwargs).decode().rstrip('\n')
return check_output(*args, **kwargs).decode().rstrip('\n')
@call_verbose(before_message='Checking your system for dependencies... ', after_message='Found all!')
def check_dependencies(check_for):
error_str = '\nMissing dependencies: {}'
missing = []
for command in check_for:
try: check_output(command)
except (CalledProcessError, FileNotFoundError): missing.append(command[0])
if missing: exit(error_str.format(', '.join(missing)))