Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
fslpy
Commits
29cbf562
Commit
29cbf562
authored
6 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
fslsub.output ignores command/name for the time being.
parent
bef8751a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/utils/fslsub.py
+13
-8
13 additions, 8 deletions
fsl/utils/fslsub.py
with
13 additions
and
8 deletions
fsl/utils/fslsub.py
+
13
−
8
View file @
29cbf562
...
...
@@ -42,6 +42,7 @@ Example usage, building a short pipeline::
from
six
import
string_types
,
BytesIO
import
subprocess
as
sp
import
os.path
as
op
import
glob
import
time
import
pickle
import
sys
...
...
@@ -155,22 +156,26 @@ def info(job_id):
return
res
def
output
(
job_id
,
c
ommand
,
cwd
=
'
.
'
,
name
=
None
):
def
output
(
job_id
,
c
wd
=
'
.
'
,
command
=
None
,
name
=
None
):
"""
Returns the output of the given job.
:arg job_id: String with job id
:arg command: Command that was run
:arg job_id: String containing job ID.
:arg cwd: Directory from which command was submitted - defaults to
the current directory.
:arg name: Job name if it was specified.
:arg command: Command that was run. Not currently used.
:arg name: Job name if it was specified. Not currently used.
:returns: A tuple containing the standard output and standard error.
"""
if
name
is
None
:
name
=
op
.
basename
(
command
)
stdout
=
list
(
glob
.
glob
(
op
.
join
(
cwd
,
'
*.o{}
'
.
format
(
job_id
))))
stderr
=
list
(
glob
.
glob
(
op
.
join
(
cwd
,
'
*.e{}
'
.
format
(
job_id
)))
)
stdout
=
op
.
join
(
cwd
,
'
{}.o{}
'
.
format
(
name
,
job_id
))
stderr
=
op
.
join
(
cwd
,
'
{}.e{}
'
.
format
(
name
,
job_id
))
if
len
(
stdout
)
!=
1
or
len
(
stderr
)
!=
1
:
raise
ValueError
(
'
No/too many error/output files for job {}: stdout:
'
'
{}, stderr: {}
'
.
format
(
job_id
,
stdout
,
stderr
))
stdout
=
stdout
[
0
]
stderr
=
stderr
[
0
]
if
op
.
exists
(
stdout
):
with
open
(
stdout
,
'
rt
'
)
as
f
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment