Skip to content

Commit

Permalink
Merge pull request #2350 from cms-sw/py312-1
Browse files Browse the repository at this point in the history
[py312][1/3] fixing SyntaxWarning warnings
  • Loading branch information
smuzaffar authored Oct 2, 2024
2 parents 3543cc6 + 0a2b3bf commit f6042bc
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 60 deletions.
2 changes: 1 addition & 1 deletion RelValArgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def GetMatrixOptions(release, arch, dasfile=None):
cmd = cmd.replace(m.group(1), val)
m = re.search("(@([a-zA-Z_]+)@)", cmd)

return re.sub("\s+", " ", cmd)
return re.sub("\\s+", " ", cmd)


def GetWFThreads(args):
Expand Down
2 changes: 1 addition & 1 deletion archive/create_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def extract_data(inputfile):
first_char = file.read(1)
if not first_char:
print("Error: Input file is empty"), sys.exit(1)
pattern = re.compile("^([a-z]+)\+([\w-]+)\+([\w.-]+)\s\(([\w]+)\)")
pattern = re.compile(r"^([a-z]+)\+([\w-]+)\+([\w.-]+)\s\(([\w]+)\)")
matched_lines = [pattern.match(l) for l in file.readlines()]
for line in matched_lines:
if line:
Expand Down
4 changes: 2 additions & 2 deletions archive/es_hypernews.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
cmd_to_get_logs = cmd_to_get_logs + " | tail -2"
prev_hour = datetime.now() - timedelta(hours=1)
filter_search = (
" | grep '" + prev_hour.strftime("^\[%a %b %d %H:[0-5][0-9]:[0-5][0-9] %Y\] ") + "'"
" | grep '" + prev_hour.strftime(r"^\[%a %b %d %H:[0-5][0-9]:[0-5][0-9] %Y\] ") + "'"
)

err, out = run_cmd(cmd_to_get_logs)
if err:
print(out)
sys.exit(1)
ReTime = re.compile(
"^\[[A-Za-z]{3} ([A-Za-z]{3} [0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [0-9]{4})] \[[^]]+] \[client (.+)]\s(.+)"
r"^\[[A-Za-z]{3} ([A-Za-z]{3} [0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [0-9]{4})] \[[^]]+] \[client (.+)]\s(.+)"
)
for log in out.split("\n"):
find_cmd = "grep '%s' %s %s" % (search_for, log, filter_search)
Expand Down
4 changes: 2 additions & 2 deletions archive/es_hypernews_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def map_int_val(pair):


# get relevant info
match_hn = re.compile(".*\|\/.*emails")
match_tmp = re.compile(".*\|\/.*Time\(s\)")
match_hn = re.compile(r".*\|\/.*emails")
match_tmp = re.compile(r".*\|\/.*Time\(s\)")
temp_fails = []
egrps = []
payload = {}
Expand Down
4 changes: 2 additions & 2 deletions archive/find-changed-workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ def read_workflows(wfile):
data = {}
wf = ""
for line in fin.readlines():
m = re.match("^([^[]+)\[(\d+)]:\s+(.+)", line)
m = re.match(r"^([^[]+)\[(\d+)]:\s+(.+)", line)
if m:
cmd = re.sub("\s\s+", " ", m.group(3).strip())
cmd = re.sub(r"\s\s+", " ", m.group(3).strip())
if m.group(1).strip():
wf = m.group(1).strip().split(" ", 1)[0]
data[wf] = []
Expand Down
2 changes: 1 addition & 1 deletion archive/generate-performance-summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def sendMetrics(metrics, server, port):
def calculateFileSizeMetrics(release, architecture, timestamp, fullRelease, args):
timestamp = time.mktime(timestamp)
cmd = format(
"find %(base)s/vol*/%(architecture)s/cms/cmssw*/%(fullRelease)s/lib/%(architecture)s -name '*.so' -exec wc -c {} \; | sed -e 's|/.*/||;s|[.]so||'",
r"find %(base)s/vol*/%(architecture)s/cms/cmssw*/%(fullRelease)s/lib/%(architecture)s -name '*.so' -exec wc -c {} \; | sed -e 's|/.*/||;s|[.]so||'",
base=IB_BASE_DIR,
releasePath=releasePath,
fullRelease=fullRelease,
Expand Down
6 changes: 3 additions & 3 deletions archive/getWorkflowStatsFromES.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def filterElasticSearchResult(ES_result=None, list_of_fields=None):

for element in ES_result:
source_object = element["_source"]
if source_object["exit_code"] is not 0:
if source_object["exit_code"] != 0:
continue

stamp = source_object["@timestamp"]
Expand Down Expand Up @@ -107,7 +107,7 @@ def compareMetrics(firstObject=None, secondObject=None, workflow=None, stepnum=N
second_metric = secondObject[stamp][wf][step][field]

if field.startswith("rss"):
if second_metric is 0:
if second_metric == 0:
continue # sometimes the result is zero even when the exit_code is non 0
# difference = 100 - ( float( float(first_metric) / float(second_metric) ) * 100 )
difference = int((first_metric - second_metric) / 1048576)
Expand Down Expand Up @@ -159,7 +159,7 @@ def compareMetrics(firstObject=None, secondObject=None, workflow=None, stepnum=N
if hist.startswith("rss"):
histo.GetXaxis().SetTitle("Difference in MB")
# print 'title set for', hist
if hist is "time":
if hist == "time":
histo.GetXaxis().SetTitle("Difference in seconds")
if hist.startswith("cpu"):
histo.GetXaxis().SetTitle("Difference in cpu time")
Expand Down
2 changes: 1 addition & 1 deletion archive/github_get_file_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def get_changed_filenames_by_pr(old_prs_dict, pr_list):

def get_git_mt(path, filename):
status, rez = run_cmd('cd %s; git log -1 --format="%%ad" --date=unix -- %s' % (path, filename))
if status is not 0:
if status != 0:
print("ERROR, " + rez)
sys.exit(1) # todo throws an exception
return rez
Expand Down
4 changes: 2 additions & 2 deletions archive/ib-pr-workflow-changed.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ def parse_workflows(workflow_file):
steps = 0
for line in out.split("\n"):
line = line.strip()
m = re.match("^.*\[(\d+)] *: *(.+)$", line)
m = re.match(r"^.*\[(\d+)] *: *(.+)$", line)
if not m:
continue
step = m.group(1)
cmd = m.group(2).strip()
prefix, rest = line.split(":", 1)
items = prefix.split(" ")
if re.match("^\d+(\.\d+|)$", items[0]):
if re.match(r"^\d+(\.\d+|)$", items[0]):
wf = items[0]
if not wf in wfs:
wfs[wf] = {}
Expand Down
92 changes: 56 additions & 36 deletions buildLogAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,121 +441,135 @@ def analyzeFile(self, fileNameIn):
{str("^.*? cannot find -l(.*?)$"): ["linkError", 'missing library "%s"']},
{
str(
"^gmake: \*\*\* .*?/src/"
"^gmake: \\*\\*\\* .*?/src/"
+ subsys
+ "/"
+ pkg
+ "/src/"
+ subsys
+ pkg
+ "/classes_rflx\.cpp"
+ "/classes_rflx\\.cpp"
): ["dictError", "for package dictionary"]
},
{
str(
"^gmake: \*\*\* .*?/src/"
"^gmake: \\*\\*\\* .*?/src/"
+ subsys
+ "/"
+ pkg
+ "/src/"
+ subsys
+ pkg
+ "/.*?\."
+ "/.*?\\."
+ shLib
): ["linkError", "for package library"]
},
{
str(
"^gmake: \*\*\* .*?/src/"
"^gmake: \\*\\*\\* .*?/src/"
+ subsys
+ "/"
+ pkg
+ "/src/"
+ subsys
+ pkg
+ "/.*?\.o"
+ "/.*?\\.o"
): ["compError", "for package library"]
},
{
str("^gmake: \*\*\* .*?/src/" + subsys + "/" + pkg + "/bin/(.*?)/.*?\.o"): [
str("^gmake: \\*\\*\\* .*?/src/" + subsys + "/" + pkg + "/bin/(.*?)/.*?\\.o"): [
"compError",
"for executable %s",
]
},
{
str("^gmake: \*\*\* .*?/src/" + subsys + "/" + pkg + "/bin/(.*?)/\1"): [
str("^gmake: \\*\\*\\* .*?/src/" + subsys + "/" + pkg + "/bin/(.*?)/\1"): [
"linkError",
"for executable %s",
]
},
{
str(
"^gmake: \*\*\* .*?/src/" + subsys + "/" + pkg + "/bin/(.*?)/lib\1\." + shLib
"^gmake: \\*\\*\\* .*?/src/"
+ subsys
+ "/"
+ pkg
+ "/bin/(.*?)/lib\1\\."
+ shLib
): ["linkError", "for shared library %s in bin"]
},
{
str(
"^gmake: \*\*\* .*?/src/"
"^gmake: \\*\\*\\* .*?/src/"
+ subsys
+ "/"
+ pkg
+ "/test/stubs/lib(.*?)\."
+ "/test/stubs/lib(.*?)\\."
+ shLib
): ["linkError", "for shared library %s in test/stubs"]
},
{
str(
"^gmake: \*\*\* .*?/src/" + subsys + "/" + pkg + "/test/(.*?)/.*?\." + shLib
"^gmake: \\*\\*\\* .*?/src/"
+ subsys
+ "/"
+ pkg
+ "/test/(.*?)/.*?\\."
+ shLib
): ["linkError", "for shared library %s in test"]
},
{
str("^gmake: \*\*\* .*?/src/" + subsys + "/" + pkg + "/test/stubs/.*?\.o"): [
str("^gmake: \\*\\*\\* .*?/src/" + subsys + "/" + pkg + "/test/stubs/.*?\\.o"): [
"compError",
"for library in test/stubs",
]
},
{
str("^gmake: \*\*\* .*?/src/" + subsys + "/" + pkg + "/test/(.*?)/.*?\.o"): [
str("^gmake: \\*\\*\\* .*?/src/" + subsys + "/" + pkg + "/test/(.*?)/.*?\\.o"): [
"compError",
"for executable %s in test",
]
},
{
str("^gmake: \*\*\* .*?/src/" + subsys + "/" + pkg + "/test/(.*?)\." + shLib): [
str(
"^gmake: \\*\\*\\* .*?/src/" + subsys + "/" + pkg + "/test/(.*?)\\." + shLib
): [
"linkError",
"for shared library %s in test",
]
},
{
str("^gmake: \*\*\* .*?/src/" + subsys + "/" + pkg + "/test/(.*?)\.o"): [
str("^gmake: \\*\\*\\* .*?/src/" + subsys + "/" + pkg + "/test/(.*?)\\.o"): [
"compError",
"for executable %s in test",
]
},
{
str("^gmake: \*\*\* .*?/src/" + subsys + "/" + pkg + "/test/(.*?)/\1"): [
str("^gmake: \\*\\*\\* .*?/src/" + subsys + "/" + pkg + "/test/(.*?)/\1"): [
"linkError",
"for executable %s in test",
]
},
{
str("^gmake: \*\*\* .*?/src/" + subsys + "/" + pkg + "/plugins/(.*?)/.*?\.o"): [
str(
"^gmake: \\*\\*\\* .*?/src/" + subsys + "/" + pkg + "/plugins/(.*?)/.*?\\.o"
): [
"compError",
"for plugin %s in plugins",
]
},
{
str(
"^gmake: \*\*\* .*?/src/"
"^gmake: \\*\\*\\* .*?/src/"
+ subsys
+ "/"
+ pkg
+ "/plugins/(.*?)/lib.*?\."
+ "/plugins/(.*?)/lib.*?\\."
+ shLib
): ["linkError", "for plugin library %s in plugins"]
},
{
str("^ *\*\*\* Break \*\*\* illegal instruction"): [
str("^ *\\*\\*\\* Break \\*\\*\\* illegal instruction"): [
"compError",
"Break illegal instruction",
]
Expand All @@ -567,7 +581,9 @@ def analyzeFile(self, fileNameIn):
{str("^TypeError: .*"): ["pythonError", "type error in module"]},
{str("^ValueError: .*"): ["pythonError", "value error in module"]},
{
str("^gmake: \*\*\* .*?/src/" + subsys + "/" + pkg + "/test/data/download\.url"): [
str(
"^gmake: \\*\\*\\* .*?/src/" + subsys + "/" + pkg + "/test/data/download\\.url"
): [
"dwnlError",
"for file in data/download.url in test",
]
Expand All @@ -580,18 +596,20 @@ def analyzeFile(self, fileNameIn):
+ subsys
+ "/"
+ pkg
+ ".*?\:\d*\: warning: "
+ ".*?\\:\\d*\\: warning: "
): ["compWarning", "for file in package"]
},
{
str("^ *(/.*?/" + self.release + "/|)src/.*?\:\d+\: warning: "): [
str("^ *(/.*?/" + self.release + "/|)src/.*?\\:\\d+\\: warning: "): [
"compWarning",
"for file in release",
]
},
{
str(
"^ *(/.*?/" + self.release + "/|)src/.*?\([0-9]+\)\: warning #[0-9]+-[A-Z]: "
"^ *(/.*?/"
+ self.release
+ "/|)src/.*?\\([0-9]+\\)\\: warning #[0-9]+-[A-Z]: "
): [
"compWarning",
"for file in release",
Expand All @@ -606,25 +624,25 @@ def analyzeFile(self, fileNameIn):
+ subsys
+ "/"
+ pkg
+ ".*?\:\d+\: error: "
+ ".*?\\:\\d+\\: error: "
): ["compError", "for file in package"]
},
{
str("^ *(/.*?/" + self.release + "/|)src/.*?\:\d+\: error: "): [
str("^ *(/.*?/" + self.release + "/|)src/.*?\\:\\d+\\: error: "): [
"compError",
"for file in release",
]
},
{str("^.*?\:\d+\: error: "): ["compError", "for file in externals"]},
{str("^.*?\\:\\d+\\: error: "): ["compError", "for file in externals"]},
{
str(
"^ *tmp/.*?/src/"
+ subsys
+ "/"
+ pkg
+ "/src/(.*?)/lib.*?\."
+ "/src/(.*?)/lib.*?\\."
+ shLib
+ "\: undefined reference to .*"
+ "\\: undefined reference to .*"
): ["linkError", "for package library %s "]
},
{
Expand All @@ -633,9 +651,9 @@ def analyzeFile(self, fileNameIn):
+ subsys
+ "/"
+ pkg
+ "/plugins/(.*?)/lib.*?\."
+ "/plugins/(.*?)/lib.*?\\."
+ shLib
+ "\: undefined reference to .*"
+ "\\: undefined reference to .*"
): ["linkError", "for plugin library %s in plugins"]
},
{
Expand All @@ -652,16 +670,18 @@ def analyzeFile(self, fileNameIn):
},
]

miscErrRe = re.compile("^gmake: \*\*\* (.*)$")
genericLinkErrRe = re.compile("^gmake: \*\*\* \[tmp/.*?/lib.*?" + shLib + "\] Error 1")
miscErrRe = re.compile("^gmake: \\*\\*\\* (.*)$")
genericLinkErrRe = re.compile(
"^gmake: \\*\\*\\* \\[tmp/.*?/lib.*?" + shLib + "\\] Error 1"
)

if "_gcc46" in os.environ["SCRAM_ARCH"]:
errorInf.append(
{str("^.*?:\d+\: warning\: "): ["compWarning", "from external in package"]}
{str("^.*?:\\d+\\: warning\\: "): ["compWarning", "from external in package"]}
)
else:
errorInf.append(
{str("^.*?:\d+\: warning\: "): ["ignoreWarning", "from external in package"]}
{str("^.*?:\\d+\\: warning\\: "): ["ignoreWarning", "from external in package"]}
)
errorInf.append(
{str("^.*?ERROR:Private Header:"): ["compError", "Private header usage."]}
Expand Down
2 changes: 1 addition & 1 deletion cache-pull-request.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def process(repo, prId, prCache):
else:
data["merge_commit_sha"] = ""
data["release-notes"] = []
REGEX_RN = re.compile("^release(-| )note(s|)\s*:\s*", re.I)
REGEX_RN = re.compile(r"^release(-| )note(s|)\s*:\s*", re.I)
if issue.body:
msg = issue.body.encode("ascii", "ignore").decode().strip()
if REGEX_RN.match(msg):
Expand Down
4 changes: 2 additions & 2 deletions cms_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
VALID_CMSDIST_BRANCHES = "^IB/CMSSW_.+$"
BACKPORT_STR = "- Backported from #"
CMSBUILD_GH_USER = "cmsbuild"
CMSBOT_IGNORE_MSG = "<cmsbot>\s*</cmsbot>"
CMSBOT_NO_NOTIFY_MSG = "<notify>\s*</notify>"
CMSBOT_IGNORE_MSG = "<cmsbot>\\s*</cmsbot>"
CMSBOT_NO_NOTIFY_MSG = "<notify>\\s*</notify>"
CMSBOT_TECHNICAL_MSG = "cms-bot internal usage"
VALID_CMS_SW_REPOS_FOR_TESTS = [
"cmssw",
Expand Down
Loading

0 comments on commit f6042bc

Please sign in to comment.