Enable Flake8 Ambiguous Variable Name Error

Flake8 currently ignores ambiguous variable name error (E741)
Enable it for more thorough testing of code

Change-Id: I752b4a2a380ee086882260981c448bd7217de003
Story: 2004515
Task: 30076
Signed-off-by: Eric Barrett <eric.barrett@windriver.com>
This commit is contained in:
Eric Barrett 2019-03-27 16:50:26 -04:00
parent 497f93c7c7
commit cca0675a03
3 changed files with 36 additions and 39 deletions

View File

@ -1195,20 +1195,20 @@ def getPlatformCores(node, cpe):
def isActiveController():
logging.basicConfig(filename="/tmp/livestream.log", filemode="a", format="%(asctime)s %(levelname)s %(message)s", level=logging.INFO)
try:
o = Popen("sm-dump", shell=True, stdout=PIPE)
o.stdout.readline()
o.stdout.readline()
p = Popen("sm-dump", shell=True, stdout=PIPE)
p.stdout.readline()
p.stdout.readline()
# read line for active/standby
l = o.stdout.readline().strip("\n").split()
per = l[1]
o.kill()
line = p.stdout.readline().strip("\n").split()
per = line[1]
p.kill()
if per == "active":
return True
else:
return False
except Exception:
if o is not None:
o.kill()
if p is not None:
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()))
return False
@ -1456,18 +1456,18 @@ if __name__ == "__main__":
influx_info.append(influx_db)
# add config options to log
with open("/tmp/livestream.log", "w") as e:
e.write("Configuration for {}:\n".format(node))
e.write("-InfluxDB address: {}:{}\n".format(influx_ip, influx_port))
e.write("-InfluxDB name: {}\n".format(influx_db))
e.write("-CPE lab: {}\n".format(str(cpe_lab)))
e.write(("-Collect API requests: {}\n".format(str(collect_api_requests))))
e.write(("-Collect all services: {}\n".format(str(collect_all_services))))
e.write(("-Fast postgres connections: {}\n".format(str(fast_postgres_connections))))
e.write(("-Automatic database removal: {}\n".format(str(auto_delete_db))))
with open("/tmp/livestream.log", "w") as log_file:
log_file.write("Configuration for {}:\n".format(node))
log_file.write("-InfluxDB address: {}:{}\n".format(influx_ip, influx_port))
log_file.write("-InfluxDB name: {}\n".format(influx_db))
log_file.write("-CPE lab: {}\n".format(str(cpe_lab)))
log_file.write(("-Collect API requests: {}\n".format(str(collect_api_requests))))
log_file.write(("-Collect all services: {}\n".format(str(collect_all_services))))
log_file.write(("-Fast postgres connections: {}\n".format(str(fast_postgres_connections))))
log_file.write(("-Automatic database removal: {}\n".format(str(auto_delete_db))))
if duration is not None:
e.write("-Live stream duration: {}\n".format(unconverted_duration))
e.close()
log_file.write("-Live stream duration: {}\n".format(unconverted_duration))
log_file.close()
# add POSTROUTING entry to NAT table
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.communicate()
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
for line in p.stdout:
tmp.append(line.strip("\n"))
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 l.startswith("MASQUERADE tcp -- anywhere"):
if formatted_line.startswith("MASQUERADE tcp -- anywhere"):
line_number = line.strip("\n").split()[0]
p1 = Popen("iptables -t nat -D POSTROUTING {}".format(line_number), shell=True)
p1.communicate()

View File

@ -280,29 +280,29 @@ def parse_arguments(debug, show):
(L_opts, L_brief, L_details, L_other) = define_options()
# Select potentially multiple values from the following options
O = set([])
O.update(L_brief)
O.update(L_details)
O.update(L_other)
S = sorted(O)
S[0:0] = L_opts
options = set([])
options.update(L_brief)
options.update(L_details)
options.update(L_other)
sorted_options = sorted(options)
sorted_options[0:0] = L_opts
# Enable debug option, but its usage/help is hidden.
D = list(debug.keys())
D.sort()
D.insert(0, 'all')
debug_options = list(debug.keys())
debug_options.sort()
debug_options.insert(0, 'all')
# Parse arguments
cli_opts = [
ChoiceOpt('show',
default=['brief'],
choices=sorted(list(set(S))),
metavar='<' + ','.join(str(x) for x in S) + '>',
choices=sorted(list(set(sorted_options))),
metavar='<' + ','.join(str(x) for x in sorted_options) + '>',
help='Show summary of selected tables'),
ChoiceOpt('dbg',
default=[],
choices=sorted(list(set(D))),
metavar='<' + ','.join(str(x) for x in D) + '>',
choices=sorted(list(set(debug_options))),
metavar='<' + ','.join(str(x) for x in debug_options) + '>',
help='Print debugging information for selected tables'),
]

View File

@ -52,7 +52,6 @@ commands =
# E402 module level import not at top of file
# E501 line too long > 80
# E722 do not use bare except'
# E741 ambiguous variable name 'O'
# H series are hacking
# H101: Use TODO(NAME)
# H102 is apache license
@ -76,7 +75,7 @@ commands =
# F series
# F401 'module' imported but unused
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,
W191,W291,W391,W503,
B001,B007,B301,