Skip to content

Commit e6e454d

Browse files
caberoscaberos
authored andcommitted
Unhandled error running a subcommand in slcli
1 parent 2c86f68 commit e6e454d

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

SoftLayer/CLI/object_storage/credential/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ 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)
3740

3841

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

SoftLayer/CLI/virt/capacity/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ 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')
42-
40+
try:
41+
module = importlib.import_module(path)
42+
return getattr(module, 'cli')
43+
except ModuleNotFoundError as ex:
44+
print(ex.name)
4345

4446
# Required to get the sub-sub-sub command to work.
4547
@click.group(cls=CapacityCommands, context_settings=CONTEXT)

SoftLayer/CLI/virt/placementgroup/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ 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)
4144

4245

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

0 commit comments

Comments
 (0)