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

add dependency checks for #225

This commit is contained in:
deadc0de6
2020-05-03 15:06:59 +02:00
parent 6ade21d7b6
commit ef4c48cadd
2 changed files with 18 additions and 2 deletions

View File

@@ -16,7 +16,7 @@ from dotdrop.installer import Installer
from dotdrop.updater import Updater from dotdrop.updater import Updater
from dotdrop.comparator import Comparator from dotdrop.comparator import Comparator
from dotdrop.utils import get_tmpdir, remove, strip_home, \ from dotdrop.utils import get_tmpdir, remove, strip_home, \
run, uniq_list, patch_ignores run, uniq_list, patch_ignores, dependencies_met
from dotdrop.linktypes import LinkTypes from dotdrop.linktypes import LinkTypes
from dotdrop.exceptions import YamlException from dotdrop.exceptions import YamlException
@@ -648,6 +648,13 @@ def main():
if o.debug: if o.debug:
LOG.dbg('\n\n') LOG.dbg('\n\n')
# check dependencies are met
try:
dependencies_met()
except Exception as e:
LOG.err(e)
return False
ret = True ret = True
try: try:

View File

@@ -12,7 +12,7 @@ import uuid
import fnmatch import fnmatch
import inspect import inspect
import importlib import importlib
from shutil import rmtree from shutil import rmtree, which
# local import # local import
from dotdrop.logger import Logger from dotdrop.logger import Logger
@@ -224,3 +224,12 @@ def get_module_from_path(path):
loader = importlib.machinery.SourceFileLoader(module_name, path) loader = importlib.machinery.SourceFileLoader(module_name, path)
mod = loader.load_module() mod = loader.load_module()
return mod return mod
def dependencies_met():
"""make sure all dependencies are met"""
deps = ['file', 'diff', 'mkdir', 'cp']
err = 'The tool \"{}\" was not found in the PATH!'
for dep in deps:
if not which(dep):
raise Exception(err.format(dep))