Skip to content

Commit

Permalink
Fix python-checker errors flagged by pylint update (#1612)
Browse files Browse the repository at this point in the history
(cherry picked from commit c4b704a)
  • Loading branch information
kgiusti authored and ganeshmurthy committed Nov 4, 2024
1 parent d7e0889 commit ab46d3a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 20 deletions.
3 changes: 2 additions & 1 deletion scripts/auto_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,11 @@ def get_inter_router_properties(self):
return {"port": "55672"}

def append_connectors(self, connectors):
mode = os.environ.get("QDROUTERD_AUTO_MESH_DISCOVERY", "")
properties = self.get_inter_router_properties()
with open(self.filename, "a") as f:
print("", file=f)
print("# generated by auto-mesh %s" % mode, file=f)
print("# generated by auto-mesh %s" % mode.upper(), file=f)
for c in connectors:
c.update(properties)
c.update(generate_connector_name(c))
Expand Down
4 changes: 2 additions & 2 deletions scripts/gha_purge_successful_test_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ def main() -> int:

log_file = pathlib.Path(build_dir, 'Testing', 'Temporary', 'LastTestsFailed.log')
if not log_file.exists():
logging.info(f"File {log_file} does not exist - nothing to do")
logging.info("File %s does not exist - nothing to do", log_file)
return 0

with log_file.open('rt') as f:
failed_tests = gha_tools.parse_last_tests_failed_log(f)
failed_test_names = {test[1] for test in failed_tests}
logging.debug(f"Failed tests: {failed_test_names}")
logging.debug("Failed tests: %s", failed_test_names)

system_tests_dir = pathlib.Path(build_dir, 'tests', 'system_test.dir', 'tests')
if not system_tests_dir.exists():
Expand Down
9 changes: 5 additions & 4 deletions scripts/sigforwarder.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,22 @@ def pre_exec() -> int:
def handle_signal(sig_number: int, stackframe):
"""Forward the signal we got to the grandchildren"""
del stackframe # unused
logging.debug(f"Sigforwarder got signal: {sig_number}")
logging.debug("Sigforwarder got signal: %s", sig_number)

if not P:
return
logging.debug("We have a child, forwarding signal to all our grandchildren")

for prc in psutil.process_iter(attrs=('pid', 'ppid')):
if prc.ppid() == P.pid:
logging.debug(f"Grandchild pid: {prc.pid}, sending signal: {sig_number} to it")
logging.debug("Grandchild pid: %s, sending signal: %s to it", prc.pid, sig_number)
os.kill(prc.pid, sig_number)


def sigforwarder(program: str, program_args: List[str]) -> int:
global P

# pylint: disable=subprocess-popen-preexec-fn
P = subprocess.Popen(
args=(program, *program_args),
preexec_fn=pre_exec
Expand All @@ -124,7 +125,7 @@ def sigforwarder(program: str, program_args: List[str]) -> int:
signal.signal(s, handle_signal)

# rr will propagate exit code from skrouterd, so we only need to propagate from rr
logging.debug(f"Sigforwarder running {program}, waiting for status")
logging.debug("Sigforwarder running %s, waiting for status", program)
return P.wait()


Expand Down Expand Up @@ -161,7 +162,7 @@ def test_run_child_process_grandchild_gets_the_kill(self):

def main():
if len(sys.argv) < 2:
RuntimeError("At least one argument is required")
raise RuntimeError("At least one argument is required")

argv0, program, *program_args = sys.argv

Expand Down
1 change: 1 addition & 0 deletions tests/pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ disable =
super-with-arguments,
too-few-public-methods,
too-many-arguments,
too-many-positional-arguments,
too-many-branches,
too-many-instance-attributes,
too-many-lines,
Expand Down
2 changes: 1 addition & 1 deletion tools/scraper/log_splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def write_subfiles(self):

os.makedirs(odir)
for i in range(1, self.hist_max):
nrange = ("10e%d" % (i))
nrange = "10e%d" % (i)
ndir = os.path.join(odir, nrange)
os.makedirs(ndir)
odirs.append(ndir)
Expand Down
24 changes: 13 additions & 11 deletions tools/scraper/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
import test_data as td
import common
import text
import router
from router import Router
from router import RestartRecord
from router import which_router_tod

SEQUENCE_TRANSFER_SIZE = 50
"""
Expand Down Expand Up @@ -954,7 +956,7 @@ def __init__(self, _log_index, _instance, _lineno, _line, _comn, _router, opaque
self.line = self.line.lstrip()

# cover for traces that don't get any better
self.data.web_show_str = ("<strong>%s</strong>" % self.line)
self.data.web_show_str = "<strong>%s</strong>" % self.line

# policy lines have no direction and described type fields
if self.data.is_policy_trace or self.data.is_server_info:
Expand All @@ -964,7 +966,7 @@ def __init__(self, _log_index, _instance, _lineno, _line, _comn, _router, opaque
if self.line.startswith('<') or self.line.startswith('-'):
self.data.direction = self.line[:2]
self.line = self.line[3:]
self.data.web_show_str = ("<strong>%s</strong>" % self.line)
self.data.web_show_str = "<strong>%s</strong>" % self.line

# The log line is now reduced to a described type:
# @describedtypename(num) [key=val [, key=val ...]]
Expand Down Expand Up @@ -1032,10 +1034,10 @@ def parse_log_file(fn, log_index, comn):
# Any key or AMQP line indicates a router in-progress
if any(s in line for s in keys) or ("[" in line and "]" in line):
assert rtr is None
rtr = router.Router(fn, log_index, instance)
rtr = Router(fn, log_index, instance)
rtrs.append(rtr)
search_for_in_progress = False
rtr.restart_rec = router.RestartRecord(rtr, line, lineno + 1)
rtr.restart_rec = RestartRecord(rtr, line, lineno + 1)
lineno += 1
verbatim_module = None
if len(comn.verbatim_include_list) > 0:
Expand All @@ -1047,9 +1049,9 @@ def parse_log_file(fn, log_index, comn):
# This line closes the current router, if any, and opens a new one
if rtr is not None:
instance += 1
rtr = router.Router(fn, log_index, instance)
rtr = Router(fn, log_index, instance)
rtrs.append(rtr)
rtr.restart_rec = router.RestartRecord(rtr, line, lineno)
rtr.restart_rec = RestartRecord(rtr, line, lineno)
search_for_in_progress = False
rtr.container_name = line[(line.find(key2) + len(key2)):].strip().split()[0]
elif key3 in line:
Expand Down Expand Up @@ -1154,13 +1156,13 @@ class dummy_args():
t_in_1 = datetime.strptime('2018-10-15 10:59:07.584498', '%Y-%m-%d %H:%M:%S.%f')
t_af_1 = datetime.strptime('2019-10-15 10:59:07.584498', '%Y-%m-%d %H:%M:%S.%f')

rtr, idx = router.which_router_tod(routers, t_b4_0)
rtr, idx = which_router_tod(routers, t_b4_0)
assert rtr is routers[0] and idx == 0
rtr, idx = router.which_router_tod(routers, t_in_0)
rtr, idx = which_router_tod(routers, t_in_0)
assert rtr is routers[0] and idx == 0
rtr, idx = router.which_router_tod(routers, t_in_1)
rtr, idx = which_router_tod(routers, t_in_1)
assert rtr is routers[1] and idx == 1
rtr, idx = router.which_router_tod(routers, t_af_1)
rtr, idx = which_router_tod(routers, t_af_1)
assert rtr is routers[1] and idx == 1

pass
2 changes: 1 addition & 1 deletion tools/scraper/seq-diag-gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, index, line):
self.performative = perf.strip()
self.router_line = router_line.strip() # diag
self.peer_log_rec = None
dir_out = (direction == '->') # name_left -> name_right
dir_out = direction == '->' # name_left -> name_right
self.sentby = name_left.strip() if dir_out else name_right.strip()
self.rcvdby = name_right.strip() if dir_out else name_left.strip()

Expand Down

0 comments on commit ab46d3a

Please sign in to comment.