Page MenuHomec4science

updateRuns.py
No OneTemporary

File Metadata

Created
Mon, Nov 18, 09:48

updateRuns.py

#!/usr/bin/env python
import BlackDynamite as BD
import os, sys, stat
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 not "user" in params.keys():
params["user"] = os.getlogin()
base = BD.Base(**params)
if ("runid" in params):
if "run_constraints" not in params:
params["run_constraints"] = []
params["run_constraints"].append("id = " + str(params["runid"]))
runSelector = BD.RunSelector(base)
run_list = runSelector.selectRuns(params,params)
if (len(run_list) == 0):
print "No runs to be updated"
if (not "updates" 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"] == True):
r.update()
base.commit()

Event Timeline