Fix nailgun code to pass flake8 tests
Command for flake tests: flake8 --exclude=__init__.py,welcome.py,docs,fuelmenu --ignore=H302,H802 --show-source --show-pep8 --count . Implements: blueprint fix-flake8-in-nailgun-repo Change-Id: Ieb482b2f096c0e8563e2dcd8f2f26e131e9bc716
This commit is contained in:
parent
12b778ddc7
commit
cb7cada968
|
@ -14,16 +14,15 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import signal
|
||||
import string
|
||||
import re
|
||||
import json
|
||||
import time
|
||||
import logging
|
||||
from logging.handlers import SysLogHandler
|
||||
from optparse import OptionParser, OptionGroup
|
||||
from optparse import OptionParser
|
||||
import os
|
||||
import re
|
||||
import signal
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
# Add syslog levels to logging module.
|
||||
|
@ -221,10 +220,8 @@ def sig_handler(signum, frame):
|
|||
def send_all():
|
||||
"""Send any updates."""
|
||||
|
||||
sending_in_progress = 1
|
||||
for group in watchlist:
|
||||
group.send()
|
||||
sending_in_progress = 0
|
||||
|
||||
|
||||
def main_loop():
|
||||
|
@ -285,7 +282,7 @@ class Config:
|
|||
fo = open(cmdline.config_file, 'r')
|
||||
parsed_config = json.load(fo)
|
||||
if cmdline.debug:
|
||||
print parsed_config
|
||||
print(parsed_config)
|
||||
except IOError: # Raised if IO operations failed.
|
||||
main_logger.error("Can not read config file %s\n" %
|
||||
cmdline.config_file)
|
||||
|
|
|
@ -12,8 +12,9 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from mock import call
|
||||
from mock import patch
|
||||
import os
|
||||
from mock import patch, call
|
||||
import unittest
|
||||
|
||||
from scapy import all as scapy
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# Add any Sphinx extension module names here, as strings.
|
||||
# They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions += ['sphinx.ext.inheritance_diagram', 'sphinxcontrib.blockdiag', 'sphinxcontrib.actdiag', 'sphinxcontrib.seqdiag', 'sphinxcontrib.nwdiag']
|
||||
extensions += ['sphinx.ext.inheritance_diagram', 'sphinxcontrib.blockdiag',
|
||||
'sphinxcontrib.actdiag', 'sphinxcontrib.seqdiag',
|
||||
'sphinxcontrib.nwdiag']
|
||||
|
||||
# The encoding of source files.
|
||||
source_encoding = 'utf-8-sig'
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys, os
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.abspath('.'), "..", "nailgun"))
|
||||
autodoc_default_flags = ['members']
|
||||
|
@ -236,8 +237,8 @@ man_pages = [
|
|||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'scaffold', u'scaffold Documentation',
|
||||
texinfo_documents = [(
|
||||
'index', 'scaffold', u'scaffold Documentation',
|
||||
u'Mike Scherbakov', 'scaffold', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
|
52
netcheck.py
52
netcheck.py
|
@ -14,25 +14,31 @@
|
|||
|
||||
|
||||
#!/usr/bin/env python
|
||||
import random
|
||||
import logging
|
||||
import itertools
|
||||
import logging
|
||||
import random
|
||||
|
||||
logging.basicConfig()
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class Vertex(object):
|
||||
def __init__(self, node, interface):
|
||||
self.node = node
|
||||
self.interface = interface
|
||||
|
||||
def __str__(self):
|
||||
return "<Vtx: %s.%s>" % (self.node, self.interface)
|
||||
|
||||
def __repr__(self):
|
||||
return self.__str__()
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.node == other.node and self.interface == other.interface
|
||||
|
||||
def __ne__(self, other):
|
||||
return self.node != other.node or self.interface != other.interface
|
||||
|
||||
def __hash__(self):
|
||||
return hash(str(self))
|
||||
|
||||
|
@ -40,20 +46,27 @@ class Vertex(object):
|
|||
class Arc(object):
|
||||
def __init__(self, vertex_a, vertex_b):
|
||||
self.arc = (vertex_a, vertex_b)
|
||||
|
||||
def __str__(self):
|
||||
return "<Arc: %s>" % (self.arc,)
|
||||
|
||||
def __repr__(self):
|
||||
return self.__str__()
|
||||
|
||||
def __getitem__(self, i):
|
||||
return self.arc[i]
|
||||
|
||||
def __eq__(self, other):
|
||||
l = map(lambda x, y: x == y, self.arc, other.arc)
|
||||
return bool(filter(lambda x: x, l))
|
||||
|
||||
def __ne__(self, other):
|
||||
l = map(lambda x, y: x != y, self.arc, other.arc)
|
||||
return bool(filter(lambda x: x, l))
|
||||
|
||||
def __hash__(self):
|
||||
return hash(str(self))
|
||||
|
||||
def invert(self):
|
||||
return Arc(self.arc[1], self.arc[0])
|
||||
|
||||
|
@ -62,7 +75,8 @@ class NetChecker(object):
|
|||
def __init__(self, nodes, arcs):
|
||||
self.nodes = nodes
|
||||
self.arcs = arcs
|
||||
logger.debug("Init: got %d nodes and %d arcs", len(nodes), len(self.arcs))
|
||||
logger.debug("Init: got %d nodes and %d arcs",
|
||||
len(nodes), len(self.arcs))
|
||||
|
||||
@staticmethod
|
||||
def _invert_arc(arc):
|
||||
|
@ -229,9 +243,6 @@ class ClassbasedNetChecker(NetChecker):
|
|||
return Vertex(node, interface)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def generateFullMesh(nodes, interfaces, Klass, stability=1.0):
|
||||
A = []
|
||||
vertices = itertools.product(nodes, interfaces, nodes, interfaces)
|
||||
|
@ -245,6 +256,7 @@ def generateFullMesh(nodes, interfaces, Klass, stability=1.0):
|
|||
logger.debug("generateArcs: %d arcs generated", len(A))
|
||||
return A
|
||||
|
||||
|
||||
def generateMesh(nodes1, ifaces1, nodes2, ifaces2, Klass, stability=1.0):
|
||||
A = []
|
||||
vertices = itertools.product(nodes1, ifaces1, nodes2, ifaces2)
|
||||
|
@ -261,38 +273,36 @@ def generateMesh(nodes1, ifaces1, nodes2, ifaces2, Klass, stability=1.0):
|
|||
|
||||
def printChoice(choice, step=4):
|
||||
def printlist(l, indent=0, step=2):
|
||||
print '%s[' % (' ' * indent)
|
||||
print('%s[' % (' ' * indent))
|
||||
for i in l:
|
||||
if type(i) is dict:
|
||||
print '%s-' % (' ' * indent)
|
||||
print('%s-' % (' ' * indent))
|
||||
printdict(i, indent + step, step)
|
||||
elif type(i) in (list, tuple):
|
||||
printlist(i, indent + step, step)
|
||||
else:
|
||||
print '%s- %s' % (' ' * indent, str(i))
|
||||
print '%s]' % (' ' * indent)
|
||||
print('%s- %s' % (' ' * indent, str(i)))
|
||||
print('%s]' % (' ' * indent))
|
||||
|
||||
def printdict(d, indent=0, step=2):
|
||||
for k, v in d.iteritems():
|
||||
if type(v) is dict:
|
||||
print '%s%s:' % (' ' * indent, str(k))
|
||||
print('%s%s:' % (' ' * indent, str(k)))
|
||||
printdict(v, indent + step, step)
|
||||
elif type(v) in (list, tuple):
|
||||
print '%s%s:' % (' ' * indent, str(k))
|
||||
print('%s%s:' % (' ' * indent, str(k)))
|
||||
printlist(v, indent + step, step)
|
||||
else:
|
||||
print '%s%s: %s' % (' ' * indent, str(k), str(v))
|
||||
print('%s%s: %s' % (' ' * indent, str(k), str(v)))
|
||||
if type(choice) is dict:
|
||||
printdict(choice, step=step)
|
||||
elif type(choice) is list:
|
||||
printlist(choice, step=step)
|
||||
else:
|
||||
print choice
|
||||
print(choice)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
print ""
|
||||
print("")
|
||||
|
||||
nodes = ['s1', 's2', 's3', 's4']
|
||||
interfaces = ['i0', 'i1', 'i2', 'i3']
|
||||
|
@ -322,10 +332,10 @@ choices = netcheck.get_topos()
|
|||
# print "\n---- Choice number %d: ----\n" % (i + 1)
|
||||
# printChoice(choices[i])
|
||||
if not choices:
|
||||
print "No choices found"
|
||||
print("No choices found")
|
||||
else:
|
||||
print "%d choices found" % len(choices)
|
||||
print ""
|
||||
print("%d choices found" % len(choices))
|
||||
print("")
|
||||
|
||||
#import time
|
||||
#time.sleep(5)
|
||||
|
|
Loading…
Reference in New Issue