Fix SLURM sinfo command parser
This commit is contained in:
parent
e3fda2c317
commit
a038d46231
2 changed files with 3 additions and 4 deletions
|
@ -140,9 +140,9 @@ def sinfo_run(username: str = None) -> str:
|
||||||
cmd = f'sinfo {flags} --Format={fmt}'
|
cmd = f'sinfo {flags} --Format={fmt}'
|
||||||
|
|
||||||
if username:
|
if username:
|
||||||
cmd = f'su - {username} -c "{cmd}"'
|
cmd = f"su - {username} -c '{cmd}'"
|
||||||
|
|
||||||
return subprocess.check_output(shlex.split(cmd, posix=False)).decode('utf-8')
|
return subprocess.check_output(shlex.split(cmd)).decode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
def sinfo_reader(result: str) -> list:
|
def sinfo_reader(result: str) -> list:
|
||||||
|
|
|
@ -109,13 +109,12 @@ def test_slurm_sinfo_run(monkeypatch):
|
||||||
)
|
)
|
||||||
|
|
||||||
assert sinfo_run(username='john-doe') == (
|
assert sinfo_run(username='john-doe') == (
|
||||||
'su - john-doe -c "'
|
'su - john-doe -c '
|
||||||
'sinfo '
|
'sinfo '
|
||||||
'--federation '
|
'--federation '
|
||||||
'--noheader '
|
'--noheader '
|
||||||
'--responding '
|
'--responding '
|
||||||
'--Format=Cluster,PartitionName,NodeHost,StateLong,CPUsState,Memory,Gres'
|
'--Format=Cluster,PartitionName,NodeHost,StateLong,CPUsState,Memory,Gres'
|
||||||
'"'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue