moved dependency checking to utility module
This commit is contained in:
16
utility.py
16
utility.py
@ -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)))
|
||||
|
Reference in New Issue
Block a user