Skip to content

Commit 1bd004d

Browse files
Merge pull request #1754 from caberos/issue1749
Unhandled error running a subcommand in slcli
2 parents 425046d + f88c7cd commit 1bd004d

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

SoftLayer/CLI/object_storage/credential/__init__.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ def get_command(self, ctx, cmd_name):
3232
"""Get command for click."""
3333
path = "%s.%s" % (__name__, cmd_name)
3434
path = path.replace("-", "_")
35-
module = importlib.import_module(path)
36-
return getattr(module, 'cli')
35+
try:
36+
module = importlib.import_module(path)
37+
return getattr(module, 'cli')
38+
except ModuleNotFoundError as ex:
39+
print(ex.name)
40+
return None
3741

3842

3943
# Required to get the sub-sub-sub command to work.

SoftLayer/CLI/virt/capacity/__init__.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ def get_command(self, ctx, cmd_name):
3737
"""Get command for click."""
3838
path = "%s.%s" % (__name__, cmd_name)
3939
path = path.replace("-", "_")
40-
module = importlib.import_module(path)
41-
return getattr(module, 'cli')
40+
try:
41+
module = importlib.import_module(path)
42+
return getattr(module, 'cli')
43+
except ModuleNotFoundError as ex:
44+
print(ex.name)
45+
return None
4246

4347

4448
# Required to get the sub-sub-sub command to work.

SoftLayer/CLI/virt/placementgroup/__init__.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ def get_command(self, ctx, cmd_name):
3636
"""Get command for click."""
3737
path = "%s.%s" % (__name__, cmd_name)
3838
path = path.replace("-", "_")
39-
module = importlib.import_module(path)
40-
return getattr(module, 'cli')
39+
try:
40+
module = importlib.import_module(path)
41+
return getattr(module, 'cli')
42+
except ModuleNotFoundError as ex:
43+
print(ex.name)
44+
return None
4145

4246

4347
# Required to get the sub-sub-sub command to work.

0 commit comments

Comments
 (0)