diff options
| author | Rui Chen <chenrui.momo@gmail.com> | 2017-02-04 17:01:21 +0800 |
|---|---|---|
| committer | Rui Chen <chenrui.momo@gmail.com> | 2017-02-06 09:44:18 +0800 |
| commit | 3afd2b7ff25af7e7998e9c8f4adac8a58a079675 (patch) | |
| tree | 2539971e11786a1088233a48f2e891251dd72d4b /openstackclient/common | |
| parent | 083b115d09b7ccf15bb3c3ab5c799a47efc2d6ac (diff) | |
| download | python-openstackclient-3afd2b7ff25af7e7998e9c8f4adac8a58a079675.tar.gz | |
Fix "module list --all" failed
KeyError cause the command "module list --all" failed,
fix it, and do refactor to filter private modules and
reduce the loop times, add related unit tests and
functional tests.
Change-Id: Icd77739502e05b5f763a04a92547497bf82d5d63
Closes-Bug: #1661814
Diffstat (limited to 'openstackclient/common')
| -rw-r--r-- | openstackclient/common/module.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/openstackclient/common/module.py b/openstackclient/common/module.py index 15719a30..f471b2aa 100644 --- a/openstackclient/common/module.py +++ b/openstackclient/common/module.py @@ -74,15 +74,21 @@ class ListModule(command.ShowOne): mods = sys.modules for k in mods.keys(): k = k.split('.')[0] - # TODO(dtroyer): Need a better way to decide which modules to - # show for the default (not --all) invocation. - # It should be just the things we actually care - # about like client and plugin modules... - if (parsed_args.all or 'client' in k): - try: - data[k] = mods[k].__version__ - except AttributeError: - # aw, just skip it - pass + # Skip private modules and the modules that had been added, + # like: keystoneclient, keystoneclient.exceptions and + # keystoneclient.auth + if not k.startswith('_') and k not in data: + # TODO(dtroyer): Need a better way to decide which modules to + # show for the default (not --all) invocation. + # It should be just the things we actually care + # about like client and plugin modules... + if (parsed_args.all or + # Handle xxxclient and openstacksdk + (k.endswith('client') or k == 'openstack')): + try: + data[k] = mods[k].__version__ + except Exception: + # Catch all exceptions, just skip it + pass return zip(*sorted(six.iteritems(data))) |
