From 25ab15d8d63cc73b56b92d4abe6bd19a66402730 Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Mon, 2 Mar 2026 12:09:27 +0800 Subject: [PATCH] Fix invalid escape sequences in Python files Fix SyntaxWarning caused by invalid escape sequences in mainUtils.py and logfilter.py. These warnings appear on Python 3.12+ (e.g., Ubuntu 24.04) and will become SyntaxError in Python 3.14. Changes: - mainUtils.py: Use raw strings for shell commands containing '\$' - logfilter.py: Use raw docstrings for functions containing regex examples See: https://github.com/apache/cloudberry/issues/1587 --- gpMgmt/bin/gppylib/logfilter.py | 4 ++-- gpMgmt/bin/gppylib/mainUtils.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gpMgmt/bin/gppylib/logfilter.py b/gpMgmt/bin/gppylib/logfilter.py index c427ac1a6cb..46c0b5e174a 100644 --- a/gpMgmt/bin/gppylib/logfilter.py +++ b/gpMgmt/bin/gppylib/logfilter.py @@ -67,7 +67,7 @@ def FilterLogEntries(iterable, filters=[], ibegin=0, jend=None): - """ + r""" Generator to consume the lines of a GPDB log file from iterable, yield the lines which satisfy the given criteria, and skip the rest. @@ -668,7 +668,7 @@ def MatchInFirstLine(iterable, regex): def NoMatchInFirstLine(iterable, regex): - """ + r""" Generator to filter a stream of groups. Skips those groups whose first line contains a match for the given regex; yields all other groups. diff --git a/gpMgmt/bin/gppylib/mainUtils.py b/gpMgmt/bin/gppylib/mainUtils.py index 553ca9d57c9..e947639591d 100644 --- a/gpMgmt/bin/gppylib/mainUtils.py +++ b/gpMgmt/bin/gppylib/mainUtils.py @@ -488,7 +488,7 @@ def parseStatusLine(line, isStart = False, isStop = False): def check_fts(fts): - fts_check_cmd= "ps -ef | awk '{print \$2, \$8}' | grep gpfts | grep -v grep" + fts_check_cmd= r"ps -ef | awk '{print \$2, \$8}' | grep gpfts | grep -v grep" process_cmd = "gpssh -h %s -e \"%s\" | wc -l" % (fts, fts_check_cmd) fts_process_res=int(subprocess.check_output(process_cmd, shell=True).decode().strip()) return fts_process_res == 2 @@ -500,7 +500,7 @@ def check_etcd(etcd): if etcd_process_res == 2: return True # for demo cluster - etcd_check_cmd = "ps -ef | awk '{print \$2, \$8}' | grep etcd | grep -v grep" + etcd_check_cmd = r"ps -ef | awk '{print \$2, \$8}' | grep etcd | grep -v grep" process_cmd = "gpssh -h %s -e \"%s\"| wc -l" % (etcd, etcd_check_cmd) etcd_process_res = int(subprocess.check_output(process_cmd, shell=True).decode().strip()) return etcd_process_res == 2