Commit ed51c163 authored by Petr Špaček's avatar Petr Špaček

Deckard: PEP8 reindent

Cheap re-indentation using reindent.py from python-2.7.13.
This costs nothing and will avoid PEP8 complaints about tabs in CI.
parent 215ce4fb
......@@ -22,7 +22,7 @@ import itertools
import calendar
def str2bool(v):
""" Return conversion of JSON-ish string value to boolean. """
""" Return conversion of JSON-ish string value to boolean. """
return v.lower() in ('yes', 'true', 'on')
......@@ -46,7 +46,7 @@ DEFAULT_FEATURE_LIST_DELIM = ';'
DEFAULT_FEATURE_PAIR_DELIM = '='
if "SOCKET_WRAPPER_DEFAULT_IFACE" in os.environ:
DEFAULT_IFACE = int(os.environ["SOCKET_WRAPPER_DEFAULT_IFACE"])
DEFAULT_IFACE = int(os.environ["SOCKET_WRAPPER_DEFAULT_IFACE"])
if DEFAULT_IFACE < 2 or DEFAULT_IFACE > 254 :
DEFAULT_IFACE = 2
os.environ["SOCKET_WRAPPER_DEFAULT_IFACE"]="{}".format(DEFAULT_IFACE)
......@@ -101,7 +101,7 @@ def setup_env(scenario, child_env, config, config_name_list, j2template_list):
child_env["FAKETIME_NO_CACHE"] = "1"
child_env["FAKETIME_TIMESTAMP_FILE"] = '%s/.time' % TMPDIR
write_timestamp_file(child_env["FAKETIME_TIMESTAMP_FILE"], int (time.time()))
# Set up child process env()
# Set up child process env()
child_env["SOCKET_WRAPPER_DEFAULT_IFACE"] = "%i" % CHILD_IFACE
child_env["SOCKET_WRAPPER_DIR"] = TMPDIR
# do not pass SOCKET_WRAPPER_PCAP_FILE into child to avoid duplicate packets in pcap
......@@ -217,8 +217,8 @@ def play_object(path, binary_name, config_name, j2template, binary_additional_pa
daemon_log = open('%s/server.log' % TMPDIR, 'w')
daemon_args = [binary_name] + binary_additional_pars
try :
daemon_proc = subprocess.Popen(daemon_args, stdout=daemon_log, stderr=daemon_log,
cwd=TMPDIR, preexec_fn=os.setsid, env=daemon_env)
daemon_proc = subprocess.Popen(daemon_args, stdout=daemon_log, stderr=daemon_log,
cwd=TMPDIR, preexec_fn=os.setsid, env=daemon_env)
except Exception as e:
server.stop()
raise Exception("Can't start '%s': %s" % (daemon_args, str(e)))
......@@ -304,9 +304,9 @@ if __name__ == '__main__':
template_name_list = sys.argv[3].split(':')
config_name_list = sys.argv[4].split(':')
if len(template_name_list) != len (config_name_list):
print("ERROR: Number of j2 template files not equal to number of file names to be generated")
print("i.e. len(<template>) != len(<config name>), see usage")
sys.exit(0)
print("ERROR: Number of j2 template files not equal to number of file names to be generated")
print("i.e. len(<template>) != len(<config name>), see usage")
sys.exit(0)
if len(sys.argv) > 5:
binary_additional_pars = sys.argv[5:]
......
......@@ -11,4 +11,3 @@ def dprint(tag, msg):
dprint_lock.acquire()
print(tag, msg)
dprint_lock.release()
......@@ -434,7 +434,7 @@ class Step:
self.repeat_if_fail = 0
self.pause_if_fail = 0
self.next_if_fail = -1
if type == 'CHECK_ANSWER':
for arg in extra_args:
param = arg.split('=')
......
......@@ -204,23 +204,23 @@ class TestServer:
if self.active is False:
raise Exception("[query_io] Test server not active")
while self.active is True:
objects = self.srv_socks + self.connections
to_read, _, to_error = select.select(objects, [], objects, 0.1)
for sock in to_read:
if sock in self.srv_socks:
if (sock.proto == socket.IPPROTO_TCP):
conn, addr = sock.accept()
self.connections.append(conn)
else:
self.handle_query(sock)
elif sock in self.connections:
if not self.handle_query(sock):
sock.close()
self.connections.remove(sock)
else:
raise Exception("[query_io] Socket IO internal error {}, exit".format(sock.getsockname()))
for sock in to_error:
raise Exception("[query_io] Socket IO error {}, exit".format(sock.getsockname()))
objects = self.srv_socks + self.connections
to_read, _, to_error = select.select(objects, [], objects, 0.1)
for sock in to_read:
if sock in self.srv_socks:
if (sock.proto == socket.IPPROTO_TCP):
conn, addr = sock.accept()
self.connections.append(conn)
else:
self.handle_query(sock)
elif sock in self.connections:
if not self.handle_query(sock):
sock.close()
self.connections.remove(sock)
else:
raise Exception("[query_io] Socket IO internal error {}, exit".format(sock.getsockname()))
for sock in to_error:
raise Exception("[query_io] Socket IO error {}, exit".format(sock.getsockname()))
def start_srv(self, address = None, family = socket.AF_INET, proto = socket.IPPROTO_UDP):
""" Starts listening thread if necessary """
......@@ -277,7 +277,7 @@ if __name__ == '__main__':
DEFAULT_IFACE = 0
CHILD_IFACE = 0
if "SOCKET_WRAPPER_DEFAULT_IFACE" in os.environ:
DEFAULT_IFACE = int(os.environ["SOCKET_WRAPPER_DEFAULT_IFACE"])
DEFAULT_IFACE = int(os.environ["SOCKET_WRAPPER_DEFAULT_IFACE"])
if DEFAULT_IFACE < 2 or DEFAULT_IFACE > 254 :
DEFAULT_IFACE = 10
os.environ["SOCKET_WRAPPER_DEFAULT_IFACE"]="{}".format(DEFAULT_IFACE)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment