Fix pep8/flake8 Error
Fix below errors E128 continuation line under-indented for visual indent E305 expected 2 blank lines after class or function definition, found 1 E502 the backslash is redundant between brackets E722 do not use bare except' E741 ambiguous variable name 'xxxxx' E999 SyntaxError: invalid token Change-Id: Ic826a70aed2cda984cbafedae154c4812bfa37b5 Story: 2003429 Task: 24624 Signed-off-by: Sun Austin <austin.sun@intel.com>
This commit is contained in:
parent
201b94d89f
commit
bae8691911
@ -103,11 +103,11 @@ def rev_lt(num1, num2):
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
n1 = int(n1w.pop(0))
|
n1 = int(n1w.pop(0))
|
||||||
except:
|
except Exception:
|
||||||
return True
|
return True
|
||||||
try:
|
try:
|
||||||
n2 = int(n2w.pop(0))
|
n2 = int(n2w.pop(0))
|
||||||
except:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
if n1 < n2:
|
if n1 < n2:
|
||||||
return True
|
return True
|
||||||
@ -1170,7 +1170,7 @@ class PatchRecipeData:
|
|||||||
write_xml_file(e_top, fname)
|
write_xml_file(e_top, fname)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "[ patch_id: %s, context: %s, metadata: %s, requires: %s, recipies: %s ]" % (str(self.patch_id), str(self.build_context), str(self.metadata), str(self.requires), str(self.recipies, keys()))
|
return "[ patch_id: %s, context: %s, metadata: %s, requires: %s, recipies: %s ]" % (str(self.patch_id), str(self.build_context), str(self.metadata), str(self.requires), str(self.recipies.keys()))
|
||||||
|
|
||||||
def myprint(self, indent=""):
|
def myprint(self, indent=""):
|
||||||
print("patch_id: %s" % str(self.patch_id))
|
print("patch_id: %s" % str(self.patch_id))
|
||||||
@ -1282,8 +1282,8 @@ class PatchRecipeData:
|
|||||||
if prev_patch_id is None:
|
if prev_patch_id is None:
|
||||||
delim = "_"
|
delim = "_"
|
||||||
words = self.patch_id.split(delim)
|
words = self.patch_id.split(delim)
|
||||||
l = len(words[-1])
|
word_lens = len(words[-1])
|
||||||
words[-1] = '0' * l
|
words[-1] = '0' * word_lens
|
||||||
prev_patch_id = delim.join(words)
|
prev_patch_id = delim.join(words)
|
||||||
prev_release_map = self._read_rpm_db(prev_patch_id)
|
prev_release_map = self._read_rpm_db(prev_patch_id)
|
||||||
release_map = self._read_rpm_db(self.patch_id)
|
release_map = self._read_rpm_db(self.patch_id)
|
||||||
@ -1399,9 +1399,9 @@ class PatchRecipeData:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def _tag_build_context():
|
def _tag_build_context(patch_id):
|
||||||
os.chdir(srcdir)
|
os.chdir(srcdir)
|
||||||
issue_cmd("for e in . `wrgit all-core-gits` ; do (cd $e ; git tag v%s) done" % self.patch_id)
|
issue_cmd("for e in . `wrgit all-core-gits` ; do (cd $e ; git tag v%s) done" % patch_id)
|
||||||
|
|
||||||
|
|
||||||
def read_build_info():
|
def read_build_info():
|
||||||
@ -1426,7 +1426,7 @@ def read_build_info():
|
|||||||
if var.startswith('"') and var.endswith('"'):
|
if var.startswith('"') and var.endswith('"'):
|
||||||
var = var[1:-1]
|
var = var[1:-1]
|
||||||
build_info[name] = var
|
build_info[name] = var
|
||||||
except:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -1712,7 +1712,7 @@ def modify_patch():
|
|||||||
print("press 'Release to Production'")
|
print("press 'Release to Production'")
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
except:
|
except Exception:
|
||||||
print("Failed to modify patch!")
|
print("Failed to modify patch!")
|
||||||
finally:
|
finally:
|
||||||
shutil.rmtree(workdir)
|
shutil.rmtree(workdir)
|
||||||
@ -1798,7 +1798,7 @@ def query_patch():
|
|||||||
answer = PatchFile.query_patch(patch_path, field=field)
|
answer = PatchFile.query_patch(patch_path, field=field)
|
||||||
print(str(answer))
|
print(str(answer))
|
||||||
|
|
||||||
except:
|
except Exception:
|
||||||
print("Failed to query patch!")
|
print("Failed to query patch!")
|
||||||
finally:
|
finally:
|
||||||
shutil.rmtree(workdir)
|
shutil.rmtree(workdir)
|
||||||
|
@ -132,7 +132,7 @@ class PatchService:
|
|||||||
sock_in = self.setup_socket_ipv4()
|
sock_in = self.setup_socket_ipv4()
|
||||||
self.socket_lock_release()
|
self.socket_lock_release()
|
||||||
return sock_in
|
return sock_in
|
||||||
except:
|
except Exception:
|
||||||
LOG.exception("Failed to setup socket")
|
LOG.exception("Failed to setup socket")
|
||||||
|
|
||||||
# Close sockets, if necessary
|
# Close sockets, if necessary
|
||||||
|
@ -12,7 +12,7 @@ try:
|
|||||||
|
|
||||||
INITIAL_CONFIG_COMPLETE_FLAG = os.path.join(
|
INITIAL_CONFIG_COMPLETE_FLAG = os.path.join(
|
||||||
tsc.PLATFORM_CONF_PATH, ".initial_config_complete")
|
tsc.PLATFORM_CONF_PATH, ".initial_config_complete")
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
PATCH_AGENT_STATE_IDLE = "idle"
|
PATCH_AGENT_STATE_IDLE = "idle"
|
||||||
|
@ -64,7 +64,7 @@ def setflag(fname):
|
|||||||
try:
|
try:
|
||||||
with open(fname, "w") as f:
|
with open(fname, "w") as f:
|
||||||
f.write("%d\n" % os.getpid())
|
f.write("%d\n" % os.getpid())
|
||||||
except:
|
except Exception:
|
||||||
LOG.exception("Failed to update %s flag" % fname)
|
LOG.exception("Failed to update %s flag" % fname)
|
||||||
|
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ def clearflag(fname):
|
|||||||
if os.path.exists(fname):
|
if os.path.exists(fname):
|
||||||
try:
|
try:
|
||||||
os.remove(fname)
|
os.remove(fname)
|
||||||
except:
|
except Exception:
|
||||||
LOG.exception("Failed to clear %s flag" % fname)
|
LOG.exception("Failed to clear %s flag" % fname)
|
||||||
|
|
||||||
|
|
||||||
@ -753,9 +753,9 @@ class PatchAgent(PatchService):
|
|||||||
shutil.rmtree(insvc_patch_scripts, ignore_errors=True)
|
shutil.rmtree(insvc_patch_scripts, ignore_errors=True)
|
||||||
if os.path.exists(insvc_patch_flags):
|
if os.path.exists(insvc_patch_flags):
|
||||||
shutil.rmtree(insvc_patch_flags, ignore_errors=True)
|
shutil.rmtree(insvc_patch_flags, ignore_errors=True)
|
||||||
os.mkdir(insvc_patch_scripts, 0700)
|
os.mkdir(insvc_patch_scripts, 0o700)
|
||||||
os.mkdir(insvc_patch_flags, 0700)
|
os.mkdir(insvc_patch_flags, 0o700)
|
||||||
except:
|
except Exception:
|
||||||
LOG.exception("Failed to create in-service patch directories")
|
LOG.exception("Failed to create in-service patch directories")
|
||||||
|
|
||||||
# Send a hello to provide a state update
|
# Send a hello to provide a state update
|
||||||
|
@ -74,7 +74,7 @@ def set_term_width():
|
|||||||
width = int(output)
|
width = int(output)
|
||||||
if width > 60:
|
if width > 60:
|
||||||
TERM_WIDTH = width - 4
|
TERM_WIDTH = width - 4
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -588,7 +588,7 @@ class PatchController(PatchService):
|
|||||||
def socket_lock_release(self):
|
def socket_lock_release(self):
|
||||||
try:
|
try:
|
||||||
self.socket_lock.release()
|
self.socket_lock.release()
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def write_state_file(self):
|
def write_state_file(self):
|
||||||
@ -1960,7 +1960,7 @@ class PatchController(PatchService):
|
|||||||
# Translated successfully, but IP isn't in the table.
|
# Translated successfully, but IP isn't in the table.
|
||||||
# Raise an exception to drop out to the failure handling
|
# Raise an exception to drop out to the failure handling
|
||||||
raise PatchError("Host IP (%s) not in table" % ip)
|
raise PatchError("Host IP (%s) not in table" % ip)
|
||||||
except:
|
except Exception:
|
||||||
self.hosts_lock.release()
|
self.hosts_lock.release()
|
||||||
msg = "Unknown host specified: %s" % host_ip
|
msg = "Unknown host specified: %s" % host_ip
|
||||||
msg_error += msg + "\n"
|
msg_error += msg + "\n"
|
||||||
@ -2063,7 +2063,7 @@ class PatchController(PatchService):
|
|||||||
# Translated successfully, but IP isn't in the table.
|
# Translated successfully, but IP isn't in the table.
|
||||||
# Raise an exception to drop out to the failure handling
|
# Raise an exception to drop out to the failure handling
|
||||||
raise PatchError("Host IP (%s) not in table" % ip)
|
raise PatchError("Host IP (%s) not in table" % ip)
|
||||||
except:
|
except Exception:
|
||||||
self.hosts_lock.release()
|
self.hosts_lock.release()
|
||||||
msg = "Unknown host specified: %s" % host_ip
|
msg = "Unknown host specified: %s" % host_ip
|
||||||
msg_error += msg + "\n"
|
msg_error += msg + "\n"
|
||||||
@ -2167,7 +2167,7 @@ class PatchControllerApiThread(threading.Thread):
|
|||||||
global keep_running
|
global keep_running
|
||||||
while keep_running:
|
while keep_running:
|
||||||
self.wsgi.handle_request()
|
self.wsgi.handle_request()
|
||||||
except:
|
except Exception:
|
||||||
# Log all exceptions
|
# Log all exceptions
|
||||||
LOG.exception("Error occurred during request processing")
|
LOG.exception("Error occurred during request processing")
|
||||||
|
|
||||||
@ -2218,7 +2218,7 @@ class PatchControllerAuthApiThread(threading.Thread):
|
|||||||
global keep_running
|
global keep_running
|
||||||
while keep_running:
|
while keep_running:
|
||||||
self.wsgi.handle_request()
|
self.wsgi.handle_request()
|
||||||
except:
|
except Exception:
|
||||||
# Log all exceptions
|
# Log all exceptions
|
||||||
LOG.exception("Authorized API failure: Error occurred during request processing")
|
LOG.exception("Authorized API failure: Error occurred during request processing")
|
||||||
|
|
||||||
@ -2384,7 +2384,7 @@ class PatchControllerMainThread(threading.Thread):
|
|||||||
query = PatchMessageQueryDetailed()
|
query = PatchMessageQueryDetailed()
|
||||||
query.send(agent_sock)
|
query.send(agent_sock)
|
||||||
agent_query_conns.append(agent_sock)
|
agent_query_conns.append(agent_sock)
|
||||||
except:
|
except Exception:
|
||||||
# Put it back on the list
|
# Put it back on the list
|
||||||
stale_hosts.append(ip)
|
stale_hosts.append(ip)
|
||||||
|
|
||||||
@ -2425,7 +2425,7 @@ class PatchControllerMainThread(threading.Thread):
|
|||||||
pc.interim_state[patch_id].remove(n)
|
pc.interim_state[patch_id].remove(n)
|
||||||
|
|
||||||
pc.hosts_lock.release()
|
pc.hosts_lock.release()
|
||||||
except:
|
except Exception:
|
||||||
# Log all exceptions
|
# Log all exceptions
|
||||||
LOG.exception("Error occurred during request processing")
|
LOG.exception("Error occurred during request processing")
|
||||||
thread_death.set()
|
thread_death.set()
|
||||||
|
@ -30,7 +30,7 @@ import rpm
|
|||||||
try:
|
try:
|
||||||
# The tsconfig module is only available at runtime
|
# The tsconfig module is only available at runtime
|
||||||
from tsconfig.tsconfig import SW_VERSION
|
from tsconfig.tsconfig import SW_VERSION
|
||||||
except:
|
except Exception:
|
||||||
SW_VERSION = "unknown"
|
SW_VERSION = "unknown"
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
@ -1188,8 +1188,8 @@ def patch_build():
|
|||||||
'storage=',
|
'storage=',
|
||||||
'all-nodes='])
|
'all-nodes='])
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
print("Usage: %s [ <args> ] ... <rpm list>" \
|
print("Usage: %s [ <args> ] ... <rpm list>"
|
||||||
% os.path.basename(sys.argv[0]))
|
% os.path.basename(sys.argv[0]))
|
||||||
print("Options:")
|
print("Options:")
|
||||||
print("\t--id <id> Patch ID")
|
print("\t--id <id> Patch ID")
|
||||||
print("\t--release <version> Platform release version")
|
print("\t--release <version> Platform release version")
|
||||||
|
@ -23,7 +23,7 @@ def gethostbyname(hostname):
|
|||||||
""" gethostbyname with IPv6 support """
|
""" gethostbyname with IPv6 support """
|
||||||
try:
|
try:
|
||||||
return socket.getaddrinfo(hostname, None)[0][4][0]
|
return socket.getaddrinfo(hostname, None)[0][4][0]
|
||||||
except:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ def ip_to_url(ip_address_string):
|
|||||||
return "[%s]" % ip_address_string
|
return "[%s]" % ip_address_string
|
||||||
else:
|
else:
|
||||||
return ip_address_string
|
return ip_address_string
|
||||||
except:
|
except Exception:
|
||||||
return ip_address_string
|
return ip_address_string
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,5 +40,6 @@ def main():
|
|||||||
app = MyApplication(urls, globals())
|
app = MyApplication(urls, globals())
|
||||||
app.run(port=port)
|
app.run(port=port)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@ -80,7 +80,7 @@ class PatchAlarmDaemon():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
req = requests.get(url)
|
req = requests.get(url)
|
||||||
except:
|
except Exception:
|
||||||
return
|
return
|
||||||
|
|
||||||
entity_instance_id = "%s=%s" % (fm_constants.FM_ENTITY_TYPE_HOST, "controller")
|
entity_instance_id = "%s=%s" % (fm_constants.FM_ENTITY_TYPE_HOST, "controller")
|
||||||
@ -171,7 +171,7 @@ class PatchAlarmDaemon():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
req = requests.get(url)
|
req = requests.get(url)
|
||||||
except:
|
except Exception:
|
||||||
return
|
return
|
||||||
|
|
||||||
entity_instance_id = "%s=%s" % (fm_constants.FM_ENTITY_TYPE_HOST, "controller")
|
entity_instance_id = "%s=%s" % (fm_constants.FM_ENTITY_TYPE_HOST, "controller")
|
||||||
|
17
tox.ini
17
tox.ini
@ -49,27 +49,14 @@ commands =
|
|||||||
-name \*.sh \
|
-name \*.sh \
|
||||||
-print0 | xargs --no-run-if-empty -0 bashate -v -e 'E*' -iE006"
|
-print0 | xargs --no-run-if-empty -0 bashate -v -e 'E*' -iE006"
|
||||||
|
|
||||||
[pep8]
|
|
||||||
# Ignoring these warnings
|
|
||||||
# E501 line too long
|
|
||||||
ignore = E501
|
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# ingore below errors , will fix flake8 errors in future
|
# ignore below errors , will fix flake8 errors in future
|
||||||
# E123, E125 skipped as they are invalid PEP-8.
|
|
||||||
# E128 continuation line under-indented for visual indent
|
|
||||||
# E305 expected 2 blank lines after class or function definition, found 1
|
|
||||||
# E501 skipped because some of the code files include templates
|
# E501 skipped because some of the code files include templates
|
||||||
# that end up quite wide
|
# that end up quite wide
|
||||||
# E502 the backslash is redundant between brackets
|
|
||||||
# E722 do not use bare except'
|
|
||||||
# E741 ambiguous variable name 'l'
|
|
||||||
# E999 SyntaxError: invalid token
|
|
||||||
# F401 'XXXXX' imported but unused
|
# F401 'XXXXX' imported but unused
|
||||||
# F821 undefined name 'XXXX'
|
|
||||||
# F841 local variable 'XXXXXX' is assigned to but never used
|
# F841 local variable 'XXXXXX' is assigned to but never used
|
||||||
show-source = True
|
show-source = True
|
||||||
ignore = E123,E125,E128,E305,E501,E502,E722,E741,E999,F401,F821,F841
|
ignore = E501,F401,F841
|
||||||
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,release-tag-*
|
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,release-tag-*
|
||||||
|
|
||||||
# Use flake8 to replace pep8.
|
# Use flake8 to replace pep8.
|
||||||
|
Loading…
Reference in New Issue
Block a user