From d0851032e5ecba86cd2cd4d2b87b23a2f06160a0 Mon Sep 17 00:00:00 2001 From: Dimitris Papagiannis Date: Tue, 25 Jun 2024 17:56:33 +0200 Subject: [PATCH 1/4] Remove unnecessary print --- src/python/DQM/GUI.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/python/DQM/GUI.py b/src/python/DQM/GUI.py index c608d88..644339a 100644 --- a/src/python/DQM/GUI.py +++ b/src/python/DQM/GUI.py @@ -643,7 +643,6 @@ def plot(self, *junk, **options): labels[i], ) ) - print(final, options) assert len(labels) == len(objs) a = self._plot(final, options) return (a[0], bytes(a[1])) From 8d86aa9dc756822493a169bbbabd3cd43ab866e9 Mon Sep 17 00:00:00 2001 From: Dimitris Papagiannis Date: Tue, 25 Jun 2024 17:56:40 +0200 Subject: [PATCH 2/4] Fixes for python3 --- src/python/Core/Plot.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/python/Core/Plot.py b/src/python/Core/Plot.py index 96a0c92..720ccf4 100644 --- a/src/python/Core/Plot.py +++ b/src/python/Core/Plot.py @@ -979,7 +979,7 @@ def jsonmap(self): { "coords": [ self._map[name][2 * i : (2 * i) + 1] - for i in range(len(self._map[name]) / 2) + for i in range(int(len(self._map[name]) / 2)) ], "title": name, "value": value, @@ -1015,7 +1015,7 @@ def __init__(self, span, series, data, legend, props): self._axisFormat = "%Y" spanFormat = "%Y" else: - raise "Bad time series span" + raise Exception("Bad time series span") self.title = "%s\n%d %ss from %s to %s UTC" % ( self.get("title", ""), @@ -1105,7 +1105,7 @@ def draw(self): p = map_patches[k] maparea = [] - def reduce_verts(verts): + def reduce_verts(verts: list) -> list: if len(verts) >= 4: if not ( verts[0][0] == verts[-1][0] and verts[0][1] == verts[-1][1] @@ -1124,7 +1124,7 @@ def reduce_verts(verts): # There is only ever a single patch here # verts = reduce_verts(p.get_transform().transform(p.get_verts())) verts = reduce_verts(p.get_transform().transform(p.get_paths()[0].vertices)) - if len(verts) > 0: + if verts and len(verts) > 0: for v in verts: maparea.extend((v[0], float(self.get("height")) - v[1])) self._map[k] = maparea @@ -1190,7 +1190,7 @@ def jsonmap(self): { "coords": [ self._map[name][2 * i : (2 * i) + 1] - for i in range(len(self._map[name]) / 2) + for i in range(int(len(self._map[name]) / 2)) ], "title": name, "value": value, @@ -1228,7 +1228,7 @@ def __init__(self, span, series, data, legend, props): self._axisFormat = "%Y" spanFormat = "%Y" else: - raise "Bad time series span" + raise Exception("Bad time series span") self.title = "%s\n%d %ss from %s to %s UTC" % ( self.get("title", ""), From bf509c4e2def9e2314395e2b349209e3ff874274 Mon Sep 17 00:00:00 2001 From: Dimitris Papagiannis Date: Wed, 26 Jun 2024 15:58:06 +0200 Subject: [PATCH 3/4] Fix for python3 --- bin/visDQMIndexCastorStager | 19 ++++++++++--------- bin/visDQMZipCastorVerifier | 9 ++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bin/visDQMIndexCastorStager b/bin/visDQMIndexCastorStager index 5c2db09..3bcd7c9 100755 --- a/bin/visDQMIndexCastorStager +++ b/bin/visDQMIndexCastorStager @@ -293,15 +293,16 @@ def executeCommand(command): # Alert email addresses given as parameter about a failure of the process. def alertBySendingEmail(errorText): process = Popen("/usr/sbin/sendmail -t", shell=True, stdin=PIPE) - # TODO: encode() the strings for python3, when Offline GUI upgrades - process.stdin.write("To: %s\n" % args.EMAIL) - process.stdin.write("Subject: Problem sending DQM GUI index backup to EOS\n") - process.stdin.write("\n") # blank line separating headers from body - process.stdin.write("Problem sending DQM GUI index backup to EOS\n") - process.stdin.write("Hostname: %s\n" % gethostname()) - process.stdin.write("Index: %s\n" % args.INDEX) - process.stdin.write("%s\n" % errorText) - process.stdin.write("Please check logs!\n") + process.stdin.write(f"To: {args.EMAIL}\n".encode()) + process.stdin.write( + "Subject: Problem sending DQM GUI index backup to EOS\n".encode() + ) + process.stdin.write("\n".encode()) # blank line separating headers from body + process.stdin.write("Problem sending DQM GUI index backup to EOS\n".encode()) + process.stdin.write(f"Hostname: {gethostname()}\n".encode()) + process.stdin.write(f"Index: {args.INDEX}\n".encode()) + process.stdin.write(f"{errorText}\n".encode()) + process.stdin.write("Please check logs!\n".encode()) process.stdin.close() returncode = process.wait() if returncode != 0: diff --git a/bin/visDQMZipCastorVerifier b/bin/visDQMZipCastorVerifier index 64cddb0..93c4717 100755 --- a/bin/visDQMZipCastorVerifier +++ b/bin/visDQMZipCastorVerifier @@ -57,12 +57,11 @@ def runme(cmd, *args, **keys): def sendmail(body="Hello from visDQMZipCastorVerifier"): - # TODO: encode() when Offline DQMGUI updates to python3 scall = Popen("%s -t" % SENDMAIL, shell=True, stdin=PIPE) - scall.stdin.write("To: %s\n" % EMAIL) - scall.stdin.write("Subject: Problem verifying file transfer to EOS\n") - scall.stdin.write("\n") # blank line separating headers from body - scall.stdin.write("%s\n" % body) + scall.stdin.write(f"To: {EMAIL}\n".encode()) + scall.stdin.write("Subject: Problem verifying file transfer to EOS\n".encode()) + scall.stdin.write("\n".encode()) # blank line separating headers from body + scall.stdin.write(f"{body}\n".encode()) scall.stdin.close() rc = scall.wait() if rc != 0: From f06d40ca35277ff097e2753b8f45102e2343c701 Mon Sep 17 00:00:00 2001 From: Dimitris Papagiannis Date: Thu, 27 Jun 2024 09:34:04 +0200 Subject: [PATCH 4/4] Make Index monitor message a bit more clear --- bin/visDQMIndexMonitoring | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/visDQMIndexMonitoring b/bin/visDQMIndexMonitoring index 2b5f4ca..69825f5 100755 --- a/bin/visDQMIndexMonitoring +++ b/bin/visDQMIndexMonitoring @@ -46,15 +46,16 @@ check_index_limits_and_send_email() { tree_current_size=$(grep "${_tree_types[$i]}" "${TMP_CATALOGUE_FILE}_${FLAVOR}" | wc -l) tree_limit=$(grep -oE "${_tree_types_limit_name[$i]}[[:space:]]+[0-9]+" "$visdqmindex_header_file" | awk '{print $2}') percent_full=$(bc -l <<<"($tree_current_size/$tree_limit)*100") - echo "Found $tree_current_size ${_tree_types[$i]} in the catalogue. Limit is $tree_limit ($(printf '%.2f' $percent_full)%)" + echo "Found $tree_current_size ${_tree_types[$i]} in the catalogue. Limit is $tree_limit ($(printf '%.2f' $percent_full)% full)" # Check if alarm threshold is exceeded threshold=$(printf '%.0f' $(bc <<<"$ALERT_THRESHOLD * $tree_limit")) if [ $tree_current_size -gt $threshold ]; then - msg=$(printf "%s" "${msg}There are $tree_current_size ${_tree_types[$i]} in the index, which is above the $threshold threshold!\n") + msg=$(printf "%s" "${msg}WARNING: DQMGUI's index tree ${_tree_types[$i]} has $tree_current_size entries out of the maximum ${tree_limit} ($(printf '%.2f' $percent_full)% full))\n") fi done if [ -n "$msg" ]; then - printf "$msg" | mail -s "visDQMIndexMonitoring on $(hostname)" "$EMAIL_ADDRESS_TO_NOTIFY" + echo "Sending email to $EMAIL_ADDRESS_TO_NOTIFY" + printf "$msg" | mail -s "visDQMIndexMonitoring on $(hostname) (${FLAVOR})" "$EMAIL_ADDRESS_TO_NOTIFY" fi } @@ -105,3 +106,4 @@ for step in "${steps[@]}"; do echo "Skipping step: $step" fi done +echo "Done!"