@@ -14,7 +14,7 @@ deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
[testenv:pep8]
-commands = flake8
+commands = flake8 --exclude="*testsuite.dir*" ovs/ ovstest/ {toxinidir}/../tests/
[flake8]
ignore=E111,E113,E126,E127,E128,E129,E131
@@ -14,6 +14,7 @@
import re
+
def xapi_local():
return Session()
@@ -97,6 +98,7 @@ class Pool(Table):
def __init__(self):
Table.__init__(self, Pool.__records)
+
class VIF(Table):
__records = ({"uuid": "6ab1b260-398e-49ba-827b-c7696108964c",
"other_config":
@@ -105,6 +107,7 @@ class VIF(Table):
def __init__(self):
Table.__init__(self, VIF.__records)
+
class VM(Table):
__records = ({"uuid": "fcb8a3f6-dc04-41d2-8b8a-55afd2b755b8",
"other_config":
@@ -13,7 +13,6 @@
# limitations under the License.
import argparse
-import logging
import signal
import sys
import time
@@ -88,7 +88,7 @@ def do_listen(name):
if error:
rpc.close()
dead_rpcs.append(rpc)
- rpcs = [rpc for rpc in rpcs if not rpc in dead_rpcs]
+ rpcs = [rpc for rpc in rpcs if rpc not in dead_rpcs]
if done and not rpcs:
break
@@ -189,7 +189,7 @@ notify REMOTE METHOD PARAMS send notification and exit
command_name = args.command[0]
args = args.command_args
- if not command_name in commands:
+ if command_name not in commands:
sys.stderr.write("%s: unknown command \"%s\" "
"(use --help for help)\n" % (argv[0], command_name))
sys.exit(1)
@@ -50,7 +50,7 @@ def get_ftpd():
def main():
SERVERS = {
- 'http': [TCPServer, SimpleHTTPRequestHandler, 80],
+ 'http': [TCPServer, SimpleHTTPRequestHandler, 80],
'http6': [TCPServerV6, SimpleHTTPRequestHandler, 80],
}
@@ -25,7 +25,7 @@ from ovs.db import error
import ovs.db.idl
import ovs.db.schema
from ovs.db import data
-from ovs.db import types
+import ovs.db.types
import ovs.ovsuuid
import ovs.poller
import ovs.util
@@ -33,15 +33,15 @@ import six
def unbox_json(json):
- if type(json) == list and len(json) == 1:
+ if isinstance(json, list) and len(json) == 1:
return json[0]
else:
return json
def do_default_atoms():
- for type_ in types.ATOMIC_TYPES:
- if type_ == types.VoidType:
+ for type_ in ovs.db.types.ATOMIC_TYPES:
+ if type_ == ovs.db.types.VoidType:
continue
sys.stdout.write("%s: " % type_.to_string())
@@ -57,15 +57,16 @@ def do_default_atoms():
def do_default_data():
any_errors = False
for n_min in 0, 1:
- for key in types.ATOMIC_TYPES:
- if key == types.VoidType:
+ for key in ovs.db.types.ATOMIC_TYPES:
+ if key == ovs.db.types.VoidType:
continue
- for value in types.ATOMIC_TYPES:
- if value == types.VoidType:
+ for value in ovs.db.types.ATOMIC_TYPES:
+ if value == ovs.db.types.VoidType:
valueBase = None
else:
- valueBase = types.BaseType(value)
- type_ = types.Type(types.BaseType(key), valueBase, n_min, 1)
+ valueBase = ovs.db.types.BaseType(value)
+ type_ = ovs.db.types.Type(ovs.db.types.BaseType(key),
+ valueBase, n_min, 1)
assert type_.is_valid()
sys.stdout.write("key %s, value %s, n_min %d: "
@@ -83,25 +84,25 @@ def do_default_data():
def do_parse_atomic_type(type_string):
type_json = unbox_json(ovs.json.from_string(type_string))
- atomic_type = types.AtomicType.from_json(type_json)
+ atomic_type = ovs.db.types.AtomicType.from_json(type_json)
print(ovs.json.to_string(atomic_type.to_json(), sort_keys=True))
def do_parse_base_type(type_string):
type_json = unbox_json(ovs.json.from_string(type_string))
- base_type = types.BaseType.from_json(type_json)
+ base_type = ovs.db.types.BaseType.from_json(type_json)
print(ovs.json.to_string(base_type.to_json(), sort_keys=True))
def do_parse_type(type_string):
type_json = unbox_json(ovs.json.from_string(type_string))
- type_ = types.Type.from_json(type_json)
+ type_ = ovs.db.types.Type.from_json(type_json)
print(ovs.json.to_string(type_.to_json(), sort_keys=True))
def do_parse_atoms(type_string, *atom_strings):
type_json = unbox_json(ovs.json.from_string(type_string))
- base = types.BaseType.from_json(type_json)
+ base = ovs.db.types.BaseType.from_json(type_json)
for atom_string in atom_strings:
atom_json = unbox_json(ovs.json.from_string(atom_string))
try:
@@ -113,7 +114,7 @@ def do_parse_atoms(type_string, *atom_strings):
def do_parse_data(type_string, *data_strings):
type_json = unbox_json(ovs.json.from_string(type_string))
- type_ = types.Type.from_json(type_json)
+ type_ = ovs.db.types.Type.from_json(type_json)
for datum_string in data_strings:
datum_json = unbox_json(ovs.json.from_string(datum_string))
datum = data.Datum.from_json(type_, datum_json)
@@ -122,7 +123,7 @@ def do_parse_data(type_string, *data_strings):
def do_sort_atoms(type_string, atom_strings):
type_json = unbox_json(ovs.json.from_string(type_string))
- base = types.BaseType.from_json(type_json)
+ base = ovs.db.types.BaseType.from_json(type_json)
atoms = [data.Atom.from_json(base, atom_json)
for atom_json in unbox_json(ovs.json.from_string(atom_strings))]
print(ovs.json.to_string([data.Atom.to_json(atom)
@@ -207,9 +208,9 @@ def substitute_uuids(json, symtab):
symbol = symtab.get(json)
if symbol:
return str(symbol)
- elif type(json) == list:
+ elif isinstance(json, list):
return [substitute_uuids(element, symtab) for element in json]
- elif type(json) == dict:
+ elif isinstance(json, dict):
d = {}
for key, value in six.iteritems(json):
d[key] = substitute_uuids(value, symtab)
@@ -223,10 +224,10 @@ def parse_uuids(json, symtab):
name = "#%d#" % len(symtab)
sys.stderr.write("%s = %s\n" % (name, json))
symtab[name] = json
- elif type(json) == list:
+ elif isinstance(json, list):
for element in json:
parse_uuids(element, symtab)
- elif type(json) == dict:
+ elif isinstance(json, dict):
for value in six.itervalues(json):
parse_uuids(value, symtab)
@@ -393,7 +394,6 @@ def idl_set(idl, commands, step):
def do_idl(schema_file, remote, *commands):
schema_helper = ovs.db.idl.SchemaHelper(schema_file)
if commands and commands[0].startswith("?"):
- monitor = {}
readonly = {}
for x in commands[0][1:].split("?"):
readonly = []
@@ -591,21 +591,21 @@ def main(argv):
command_name = args[0]
args = args[1:]
- if not command_name in commands:
+ if command_name not in commands:
sys.stderr.write("%s: unknown command \"%s\" "
"(use --help for help)\n" % (ovs.util.PROGRAM_NAME,
command_name))
sys.exit(1)
func, n_args = commands[command_name]
- if type(n_args) == tuple:
+ if isinstance(n_args, tuple):
if len(args) < n_args[0]:
sys.stderr.write("%s: \"%s\" requires at least %d arguments but "
"only %d provided\n"
% (ovs.util.PROGRAM_NAME, command_name,
n_args, len(args)))
sys.exit(1)
- elif type(n_args) == int:
+ elif isinstance(n_args, int):
if len(args) != n_args:
sys.stderr.write("%s: \"%s\" requires %d arguments but %d "
"provided\n"
@@ -132,7 +132,7 @@ def diff_stats(old, new, delta):
print((" %sconnected" % negate))
if (old.last_connected != new.last_connected or
- (new.msec_since_connect != None and
+ (new.msec_since_connect is not None and
old.msec_since_connect != new.msec_since_connect - delta) or
(old.total_connected_duration != new.total_connected_duration - delta
and not (old.total_connected_duration == 0 and
@@ -141,7 +141,7 @@ def diff_stats(old, new, delta):
% (new.msec_since_connect, new.total_connected_duration)))
if (old.last_disconnected != new.last_disconnected or
- (new.msec_since_disconnect != None and
+ (new.msec_since_disconnect is not None and
old.msec_since_disconnect != new.msec_since_disconnect - delta)):
print((" disconnected at %d ms (%d ms ago)"
% (new.last_disconnected, new.msec_since_disconnect)))
@@ -20,6 +20,7 @@ import sys
import ovs.socket_util
+
def main(argv):
if len(argv) not in (2, 3):
sys.stderr.write("usage: %s SOCKETNAME1 [SOCKETNAME2]", argv[0])
@@ -22,6 +22,7 @@ import ovs.unixctl.server
vlog = ovs.vlog.Vlog("test-unixctl")
exiting = False
+
def unixctl_exit(conn, unused_argv, aux):
assert aux == "aux_exit"
global exiting
@@ -36,7 +37,7 @@ def unixctl_echo(conn, argv, aux):
def unixctl_echo_error(conn, argv, aux):
- assert aux == "aux_echo_error"
+ assert aux == "aux_echo_error"
conn.reply_error(str(argv))
Make flake8 run clean against these. Also use isinstance() instead of direct type comparisons. Update the tox config to run flake8 against these files, as well. Signed-off-by: Russell Bryant <russell@ovn.org> --- python/tox.ini | 2 +- tests/MockXenAPI.py | 3 +++ tests/test-daemon.py | 1 - tests/test-jsonrpc.py | 4 ++-- tests/test-l7.py | 2 +- tests/test-ovsdb.py | 48 +++++++++++++++++++++++------------------------ tests/test-reconnect.py | 4 ++-- tests/test-unix-socket.py | 1 + tests/test-unixctl.py | 3 ++- 9 files changed, 36 insertions(+), 32 deletions(-)