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..2e2eee1 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() #