Skip to content

Commit 4c81e99

Browse files
committed
Merge branch 'job_utf-8_fix' into 'main'
Fix issue in decoding PBS qstat information: 'utf-8' codec can't decode See merge request kejacob1/pbs4py!45
2 parents fb2ee64 + 98f0df5 commit 4c81e99

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pbs4py/job.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import time
22
import os
33
from typing import List, Union
4+
import subprocess
45

56

67
class PBSJob:
@@ -136,7 +137,13 @@ def _job_is_still_running_or_queued(self):
136137
return False
137138

138139
def _run_qstat_to_get_full_job_attributes(self) -> Union[List[str], str]:
139-
return os.popen(f"qstat -xf {self.id}").read().split("\n")
140+
result = subprocess.run(
141+
["qstat", "-xf", str(self.id)],
142+
stdout=subprocess.PIPE,
143+
stderr=subprocess.PIPE,
144+
text=False, # Disable automatic decoding
145+
)
146+
return result.stdout.decode("utf-8", errors="replace").split("\n")
140147

141148
def _is_a_known_job(self, qstat_output):
142149
return not "Unknown Job Id" in qstat_output

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444

4545
__package_name__ = "pbs4py"
46-
__package_version__ = "1.0.7"
46+
__package_version__ = "1.0.8"
4747

4848
root = os.path.abspath(os.path.dirname(__file__))
4949
with open(os.path.join(root, "README.md"), encoding="utf-8") as f:

0 commit comments

Comments
 (0)