From 016a0b301e0ecfea5d84b09e7f1e22a86953c1c1 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Tue, 14 May 2013 08:28:48 -0700 Subject: [PATCH] Fix flake8 errors in anticipation of flake8 patch. Change-Id: Ifdc4322b699f2bd91a6900e55695acd3d736568e --- openstackclient/common/command.py | 4 ++-- openstackclient/common/utils.py | 2 +- openstackclient/compute/v2/server.py | 2 +- openstackclient/identity/v2_0/service.py | 6 ++++-- openstackclient/identity/v2_0/tenant.py | 3 ++- openstackclient/identity/v2_0/user.py | 3 ++- openstackclient/identity/v3/group.py | 3 ++- openstackclient/identity/v3/project.py | 3 ++- openstackclient/identity/v3/user.py | 3 ++- openstackclient/shell.py | 14 +++++++------- openstackclient/volume/v1/quota.py | 3 ++- tests/identity/test_identity.py | 2 -- tests/test_shell.py | 2 +- 13 files changed, 28 insertions(+), 22 deletions(-) diff --git a/openstackclient/common/command.py b/openstackclient/common/command.py index 64e855df..59cd0da2 100644 --- a/openstackclient/common/command.py +++ b/openstackclient/common/command.py @@ -15,10 +15,10 @@ """OpenStack base command""" -from cliff.command import Command +from cliff import command -class OpenStackCommand(Command): +class OpenStackCommand(command.Command): """Base class for OpenStack commands.""" api = None diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py index 8a792675..56f9cd17 100644 --- a/openstackclient/common/utils.py +++ b/openstackclient/common/utils.py @@ -55,7 +55,7 @@ def find_resource(manager, name_or_id): except Exception as ex: try: return manager.find(display_name=name_or_id) - except: + except Exception: pass if type(ex).__name__ == 'NotFound': diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index 79deaca4..a2496fad 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -528,7 +528,7 @@ class RebuildServer(show.ShowOne): _password = None if parsed_args.rebuild_password is not False: - _password = args.rebuild_password + _password = parsed_args.rebuild_password kwargs = {} server = server.rebuild(image, _password, **kwargs) diff --git a/openstackclient/identity/v2_0/service.py b/openstackclient/identity/v2_0/service.py index 21e32a51..51abfc18 100644 --- a/openstackclient/identity/v2_0/service.py +++ b/openstackclient/identity/v2_0/service.py @@ -141,8 +141,10 @@ class ShowService(show.ShowOne): # FIXME(dtroyer): This exception should eventually come from # common client exceptions except identity_exc.NotFound: - msg = "No service with a type, name or ID of '%s' exists." % \ - name_or_id + msg = "No service with exists." + # TODO(mordred): Where does name_or_id come from? + # msg = ("No service with a type, name or ID of '%s' exists." % + # name_or_id) raise exceptions.CommandError(msg) info = {} diff --git a/openstackclient/identity/v2_0/tenant.py b/openstackclient/identity/v2_0/tenant.py index 8a2f738f..00a6a977 100644 --- a/openstackclient/identity/v2_0/tenant.py +++ b/openstackclient/identity/v2_0/tenant.py @@ -16,6 +16,7 @@ """Tenant action implementations""" import logging +import sys from cliff import command from cliff import lister @@ -167,7 +168,7 @@ class SetTenant(command.Command): kwargs['enabled'] = parsed_args.enabled if kwargs == {}: - stdout.write("Tenant not updated, no arguments present") + sys.stdout.write("Tenant not updated, no arguments present") return 0 tenant.update(**kwargs) return diff --git a/openstackclient/identity/v2_0/user.py b/openstackclient/identity/v2_0/user.py index 840cc500..03da6008 100644 --- a/openstackclient/identity/v2_0/user.py +++ b/openstackclient/identity/v2_0/user.py @@ -16,6 +16,7 @@ """Identity v2.0 User action implementations""" import logging +import sys from cliff import command from cliff import lister @@ -196,7 +197,7 @@ class SetUser(command.Command): kwargs['enabled'] = parsed_args.enabled if not len(kwargs): - stdout.write("User not updated, no arguments present") + sys.stdout.write("User not updated, no arguments present") return identity_client.users.update(user.id, **kwargs) return diff --git a/openstackclient/identity/v3/group.py b/openstackclient/identity/v3/group.py index 3a9b80ed..0562b766 100644 --- a/openstackclient/identity/v3/group.py +++ b/openstackclient/identity/v3/group.py @@ -16,6 +16,7 @@ """Group action implementations""" import logging +import sys from cliff import command from cliff import lister @@ -157,7 +158,7 @@ class SetGroup(command.Command): kwargs['domain'] = domain if not len(kwargs): - stdout.write("Group not updated, no arguments present") + sys.stdout.write("Group not updated, no arguments present") return identity_client.groups.update(group.id, **kwargs) return diff --git a/openstackclient/identity/v3/project.py b/openstackclient/identity/v3/project.py index d1e67acc..84271cd9 100644 --- a/openstackclient/identity/v3/project.py +++ b/openstackclient/identity/v3/project.py @@ -16,6 +16,7 @@ """Project action implementations""" import logging +import sys from cliff import command from cliff import lister @@ -189,7 +190,7 @@ class SetProject(command.Command): kwargs['enabled'] = parsed_args.enabled if kwargs == {}: - stdout.write("Project not updated, no arguments present") + sys.stdout.write("Project not updated, no arguments present") return project.update(**kwargs) return diff --git a/openstackclient/identity/v3/user.py b/openstackclient/identity/v3/user.py index bf592d81..7bd37065 100644 --- a/openstackclient/identity/v3/user.py +++ b/openstackclient/identity/v3/user.py @@ -16,6 +16,7 @@ """Identity v3 User action implementations""" import logging +import sys from cliff import command from cliff import lister @@ -215,7 +216,7 @@ class SetUser(command.Command): kwargs['enabled'] = parsed_args.enabled if not len(kwargs): - stdout.write("User not updated, no arguments present") + sys.stdout.write("User not updated, no arguments present") return identity_client.users.update(user.id, **kwargs) return diff --git a/openstackclient/shell.py b/openstackclient/shell.py index 303771c6..cd5ab552 100644 --- a/openstackclient/shell.py +++ b/openstackclient/shell.py @@ -20,14 +20,14 @@ import logging import os import sys -from cliff.app import App -from cliff.help import HelpAction +from cliff import app +from cliff import help from openstackclient.common import clientmanager +from openstackclient.common.commandmanager import CommandManager from openstackclient.common import exceptions as exc from openstackclient.common import openstackkeyring from openstackclient.common import utils -from openstackclient.common.commandmanager import CommandManager VERSION = '0.1' @@ -53,7 +53,7 @@ def env(*vars, **kwargs): return kwargs.get('default', '') -class OpenStackShell(App): +class OpenStackShell(app.App): CONSOLE_MESSAGE_FORMAT = '%(levelname)s: %(name)s %(message)s' @@ -75,10 +75,10 @@ class OpenStackShell(App): # have been loaded. There doesn't seem to be a # way to edit/remove anything from an existing parser. - # Replace the cliff-added HelpAction to defer its execution + # Replace the cliff-added help.HelpAction to defer its execution self.DeferredHelpAction = None for a in self.parser._actions: - if type(a) == HelpAction: + if type(a) == help.HelpAction: # Found it, save and replace it self.DeferredHelpAction = a @@ -359,7 +359,7 @@ class OpenStackShell(App): def main(argv=sys.argv[1:]): try: return OpenStackShell().run(argv) - except: + except Exception: return 1 diff --git a/openstackclient/volume/v1/quota.py b/openstackclient/volume/v1/quota.py index ae6c50f5..4f4e97e8 100644 --- a/openstackclient/volume/v1/quota.py +++ b/openstackclient/volume/v1/quota.py @@ -16,6 +16,7 @@ """Volume v1 Quota action implementations""" import logging +import sys from cliff import command from cliff import show @@ -79,7 +80,7 @@ class SetQuota(command.Command): kwargs['gigabytes'] = parsed_args.gigabytes if kwargs == {}: - stdout.write("Quota not updated, no arguments present") + sys.stdout.write("Quota not updated, no arguments present") return volume_client = self.app.client_manager.volume diff --git a/tests/identity/test_identity.py b/tests/identity/test_identity.py index 5b2cf4e3..52bbd222 100644 --- a/tests/identity/test_identity.py +++ b/tests/identity/test_identity.py @@ -13,8 +13,6 @@ # under the License. # -import mock - from openstackclient.common import clientmanager from openstackclient.identity import client as identity_client from tests import utils diff --git a/tests/test_shell.py b/tests/test_shell.py index c33068d8..d0eb5b0d 100644 --- a/tests/test_shell.py +++ b/tests/test_shell.py @@ -13,8 +13,8 @@ # under the License. # -import os import mock +import os from openstackclient import shell from tests import utils