DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
rename_session.py
Go to the documentation of this file.
1import conffwk
2import copy
3
4def rename_session(oksfile,output_name,session_name=None):
5 """Script to rename the session (first session if multiple and not specified)"""
6
7 db = conffwk.Configuration('oksconflibs:'+oksfile)
8
9 if session_name is not None:
10 try:
11 session = db.get_dal("Session",session_name)
12 except:
13 print(f"Error could not find Session {session_name} in file {oksfile}")
14 return
15 else:
16 sessions = db.get_dals("Session")
17 if len(sessions)==0:
18 print(f"Error in {oksfile}: no sessions found.")
19 return
20 if len(sessions)>1:
21 print(f"{oksfile} found {len(sessions)}. Will change name of first ({sessions[0].id})")
22 session = sessions[0]
23
24 new_session = copy.copy(session)
25 setattr(new_session,"id",output_name)
26
27 db.add_dal(new_session)
28 db.destroy_dal(session)
29
30 db.commit()