Skip to content

Commit

Permalink
python: Fix several pep8 whitespace errors.
Browse files Browse the repository at this point in the history
Fix the following pep8 errors:

  E201 whitespace after '('
  E203 whitespace before ','
  E222 multiple spaces after operator
  E225 missing whitespace around operator
  E226 missing whitespace around arithmetic operator
  E231 missing whitespace after ':'
  E241 multiple spaces after ':'
  E251 unexpected spaces around keyword / parameter equals
  E261 at least two spaces before inline comment
  E262 inline comment should start with '# '
  E265 block comment should start with '# '
  E271 multiple spaces after keyword

Signed-off-by: Russell Bryant <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
russellb committed Jan 5, 2016
1 parent 3c05711 commit a0631d9
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 45 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ endif
if HAVE_FLAKE8
ALL_LOCAL += flake8-check
flake8-check: $(FLAKE8_PYFILES)
$(AM_V_GEN) if flake8 $^ --ignore=E111,E112,E113,E123,E126,E127,E128,E129,E131,E201,E203,E222,E225,E226,E231,E241,E251,E261,E262,E265,E271,E501,E502,E703,E713,W601 ${FLAKE8_FLAGS}; then touch $@; else exit 1; fi
$(AM_V_GEN) if flake8 $^ --ignore=E111,E112,E113,E123,E126,E127,E128,E129,E131,E501,E502,E703,E713,W601 ${FLAKE8_FLAGS}; then touch $@; else exit 1; fi
endif

include $(srcdir)/manpages.mk
Expand Down
2 changes: 0 additions & 2 deletions python/ovs/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import ovs.dirs
import ovs.fatal_signal
#import ovs.lockfile
import ovs.process
import ovs.socket_util
import ovs.timeval
Expand Down Expand Up @@ -254,7 +253,6 @@ def _fork_and_wait_for_startup():
# Running in parent process.
os.close(rfd)
ovs.timeval.postfork()
#ovs.lockfile.postfork()

global _daemonize_fd
_daemonize_fd = wfd
Expand Down
2 changes: 1 addition & 1 deletion python/ovs/db/idl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ def _increment(self, row, column):
self._inc_column = column

def _fetch(self, row, column_name):
self._fetch_requests.append({"row":row, "column_name":column_name})
self._fetch_requests.append({"row": row, "column_name": column_name})

def _write(self, row, column, datum):
assert row._changes is not None
Expand Down
6 changes: 6 additions & 0 deletions python/ovs/dirs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# The @variables@ in this file are replaced by default directories for
# use in python/ovs/dirs.py in the source directory and replaced by the
# configured directories for use in the installed python/ovs/dirs.py.
#
import os

# Note that the use of """ is to aid in dealing with paths with quotes in them.
PKGDATADIR = os.environ.get("OVS_PKGDATADIR", """/usr/local/share/openvswitch""")
RUNDIR = os.environ.get("OVS_RUNDIR", """/var/run""")
LOGDIR = os.environ.get("OVS_LOGDIR", """/usr/local/var/log""")
Expand Down
10 changes: 6 additions & 4 deletions python/ovs/dirs.py.template
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
## The @variables@ in this file are replaced by default directories for
## use in python/ovs/dirs.py in the source directory and replaced by the
## configured directories for use in the installed python/ovs/dirs.py.
##
# The @variables@ in this file are replaced by default directories for
# use in python/ovs/dirs.py in the source directory and replaced by the
# configured directories for use in the installed python/ovs/dirs.py.
#
import os

# Note that the use of """ is to aid in dealing with paths with quotes in them.
PKGDATADIR = os.environ.get("OVS_PKGDATADIR", """@pkgdatadir@""")
RUNDIR = os.environ.get("OVS_RUNDIR", """@RUNDIR@""")
LOGDIR = os.environ.get("OVS_LOGDIR", """@LOGDIR@""")
Expand Down
2 changes: 1 addition & 1 deletion python/ovs/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def from_string(s):


class Parser(object):
## Maximum height of parsing stack. ##
# Maximum height of parsing stack. #
MAX_HEIGHT = 1000

def __init__(self, check_trailer=False):
Expand Down
6 changes: 3 additions & 3 deletions python/ovs/jsonrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ def is_valid(self):
return "\"params\" must be JSON array"

pattern = {Message.T_REQUEST: 0x11001,
Message.T_NOTIFY: 0x11000,
Message.T_REPLY: 0x00101,
Message.T_ERROR: 0x00011}.get(self.type)
Message.T_NOTIFY: 0x11000,
Message.T_REPLY: 0x00101,
Message.T_ERROR: 0x00011}.get(self.type)
if pattern is None:
return "invalid JSON-RPC message type %s" % self.type

Expand Down
4 changes: 2 additions & 2 deletions python/ovs/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ class UnixStream(Stream):
@staticmethod
def _open(suffix, dscp):
connect_path = suffix
return ovs.socket_util.make_unix_socket(socket.SOCK_STREAM,
True, None, connect_path)
return ovs.socket_util.make_unix_socket(socket.SOCK_STREAM,
True, None, connect_path)
Stream.register_method("unix", UnixStream)


Expand Down
2 changes: 1 addition & 1 deletion python/ovs/vlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def _format_field(self, tmp, match, replace):
matches = formatting.match(match)
# Do we need to apply padding?
if not matches.group(1) and replace != "":
replace = replace.center(len(replace)+2)
replace = replace.center(len(replace) + 2)
# Does the field have a minimum width
if matches.group(2):
min_width = int(matches.group(2))
Expand Down
2 changes: 1 addition & 1 deletion python/ovstest/udp.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, host, count, size, duration):
def startProtocol(self):
self.looper = LoopingCall(self.sendData)
period = self.duration / float(self.count)
self.looper.start(period , now = False)
self.looper.start(period, now=False)

def stopProtocol(self):
if (self.looper is not None):
Expand Down
12 changes: 6 additions & 6 deletions python/ovstest/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_interface_mtu(iface):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
indata = iface + ('\0' * (32 - len(iface)))
try:
outdata = fcntl.ioctl(s.fileno(), 0x8921, indata) # socket.SIOCGIFMTU
outdata = fcntl.ioctl(s.fileno(), 0x8921, indata) # socket.SIOCGIFMTU
mtu = struct.unpack("16si12x", outdata)[1]
except:
return 0
Expand All @@ -60,7 +60,7 @@ def get_interface(address):
names = array.array('B', '\0' * bytes)
outbytes = struct.unpack('iL', fcntl.ioctl(
s.fileno(),
0x8912, # SIOCGIFCONF
0x8912, # SIOCGIFCONF
struct.pack('iL', bytes, names.buffer_info()[0])
))[0]
namestr = names.tostring()
Expand All @@ -80,9 +80,9 @@ def uname():
def start_process(args):
try:
p = subprocess.Popen(args,
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = p.communicate()
return (p.returncode, out, err)
except exceptions.OSError:
Expand Down Expand Up @@ -186,7 +186,7 @@ def start_local_server(port):
p = subprocess.Popen(["ovs-test", "-s", str(port)],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
preexec_fn=sigint_intercept)
fcntl.fcntl( p.stdout.fileno(),fcntl.F_SETFL,
fcntl.fcntl(p.stdout.fileno(), fcntl.F_SETFL,
fcntl.fcntl(p.stdout.fileno(), fcntl.F_GETFL) | os.O_NONBLOCK)

while p.poll() is None:
Expand Down
2 changes: 1 addition & 1 deletion tests/test-l7.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class OVSFTPHandler(FTPHandler):

def main():
SERVERS = {
'http': [TCPServer, SimpleHTTPRequestHandler, 80],
'http': [TCPServer, SimpleHTTPRequestHandler, 80],
'http6': [TCPServerV6, SimpleHTTPRequestHandler, 80],
}

Expand Down
2 changes: 1 addition & 1 deletion tests/test-unixctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,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))


Expand Down
42 changes: 21 additions & 21 deletions vtep/ovs-vtep
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class Logical_Switch(object):
self.local_macs = macs

def add_remote_mac(self, mac, tunnel):
port_no = self.tunnels.get(tunnel, (0,""))[0]
port_no = self.tunnels.get(tunnel, (0, ""))[0]
if not port_no:
return

Expand Down Expand Up @@ -300,10 +300,10 @@ class Logical_Switch(object):
# vtep's logical_binding_stats. Since we are using the 'interface' from
# the logical switch to collect stats, packets transmitted from it
# is received in the physical switch and vice versa.
stats_map = {'tx_packets':'packets_to_local',
'tx_bytes':'bytes_to_local',
'rx_packets':'packets_from_local',
'rx_bytes':'bytes_from_local'}
stats_map = {'tx_packets': 'packets_to_local',
'tx_bytes': 'bytes_to_local',
'rx_packets': 'packets_from_local',
'rx_bytes': 'bytes_from_local'}

# Go through all the logical switch's interfaces that end with "-l"
# and copy the statistics to logical_binding_stats.
Expand Down Expand Up @@ -362,7 +362,7 @@ def create_vtep_tunnel(remote_ip):
% remote_ip)
tunnel = vtep_ctl("add physical_switch %s tunnels @tun -- "
"--id=@tun create Tunnel local=%s remote=%s"
%(ps_name, local, remote))
% (ps_name, local, remote))
return tunnel


Expand Down Expand Up @@ -426,12 +426,12 @@ def run_bfd():
if not tunnel:
continue

bfd_params_default = {'bfd_params:enable' : 'false',
'bfd_params:min_rx' : 1000,
'bfd_params:min_tx' : 100,
'bfd_params:decay_min_rx' : 0,
'bfd_params:cpath_down' : 'false',
'bfd_params:check_tnl_key' : 'false'}
bfd_params_default = {'bfd_params:enable': 'false',
'bfd_params:min_rx': 1000,
'bfd_params:min_tx': 100,
'bfd_params:decay_min_rx': 0,
'bfd_params:cpath_down': 'false',
'bfd_params:check_tnl_key': 'false'}
bfd_params_values = {}

for key, default in bfd_params_default.iteritems():
Expand All @@ -443,7 +443,7 @@ def run_bfd():
bfd_params_values[key] = column

for key, value in bfd_params_values.iteritems():
new_key = key.replace('_params','')
new_key = key.replace('_params', '')
ovs_vsctl("set interface %s %s=%s" % (port, new_key, value))

bfd_status = ['bfd_status:state', 'bfd_status:forwarding',
Expand All @@ -452,7 +452,7 @@ def run_bfd():
for key in bfd_status:
value = ovs_vsctl("--if-exists get interface %s %s" % (port, key))
if value:
vtep_ctl("set tunnel %s %s=%s" %(tunnel, key, value))
vtep_ctl("set tunnel %s %s=%s" % (tunnel, key, value))
else:
new_key = key.replace('bfd_status:', '')
vtep_ctl("remove tunnel %s bfd_status %s" % (tunnel, new_key))
Expand All @@ -461,11 +461,11 @@ def run_bfd():
% (tunnel, bfd_params_values['bfd_params:enable']))

# Add the defaults as described in VTEP schema to make it explicit.
bfd_lconf_default = {'bfd_config_local:bfd_dst_ip' : '169.254.1.0',
'bfd_config_local:bfd_dst_mac' :
bfd_lconf_default = {'bfd_config_local:bfd_dst_ip': '169.254.1.0',
'bfd_config_local:bfd_dst_mac':
'00:23:20:00:00:01'}
for key, value in bfd_lconf_default.iteritems():
vtep_ctl("set tunnel %s %s=%s" %(tunnel, key, value))
vtep_ctl("set tunnel %s %s=%s" % (tunnel, key, value))

# bfd_config_remote options from VTEP DB should be populated to
# corresponding OVS DB values.
Expand All @@ -490,8 +490,8 @@ def add_binding(binding, ls):
vlog.info("adding binding %s" % binding)

vlan, pp_name = binding.split("-", 1)
pbinding = binding+"-p"
lbinding = binding+"-l"
pbinding = binding + "-p"
lbinding = binding + "-l"

# Create a patch port that connects the VLAN+port to the lswitch.
# Do them as two separate calls so if one side already exists, the
Expand Down Expand Up @@ -532,8 +532,8 @@ def del_binding(binding, ls):
vlog.info("removing binding %s" % binding)

vlan, pp_name = binding.split("-", 1)
pbinding = binding+"-p"
lbinding = binding+"-l"
pbinding = binding + "-p"
lbinding = binding + "-l"

port_no = ovs_vsctl("get Interface %s ofport" % pp_name)
patch_no = ovs_vsctl("get Interface %s ofport" % pbinding)
Expand Down

0 comments on commit a0631d9

Please sign in to comment.