Merge "Enable Flake8 Ambiguous Variable Name Error"
This commit is contained in:
commit
98f2ff7bf4
@ -1195,20 +1195,20 @@ def getPlatformCores(node, cpe):
|
|||||||
def isActiveController():
|
def isActiveController():
|
||||||
logging.basicConfig(filename="/tmp/livestream.log", filemode="a", format="%(asctime)s %(levelname)s %(message)s", level=logging.INFO)
|
logging.basicConfig(filename="/tmp/livestream.log", filemode="a", format="%(asctime)s %(levelname)s %(message)s", level=logging.INFO)
|
||||||
try:
|
try:
|
||||||
o = Popen("sm-dump", shell=True, stdout=PIPE)
|
p = Popen("sm-dump", shell=True, stdout=PIPE)
|
||||||
o.stdout.readline()
|
p.stdout.readline()
|
||||||
o.stdout.readline()
|
p.stdout.readline()
|
||||||
# read line for active/standby
|
# read line for active/standby
|
||||||
l = o.stdout.readline().strip("\n").split()
|
line = p.stdout.readline().strip("\n").split()
|
||||||
per = l[1]
|
per = line[1]
|
||||||
o.kill()
|
p.kill()
|
||||||
if per == "active":
|
if per == "active":
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
except Exception:
|
except Exception:
|
||||||
if o is not None:
|
if p is not None:
|
||||||
o.kill()
|
p.kill()
|
||||||
logging.error("sm-dump command could not be called properly. This is usually caused by a swact. Trying again on next call: {}".format(sys.exc_info()))
|
logging.error("sm-dump command could not be called properly. This is usually caused by a swact. Trying again on next call: {}".format(sys.exc_info()))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -1456,18 +1456,18 @@ if __name__ == "__main__":
|
|||||||
influx_info.append(influx_db)
|
influx_info.append(influx_db)
|
||||||
|
|
||||||
# add config options to log
|
# add config options to log
|
||||||
with open("/tmp/livestream.log", "w") as e:
|
with open("/tmp/livestream.log", "w") as log_file:
|
||||||
e.write("Configuration for {}:\n".format(node))
|
log_file.write("Configuration for {}:\n".format(node))
|
||||||
e.write("-InfluxDB address: {}:{}\n".format(influx_ip, influx_port))
|
log_file.write("-InfluxDB address: {}:{}\n".format(influx_ip, influx_port))
|
||||||
e.write("-InfluxDB name: {}\n".format(influx_db))
|
log_file.write("-InfluxDB name: {}\n".format(influx_db))
|
||||||
e.write("-CPE lab: {}\n".format(str(cpe_lab)))
|
log_file.write("-CPE lab: {}\n".format(str(cpe_lab)))
|
||||||
e.write(("-Collect API requests: {}\n".format(str(collect_api_requests))))
|
log_file.write(("-Collect API requests: {}\n".format(str(collect_api_requests))))
|
||||||
e.write(("-Collect all services: {}\n".format(str(collect_all_services))))
|
log_file.write(("-Collect all services: {}\n".format(str(collect_all_services))))
|
||||||
e.write(("-Fast postgres connections: {}\n".format(str(fast_postgres_connections))))
|
log_file.write(("-Fast postgres connections: {}\n".format(str(fast_postgres_connections))))
|
||||||
e.write(("-Automatic database removal: {}\n".format(str(auto_delete_db))))
|
log_file.write(("-Automatic database removal: {}\n".format(str(auto_delete_db))))
|
||||||
if duration is not None:
|
if duration is not None:
|
||||||
e.write("-Live stream duration: {}\n".format(unconverted_duration))
|
log_file.write("-Live stream duration: {}\n".format(unconverted_duration))
|
||||||
e.close()
|
log_file.close()
|
||||||
|
|
||||||
# add POSTROUTING entry to NAT table
|
# add POSTROUTING entry to NAT table
|
||||||
if cpe_lab is False:
|
if cpe_lab is False:
|
||||||
@ -1483,14 +1483,12 @@ if __name__ == "__main__":
|
|||||||
p = Popen("sysctl -w net.ipv4.ip_forward=1 > /dev/null", shell=True)
|
p = Popen("sysctl -w net.ipv4.ip_forward=1 > /dev/null", shell=True)
|
||||||
p.communicate()
|
p.communicate()
|
||||||
p = Popen("iptables -t nat -L --line-numbers", shell=True, stdout=PIPE)
|
p = Popen("iptables -t nat -L --line-numbers", shell=True, stdout=PIPE)
|
||||||
tmp = []
|
tmp = [line.strip("\n") for line in p.stdout.readlines()]
|
||||||
# entries need to be removed in reverse order
|
# entries need to be removed in reverse order
|
||||||
for line in p.stdout:
|
|
||||||
tmp.append(line.strip("\n"))
|
|
||||||
for line in reversed(tmp):
|
for line in reversed(tmp):
|
||||||
l = " ".join(line.strip("\n").split()[1:])
|
formatted_line = " ".join(line.strip("\n").split()[1:])
|
||||||
# if an entry already exists, remove it
|
# if an entry already exists, remove it
|
||||||
if l.startswith("MASQUERADE tcp -- anywhere"):
|
if formatted_line.startswith("MASQUERADE tcp -- anywhere"):
|
||||||
line_number = line.strip("\n").split()[0]
|
line_number = line.strip("\n").split()[0]
|
||||||
p1 = Popen("iptables -t nat -D POSTROUTING {}".format(line_number), shell=True)
|
p1 = Popen("iptables -t nat -D POSTROUTING {}".format(line_number), shell=True)
|
||||||
p1.communicate()
|
p1.communicate()
|
||||||
|
@ -280,29 +280,29 @@ def parse_arguments(debug, show):
|
|||||||
(L_opts, L_brief, L_details, L_other) = define_options()
|
(L_opts, L_brief, L_details, L_other) = define_options()
|
||||||
|
|
||||||
# Select potentially multiple values from the following options
|
# Select potentially multiple values from the following options
|
||||||
O = set([])
|
options = set([])
|
||||||
O.update(L_brief)
|
options.update(L_brief)
|
||||||
O.update(L_details)
|
options.update(L_details)
|
||||||
O.update(L_other)
|
options.update(L_other)
|
||||||
S = sorted(O)
|
sorted_options = sorted(options)
|
||||||
S[0:0] = L_opts
|
sorted_options[0:0] = L_opts
|
||||||
|
|
||||||
# Enable debug option, but its usage/help is hidden.
|
# Enable debug option, but its usage/help is hidden.
|
||||||
D = list(debug.keys())
|
debug_options = list(debug.keys())
|
||||||
D.sort()
|
debug_options.sort()
|
||||||
D.insert(0, 'all')
|
debug_options.insert(0, 'all')
|
||||||
|
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
cli_opts = [
|
cli_opts = [
|
||||||
ChoiceOpt('show',
|
ChoiceOpt('show',
|
||||||
default=['brief'],
|
default=['brief'],
|
||||||
choices=sorted(list(set(S))),
|
choices=sorted(list(set(sorted_options))),
|
||||||
metavar='<' + ','.join(str(x) for x in S) + '>',
|
metavar='<' + ','.join(str(x) for x in sorted_options) + '>',
|
||||||
help='Show summary of selected tables'),
|
help='Show summary of selected tables'),
|
||||||
ChoiceOpt('dbg',
|
ChoiceOpt('dbg',
|
||||||
default=[],
|
default=[],
|
||||||
choices=sorted(list(set(D))),
|
choices=sorted(list(set(debug_options))),
|
||||||
metavar='<' + ','.join(str(x) for x in D) + '>',
|
metavar='<' + ','.join(str(x) for x in debug_options) + '>',
|
||||||
help='Print debugging information for selected tables'),
|
help='Print debugging information for selected tables'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
3
tox.ini
3
tox.ini
@ -52,7 +52,6 @@ commands =
|
|||||||
# E402 module level import not at top of file
|
# E402 module level import not at top of file
|
||||||
# E501 line too long > 80
|
# E501 line too long > 80
|
||||||
# E722 do not use bare except'
|
# E722 do not use bare except'
|
||||||
# E741 ambiguous variable name 'O'
|
|
||||||
# H series are hacking
|
# H series are hacking
|
||||||
# H101: Use TODO(NAME)
|
# H101: Use TODO(NAME)
|
||||||
# H102 is apache license
|
# H102 is apache license
|
||||||
@ -78,7 +77,7 @@ commands =
|
|||||||
# F series
|
# F series
|
||||||
# F401 'module' imported but unused
|
# F401 'module' imported but unused
|
||||||
ignore = E121,E123,E124,E125,E126,E127,E128,E265,E266,
|
ignore = E121,E123,E124,E125,E126,E127,E128,E265,E266,
|
||||||
E302,E303,E305,E402,E501,E722,E741,
|
E302,E303,E305,E402,E501,E722
|
||||||
H101,H102,H104,H201,H238,H237,H306,H401,H404,H405,
|
H101,H102,H104,H201,H238,H237,H306,H401,H404,H405,
|
||||||
W191,W291,W391,W503,
|
W191,W291,W391,W503,
|
||||||
B001,B007,B009,B010,B301,
|
B001,B007,B009,B010,B301,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user