Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90864159
bashCoat.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Nov 5, 11:33
Size
1 KB
Mime Type
text/x-python
Expires
Thu, Nov 7, 11:33 (2 d)
Engine
blob
Format
Raw Data
Handle
22124841
Attached To
R3127 blackdynamite
bashCoat.py
View Options
#!/usr/bin/env python
import
run
import
os
,
stat
import
subprocess
import
re
import
socket
admissible_params
=
{
"stdout"
:
None
}
#default_params = {}
help
=
{
"stdout"
:
"Specify if you want the standard output instead of a file"
}
def
launch
(
run
,
params
):
_exec
=
run
.
getExecFile
()
head
=
\
"""#!/bin/bash
export BLACKDYNAMITE_HOST=__BLACKDYNAMITE__dbhost__
export BLACKDYNAMITE_SCHEMA=__BLACKDYNAMITE__study__
export BLACKDYNAMITE_RUN_ID=__BLACKDYNAMITE__run_id__
export BLACKDYNAMITE_USER=$USER
"""
_exec
[
"file"
]
=
run
.
replaceBlackDynamiteVariables
(
head
)
+
_exec
[
"file"
]
f
=
open
(
_exec
[
"filename"
],
'w'
)
f
.
write
(
_exec
[
"file"
])
f
.
close
()
os
.
chmod
(
_exec
[
"filename"
],
stat
.
S_IRWXU
)
print
(
"execute ./"
+
_exec
[
"filename"
])
if
(
params
[
"truerun"
]):
run
[
"state"
]
=
"launched"
run
.
update
()
run
.
commit
()
filename
=
run
[
"run_name"
]
+
".o"
+
str
(
run
.
id
)
filename_err
=
run
[
"run_name"
]
+
".e"
+
str
(
run
.
id
)
with
open
(
filename
,
"w"
)
as
outfile
:
with
open
(
filename_err
,
"w"
)
as
errfile
:
ret
=
subprocess
.
call
(
"./"
+
_exec
[
"filename"
],
stdout
=
outfile
,
stderr
=
errfile
)
Event Timeline
Log In to Comment