Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F60174352
updateRuns.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
Sun, Apr 28, 01:52
Size
1 KB
Mime Type
text/x-python
Expires
Tue, Apr 30, 01:52 (2 d)
Engine
blob
Format
Raw Data
Handle
17312727
Attached To
R3127 blackdynamite
updateRuns.py
View Options
#!/usr/bin/env python3
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import
BlackDynamite
as
BD
import
os
import
sys
import
socket
parser
=
BD
.
BDParser
()
parser
.
register_params
(
group
=
"updateRuns"
,
params
=
{
"run_id"
:
int
,
"updates"
:
[
str
]},
defaults
=
{
"machine_name"
:
socket
.
gethostname
()},
help
=
{
"run_id"
:
"The id of the run to update"
,
"updates"
:
"The updates to perform. Syntax should be 'key = newval'"
}
)
params
=
parser
.
parseBDParameters
()
if
"user"
not
in
params
.
keys
():
params
[
"user"
]
=
os
.
getlogin
()
base
=
BD
.
Base
(
**
params
)
if
"run_id"
in
params
:
if
"constraints"
not
in
params
:
params
[
"constraints"
]
=
[]
params
[
"constraints"
]
.
append
(
"runs.id = "
+
str
(
params
[
"run_id"
]))
runSelector
=
BD
.
RunSelector
(
base
)
run_list
=
runSelector
.
selectRuns
(
params
)
if
len
(
run_list
)
==
0
:
print
(
"No runs to be updated"
)
if
"updates"
not
in
params
:
print
(
"No update to be performed: use --updates option"
)
sys
.
exit
(
-
1
)
for
r
,
j
in
run_list
:
r
.
setFields
(
params
[
"updates"
])
if
params
[
"truerun"
]
is
True
:
r
.
update
()
base
.
commit
()
Event Timeline
Log In to Comment