Fixed PEP8/flake8 issues

We need to fix PEP8/flake8 issues corresponding to the new
hacking rules that got added before we can update to the
new global requirements.

Change-Id: Iff995139d258549ff9a8e3e5018e964efa2ab152
This commit is contained in:
Nikhil Manchanda 2013-12-10 15:24:43 -08:00
parent 4790ba1f04
commit 8a1db9b689
27 changed files with 347 additions and 41 deletions

View File

@ -53,5 +53,5 @@ if __name__ == '__main__':
launcher.wait()
except RuntimeError as error:
import traceback
print traceback.format_exc()
print(traceback.format_exc())
sys.exit("ERROR: %s" % error)

View File

@ -43,7 +43,7 @@ oparser = None
def _pretty_print(info):
print json.dumps(info, sort_keys=True, indent=4)
print(json.dumps(info, sort_keys=True, indent=4))
class InstanceCommands(object):
@ -61,7 +61,7 @@ class InstanceCommands(object):
result = dbaas.instances.create(name, flavorRef, volume)
_pretty_print(result._info)
except Exception:
print sys.exc_info()[1]
print(sys.exc_info()[1])
def delete(self, id):
"""Delete the specified instance"""
@ -69,9 +69,9 @@ class InstanceCommands(object):
try:
result = dbaas.instances.delete(id)
if result:
print result
print(result)
except Exception:
print sys.exc_info()[1]
print(sys.exc_info()[1])
def get(self, id):
"""Get details for the specified instance"""
@ -79,7 +79,7 @@ class InstanceCommands(object):
try:
_pretty_print(dbaas.instances.get(id)._info)
except Exception:
print sys.exc_info()[1]
print(sys.exc_info()[1])
def list(self):
"""List all instances for account"""
@ -88,7 +88,7 @@ class InstanceCommands(object):
for instance in dbaas.instances.list():
_pretty_print(instance._info)
except Exception:
print sys.exc_info()[1]
print(sys.exc_info()[1])
def resize(self, id, size):
"""Resize an instance volume"""
@ -96,9 +96,9 @@ class InstanceCommands(object):
try:
result = dbaas.instances.resize(id, size)
if result:
print result
print(result)
except Exception:
print sys.exc_info()[1]
print(sys.exc_info()[1])
def restart(self, id):
"""Restart the database"""
@ -106,9 +106,9 @@ class InstanceCommands(object):
try:
result = dbaas.instances.restart(id)
if result:
print result
print(result)
except Exception:
print sys.exc_info()[1]
print(sys.exc_info()[1])
class FlavorsCommands(object):
@ -124,7 +124,7 @@ class FlavorsCommands(object):
for flavor in dbaas.flavors.list():
_pretty_print(flavor._info)
except Exception:
print sys.exc_info()[1]
print(sys.exc_info()[1])
class DatabaseCommands(object):
@ -140,7 +140,7 @@ class DatabaseCommands(object):
databases = [{'name': dbname}]
dbaas.databases.create(id, databases)
except Exception:
print sys.exc_info()[1]
print(sys.exc_info()[1])
def delete(self, id, dbname):
"""Delete a database"""
@ -148,7 +148,7 @@ class DatabaseCommands(object):
try:
dbaas.databases.delete(id, dbname)
except Exception:
print sys.exc_info()[1]
print(sys.exc_info()[1])
def list(self, id):
"""List the databases"""
@ -157,7 +157,7 @@ class DatabaseCommands(object):
for database in dbaas.databases.list(id):
_pretty_print(database._info)
except Exception:
print sys.exc_info()[1]
print(sys.exc_info()[1])
class UserCommands(object):
@ -176,7 +176,7 @@ class UserCommands(object):
'databases': databases}]
dbaas.users.create(id, users)
except Exception:
print sys.exc_info()[1]
print(sys.exc_info()[1])
def delete(self, id, user):
"""Delete the specified user"""
@ -184,7 +184,7 @@ class UserCommands(object):
try:
dbaas.users.delete(id, user)
except Exception:
print sys.exc_info()[1]
print(sys.exc_info()[1])
def list(self, id):
"""List all the users for an instance"""
@ -193,7 +193,7 @@ class UserCommands(object):
for user in dbaas.users.list(id):
_pretty_print(user._info)
except Exception:
print sys.exc_info()[1]
print(sys.exc_info()[1])
class RootCommands(object):
@ -207,9 +207,9 @@ class RootCommands(object):
dbaas = common.get_client()
try:
user, password = dbaas.root.create(id)
print "User:\t\t%s\nPassword:\t%s" % (user, password)
print("User:\t\t%s\nPassword:\t%s" % (user, password))
except Exception:
print sys.exc_info()[1]
print(sys.exc_info()[1])
def enabled(self, id):
"""Check the instance for root access"""
@ -217,7 +217,7 @@ class RootCommands(object):
try:
_pretty_print(dbaas.root.is_root_enabled(id))
except Exception:
print sys.exc_info()[1]
print(sys.exc_info()[1])
class VersionCommands(object):
@ -234,7 +234,7 @@ class VersionCommands(object):
for version in versions:
_pretty_print(version._info)
except Exception:
print sys.exc_info()[1]
print(sys.exc_info()[1])
def config_options():
@ -285,13 +285,13 @@ def main():
fn(*args)
sys.exit(0)
except TypeError as err:
print "Possible wrong number of arguments supplied."
print "%s %s: %s" % (cmd, action, fn.__doc__)
print "\t\t", [fn.func_code.co_varnames[i] for i in
range(fn.func_code.co_argcount)]
print "ERROR: %s" % err
print("Possible wrong number of arguments supplied.")
print("%s %s: %s" % (cmd, action, fn.__doc__))
print("\t\t", [fn.func_code.co_varnames[i] for i in
range(fn.func_code.co_argcount)])
print("ERROR: %s" % err)
except Exception:
print "Command failed, please check the log for more info."
print("Command failed, please check the log for more info.")
raise
else:
common.print_actions(cmd, actions)

View File

@ -58,5 +58,5 @@ if __name__ == '__main__':
try:
main()
except RuntimeError as error:
print traceback.format_exc()
print(traceback.format_exc())
sys.exit("ERROR: %s" % error)

View File

@ -60,5 +60,5 @@ if __name__ == '__main__':
launcher.wait()
except RuntimeError as error:
import traceback
print traceback.format_exc()
print(traceback.format_exc())
sys.exit("ERROR: %s" % error)

View File

@ -128,8 +128,8 @@ if __name__ == '__main__':
Commands().execute()
sys.exit(0)
except TypeError as e:
print _("Possible wrong number of arguments supplied %s") % e
print(_("Possible wrong number of arguments supplied %s") % e)
sys.exit(2)
except Exception:
print _("Command failed, please check log for more info")
print(_("Command failed, please check log for more info"))
raise

View File

@ -57,5 +57,5 @@ if __name__ == '__main__':
launcher.wait()
except RuntimeError as error:
import traceback
print traceback.format_exc()
print(traceback.format_exc())
sys.exit("ERROR: %s" % error)

View File

@ -66,5 +66,5 @@ if __name__ == '__main__':
launcher.wait()
except RuntimeError as error:
import traceback
print traceback.format_exc()
print(traceback.format_exc())
sys.exit("ERROR: %s" % error)

View File

@ -1,3 +1,21 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
import gettext
import os
import urllib

View File

@ -3,7 +3,7 @@ pep8==1.4.5
pyflakes==0.7.2
flake8==2.0
hacking>=0.5.3,<0.6
sphinx>=1.1.2
sphinx>=1.1.2,<1.2
coverage
nose

View File

@ -1,3 +1,21 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
import inspect
import os

View File

@ -1,3 +1,21 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from trove.common import cfg
from trove.common import exception
from trove.db import models as dbmodels

View File

@ -1,3 +1,21 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from trove.common import wsgi
from trove.datastore import models, views

View File

@ -1,3 +1,21 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from trove.common.views import create_links

View File

@ -1,3 +1,21 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from trove.guestagent.backup.backupagent import BackupAgent
AGENT = BackupAgent()

View File

@ -1,3 +1,21 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
import os
from trove.common import cfg
from trove.common import instance as rd_instance

View File

@ -1,3 +1,21 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
import os
import passlib.utils
import re

View File

@ -1,3 +1,21 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from proboscis import test
from proboscis.asserts import *
from proboscis import SkipTest

View File

@ -1,3 +1,21 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
import time
from proboscis import before_class

View File

@ -1,3 +1,21 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from nose.tools import assert_equal
from nose.tools import assert_true

View File

@ -108,11 +108,11 @@ def mgmt_instance_get():
#TODO(tim-simpson): Validate additional fields, assert
# no extra fields exist.
if api_instance.server is not None:
print "the real content of server: %s" % dir(api_instance.server)
print "the type of server: %s" % type(api_instance.server)
print "the real content of api_instance: %s" % dir(api_instance)
print "the type of api_instance: %s" % type(api_instance)
print hasattr(api_instance, "server")
print("the real content of server: %s" % dir(api_instance.server))
print("the type of server: %s" % type(api_instance.server))
print("the real content of api_instance: %s" % dir(api_instance))
print("the type of api_instance: %s" % type(api_instance))
print(hasattr(api_instance, "server"))
with CollectionCheck("server", api_instance.server) as server:
server.has_element("addresses", dict)

View File

@ -1,3 +1,21 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from collections import deque
from proboscis import test
from proboscis.asserts import *

View File

@ -1,3 +1,21 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from proboscis import test
from proboscis.asserts import *
from proboscis import after_class

View File

@ -174,7 +174,7 @@ class SwiftStorageLoad(testtools.TestCase):
self.assertEqual(download_stream.filename, "123")
with download_stream as stream:
print "Testing SwiftDownloadStream context manager: %s" % stream
print("Testing SwiftDownloadStream context manager: %s" % stream)
self.assertIsNotNone(download_stream.process,
"SwiftDownloadStream process/cmd is supposed "

View File

@ -1,3 +1,21 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
import testtools
from trove.common.pagination import PaginatedDataView

View File

@ -1,3 +1,21 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from mockito import mock, when, unstub
import testtools
from testtools.matchers import *

View File

@ -1,3 +1,21 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
"""
Simulates time itself to make the fake mode tests run even faster.
"""

View File

@ -1,3 +1,21 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
import pexpect
import re
from sqlalchemy import create_engine