From 744e15532b0386c94f8ea00d715bfa693a652083 Mon Sep 17 00:00:00 2001 From: zaihuaji Date: Wed, 17 Sep 2025 12:52:48 -0500 Subject: [PATCH 1/2] dump trace into error log files only --- pyproject.toml | 2 +- src/rda_python_common/PgFile.py | 20 +++++++++++--------- src/rda_python_common/PgLOG.py | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 019889e..b6b5777 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "rda_python_common" -version = "1.0.44" +version = "1.0.45" authors = [ { name="Zaihua Ji", email="zji@ucar.edu" }, ] diff --git a/src/rda_python_common/PgFile.py b/src/rda_python_common/PgFile.py index 204c834..6c82cc3 100644 --- a/src/rda_python_common/PgFile.py +++ b/src/rda_python_common/PgFile.py @@ -1664,7 +1664,7 @@ def local_file_stat(file, fstat, opt, logact): if opt&8: info['gid'] = fstat.st_gid info['group'] = grp.getgrgid(info['gid']).gr_name - if opt&32: info['checksum'] = get_md5sum(file, 0, logact) + if opt&32 and info['isfile']: info['checksum'] = get_md5sum(file, 0, logact) return info @@ -2305,16 +2305,18 @@ def get_md5sum(file, count = 0, logact = 0): if count > 0: checksum = [None]*count for i in range(count): - chksm = PgLOG.pgsystem(cmd + file[i], logact, 20) - if chksm: - ms = re.search(r'(\w{32})', chksm) - if ms: checksum[i] = ms.group(1) + if(op.isfile(file[i])): + chksm = PgLOG.pgsystem(cmd + file[i], logact, 20) + if chksm: + ms = re.search(r'(\w{32})', chksm) + if ms: checksum[i] = ms.group(1) else: - chksm = PgLOG.pgsystem(cmd + file, logact, 20) checksum = None - if chksm: - ms = re.search(r'(\w{32})', chksm) - if ms: checksum = ms.group(1) + if op.isfile(file): + chksm = PgLOG.pgsystem(cmd + file, logact, 20) + if chksm: + ms = re.search(r'(\w{32})', chksm) + if ms: checksum = ms.group(1) return checksum diff --git a/src/rda_python_common/PgLOG.py b/src/rda_python_common/PgLOG.py index b7756e0..d48fe46 100644 --- a/src/rda_python_common/PgLOG.py +++ b/src/rda_python_common/PgLOG.py @@ -474,7 +474,7 @@ def write_message(msg, file, logact): if logact&BRKLIN: OUT.write("\n") if logact&SEPLIN: OUT.write(PGLOG['SEPLINE']) OUT.write(msg) - if errlog and not logact&(EMLALL|SKPTRC): OUT.write(get_call_trace()) + if errlog and file and not logact&(EMLALL|SKPTRC): OUT.write(get_call_trace()) if doclose: OUT.close() # From beb82c4fe97ccd47cbed4c8a0268029ec74f73a2 Mon Sep 17 00:00:00 2001 From: zaihuaji Date: Wed, 17 Sep 2025 12:54:49 -0500 Subject: [PATCH 2/2] check ifile before get checksum --- src/rda_python_common/PgFile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rda_python_common/PgFile.py b/src/rda_python_common/PgFile.py index 6c82cc3..2e2eee1 100644 --- a/src/rda_python_common/PgFile.py +++ b/src/rda_python_common/PgFile.py @@ -2305,7 +2305,7 @@ def get_md5sum(file, count = 0, logact = 0): if count > 0: checksum = [None]*count for i in range(count): - if(op.isfile(file[i])): + if op.isfile(file[i]): chksm = PgLOG.pgsystem(cmd + file[i], logact, 20) if chksm: ms = re.search(r'(\w{32})', chksm)