1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 19:09:44 +00:00

check python dependencies

This commit is contained in:
deadc0de6
2020-11-07 16:23:36 +01:00
parent 68b901e667
commit 8e62bc3d97
2 changed files with 31 additions and 8 deletions

View File

@@ -690,6 +690,13 @@ def apply_trans(dotpath, dotfile, templater, debug=False):
def main():
"""entry point"""
# check dependencies are met
try:
dependencies_met()
except Exception as e:
LOG.err(e)
return False
try:
o = Options()
except YamlException as e:
@@ -702,13 +709,6 @@ def main():
if o.debug:
LOG.dbg('\n\n')
# check dependencies are met
try:
dependencies_met()
except Exception as e:
LOG.err(e)
return False
ret = True
try:

View File

@@ -268,11 +268,34 @@ def get_module_from_path(path):
def dependencies_met():
"""make sure all dependencies are met"""
deps = ['file', 'diff', 'mkdir']
# check unix tools deps
deps = ['file', 'diff']
err = 'The tool \"{}\" was not found in the PATH!'
for dep in deps:
if not which(dep):
raise Exception(err.format(dep))
# check python deps
err = 'missing python module {}'
try:
import magic
assert(magic)
except ImportError:
raise Exception(err.format('python-magic'))
try:
from docopt import docopt
assert(docopt)
except ImportError:
raise Exception(err.format('docopt'))
try:
import jinja2
assert(jinja2)
except ImportError:
raise Exception(err.format('jinja2'))
try:
from ruamel.yaml import YAML
assert(YAML)
except ImportError:
raise Exception(err.format('ruamel.yaml'))
def mirror_file_rights(src, dst):