From 63f1356d7fd756c95582a271b05980d654c2bfad Mon Sep 17 00:00:00 2001 From: Thomas Cram Date: Fri, 3 Oct 2025 11:45:01 -0600 Subject: [PATCH 1/6] remove exclamation point from email subject --- src/rda_python_common/PgLOG.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rda_python_common/PgLOG.py b/src/rda_python_common/PgLOG.py index 574435f..54ce0e2 100644 --- a/src/rda_python_common/PgLOG.py +++ b/src/rda_python_common/PgLOG.py @@ -335,7 +335,7 @@ def send_python_email(subject = None, receiver = None, msg = None, sender = None emlmsg['Cc'] = cc logmsg += " Cc'd " + cc if not subject: subject = "Message from {}-{}".format(PGLOG['HOSTNAME'], get_command()) - if not re.search(r'!$', subject): subject += '!' + # if not re.search(r'!$', subject): subject += '!' emlmsg['Subject'] = subject if CPID['CPID']: logmsg += " in " + CPID['CPID'] logmsg += ", Subject: {}\n".format(subject) From 7ac9e63b9fd3266b6e3cc4bb9abc474e86846b32 Mon Sep 17 00:00:00 2001 From: Thomas Cram Date: Fri, 3 Oct 2025 11:48:17 -0600 Subject: [PATCH 2/6] increment version to 1.0.48 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index aa92fd1..e1b7895 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "rda_python_common" -version = "1.0.47" +version = "1.0.48" authors = [ { name="Zaihua Ji", email="zji@ucar.edu" }, ] From a3e170e9558c85be2ed539bf50a86458f4c812cd Mon Sep 17 00:00:00 2001 From: Thomas Cram Date: Wed, 8 Oct 2025 11:42:13 -0600 Subject: [PATCH 3/6] add unidecode to requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index f038d89..a1482d1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ pluggy==1.5.0 psycopg2-binary==2.9.10 pytest==8.3.5 rda-python-globus +unidecode From e7a35626b3760a13752b8816db47efbed17d2f42 Mon Sep 17 00:00:00 2001 From: Thomas Cram Date: Wed, 8 Oct 2025 12:03:02 -0600 Subject: [PATCH 4/6] refactor: improve character conversion to use unidecode for better ASCII representation --- src/rda_python_common/PgLOG.py | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/src/rda_python_common/PgLOG.py b/src/rda_python_common/PgLOG.py index 54ce0e2..d6f8c0d 100644 --- a/src/rda_python_common/PgLOG.py +++ b/src/rda_python_common/PgLOG.py @@ -28,6 +28,7 @@ import socket import shutil import traceback +from unidecode import unidecode # define some constants for logging actions MSGLOG = (0x00001) # logging message @@ -1579,33 +1580,18 @@ def check_process_host(hosts, chost = None, mflag = None, pinfo = None, logact = return ret # -# convert special characters +# convert special foreign characters into ascii characters # def convert_chars(name, default = 'X'): if not name: return default - if re.match(r'^[a-zA-Z0-9]+$', name): return name # no need convert - - z = ord('z') - newchrs = ochrs = '' - for i in range(len(name)): - ch = name[i] - if re.match(r'^[a-zA-Z0-9]$', ch): - newchrs += ch - elif (ch == ' ' or ch == '_') and newchrs: - newchrs += '_' - elif ord(ch) > z and ochrs != None: - if not ochrs: - ochrs = None - with open(PGLOG['DSSHOME'] + "/lib/ExtChrs.txt", "r") as CHR: - ochrs = CHR.readline() - nchrs = CHR.readline() - if ochrs is None: continue - idx = ochrs.find(ch) - if idx >= 0: newchrs += nchrs[idx] - - if newchrs: - return newchrs + if re.match(r'^[a-zA-Z0-9]+$', name): return name # conversion not needed + + decoded_name = unidecode(name).strip() + cleaned_name = re.sub(r'[^a-zA-Z0-9]', '', decoded_name) + + if cleaned_name: + return cleaned_name else: return default From 2ba2ee082c7d4bda8594f4dcaf0fbf60d82e5bc7 Mon Sep 17 00:00:00 2001 From: Thomas Cram Date: Wed, 8 Oct 2025 12:10:57 -0600 Subject: [PATCH 5/6] refactor: enhance character conversion to allow underscores in cleaned names --- src/rda_python_common/PgLOG.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/rda_python_common/PgLOG.py b/src/rda_python_common/PgLOG.py index d6f8c0d..c08b3e3 100644 --- a/src/rda_python_common/PgLOG.py +++ b/src/rda_python_common/PgLOG.py @@ -1583,13 +1583,11 @@ def check_process_host(hosts, chost = None, mflag = None, pinfo = None, logact = # convert special foreign characters into ascii characters # def convert_chars(name, default = 'X'): - if not name: return default if re.match(r'^[a-zA-Z0-9]+$', name): return name # conversion not needed - decoded_name = unidecode(name).strip() - cleaned_name = re.sub(r'[^a-zA-Z0-9]', '', decoded_name) - + # remove any non-alphanumeric and non-underscore characters + cleaned_name = re.sub(r'[^a-zA-Z0-9_]', '', decoded_name) if cleaned_name: return cleaned_name else: From 22890d3fb9aca58462e4e1c828aac03859577ab7 Mon Sep 17 00:00:00 2001 From: Thomas Cram Date: Wed, 8 Oct 2025 12:21:57 -0600 Subject: [PATCH 6/6] bump version to 1.0.49 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e1b7895..3fa0fe0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "rda_python_common" -version = "1.0.48" +version = "1.0.49" authors = [ { name="Zaihua Ji", email="zji@ucar.edu" }, ]