Commit 4a6ea875 authored by Tomas Krizek's avatar Tomas Krizek
Browse files

Merge branch 'show-command-import-errors' into 'master'

CLI: don't supress command module errors

Closes #46

See merge request !44
parents 38229efc 377ad479
Pipeline #80406 passed with stages
in 2 minutes and 48 seconds
......@@ -23,6 +23,7 @@ Options:
# A script for updating the __doc__ string here that is run
# when dev adds a new command might be a decent compromise.
import importlib
import sys
from docopt import docopt
......@@ -91,11 +92,11 @@ def run_command(cargs):
"""
command = cargs[0]
modname = 'apkg.commands.%s' % cmd2mod(command)
try:
mod = __import__(modname, fromlist=[''])
# py35 compat: use ModuleNotFoundError once py3.5 support is dropped
except ImportError:
spec = importlib.util.find_spec(modname)
if not spec:
raise ex.InvalidApkgCommand(command=command)
# import command module
mod = __import__(modname, fromlist=[''])
return mod.run_command(cargs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment