Fix SLURM sinfo command parser

This commit is contained in:
Benoît Seignovert 2024-02-20 18:08:46 +01:00
parent e3fda2c317
commit a038d46231
Signed by: Benoît Seignovert
GPG key ID: F5D8895227D18A0B
2 changed files with 3 additions and 4 deletions

View file

@ -140,9 +140,9 @@ def sinfo_run(username: str = None) -> str:
cmd = f'sinfo {flags} --Format={fmt}'
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:

View file

@ -109,13 +109,12 @@ def test_slurm_sinfo_run(monkeypatch):
)
assert sinfo_run(username='john-doe') == (
'su - john-doe -c "'
'su - john-doe -c '
'sinfo '
'--federation '
'--noheader '
'--responding '
'--Format=Cluster,PartitionName,NodeHost,StateLong,CPUsState,Memory,Gres'
'"'
)