Skip to content
Snippets Groups Projects
Commit 6d59ac9e authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

Merge branch 'bf/fslsub' into 'master'

Bf/fslsub

See merge request fsl/fslpy!207
parents 54d0e61d d9de5b15
No related branches found
No related tags found
No related merge requests found
Pipeline #5115 passed
......@@ -55,6 +55,7 @@ Fixed
* Updated the :func:`.prepareArgs` function to use ``shlex.split`` when
preparing shell command arguments, instead of performing a naive whitespace
split.
* Fixed some bugs in the :func:`.fslsub.info` function.
2.8.4 (Monday 2nd March 2020)
......
......@@ -40,8 +40,7 @@ Example usage, building a short pipeline::
"""
from six import string_types, BytesIO
import subprocess as sp
from six import BytesIO
import os.path as op
import glob
import time
......@@ -149,8 +148,9 @@ def info(job_id):
:return: dictionary with information on the submitted job (empty
if job does not exist)
"""
from fsl.utils.run import run
try:
result = sp.call(['qstat', '-j', job_id]).decode('utf-8')
result = run(['qstat', '-j', job_id])
except FileNotFoundError:
log.debug("qstat not found; assuming not on cluster")
return {}
......@@ -158,7 +158,7 @@ def info(job_id):
return {}
res = {}
for line in result.splitlines()[1:]:
key, value = line.split(':', nsplit=1)
key, value = line.split(':', 1)
res[key.strip()] = value.strip()
return res
......
......@@ -102,6 +102,29 @@ def test_submit():
assert stderr.strip() == 'standard error'
def test_info():
mock_qstat = tw.dedent("""
#!/usr/bin/env bash
echo "#####################"
echo "job_number: 1 "
echo "exec_file: 2 "
echo "submission_time: 3 "
echo "owner: 4 "
""").strip()
with mockFSLDIR() as fsldir:
qstatbin = op.join(fsldir, 'bin', 'qstat')
with open(qstatbin, 'wt') as f:
f.write(mock_qstat)
os.chmod(qstatbin, 0o755)
exp = {'job_number' : '1',
'exec_file' : '2',
'submission_time' : '3',
'owner' : '4'}
assert fslsub.info('12345') == exp
def myfunc():
print('standard output')
print('standard error', file=sys.stderr)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment