DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
daqconf
python
daqconf
session.py
Go to the documentation of this file.
1
import
conffwk
2
3
def
get_segment_apps
(segment: object) -> list[object]:
4
"""
5
Gather the list of applications in the segment and its sub-segments
6
"""
7
apps = []
8
9
for
ss
in
segment.segments:
10
apps +=
get_segment_apps
(ss)
11
12
for
aa
in
segment.applications:
13
apps.append(aa)
14
15
apps.append(segment.controller)
16
17
return
apps
18
19
20
def
get_session_apps
(confdb: conffwk.Configuration, session_name: str =
""
) -> list[object] |
None
:
21
"""
22
Gather the apps defined used in a session.
23
"""
24
if
session_name ==
""
:
25
session_dals = confdb.get_dals(class_name=
"Session"
)
26
if
len(session_dals) == 0:
27
print(f
"Error could not find any Session in file {confdb.databases}"
)
28
return
29
session = session_dals[0]
30
else
:
31
try
:
32
session = confdb.get_dal(
"Session"
, session_name)
33
except
:
34
print(f
"Error could not find Session {session_name} in file {confdb.databases}"
)
35
return
36
37
segment = session.segment
38
39
return
get_segment_apps
(segment)
40
41
42
def
get_apps_in_any_session
(confdb: conffwk.Configuration) -> dict[str, list[object]]:
43
"""
44
Gather the applications used in any session present in the database
45
"""
46
47
output = {}
48
session_dals = confdb.get_dals(class_name=
"Session"
)
49
if
len(session_dals) == 0:
50
print(f
"Error could not find any Session in file {confdb.databases}"
)
51
return
{}
52
53
for
session
in
session_dals:
54
segment = session.segment
55
output[session.id] =
get_segment_apps
(segment)
56
57
return
output
58
59
60
def
enable_resource_in_session
(
61
db: conffwk.Configuration,
62
session_name: str,
63
resource: list[str],
64
disable: bool,
65
) ->
None
:
66
"""Script to enable or disable (-d) Resources from the first Session of the
67
specified OKS database file"""
68
if
session_name ==
""
:
69
session_dals = db.get_dals(class_name=
"Session"
)
70
if
len(session_dals) == 0:
71
print(f
"Error could not find any Session in file {db.databases}"
)
72
return
73
session = session_dals[0]
74
else
:
75
try
:
76
session = db.get_dal(
"Session"
, session_name)
77
except
:
78
print(f
"Error could not find Session {session_name} in file {db.databases}"
)
79
return
80
81
disabled = session.disabled
82
for
res
in
resource:
83
try
:
84
res_dal = db.get_dal(
"Resource"
, res)
85
except
:
86
print(f
"Error could not find Resource {res} in file {db.databases}"
)
87
continue
88
89
if
disable:
90
if
res_dal
in
disabled:
91
print(
92
f
"{res} is already in disabled relationship of Session {session.id}"
93
)
94
else
:
95
# Add to the Segment's disabled list
96
print(f
"Adding {res} to disabled relationship of Session {session.id}"
)
97
disabled.append(res_dal)
98
else
:
99
if
res_dal
not
in
disabled:
100
print(f
"{res} is not in disabled relationship of Session {session.id}"
)
101
else
:
102
# Remove from the Segments disabled list
103
print(
104
f
"Removing {res} from disabled relationship of Session {session.id}"
105
)
106
disabled.remove(res_dal)
107
session.disabled = disabled
108
db.update_dal(session)
109
db.commit()
110
get_session_apps
Definition
get_session_apps.py:1
session.enable_resource_in_session
None enable_resource_in_session(conffwk.Configuration db, str session_name, list[str] resource, bool disable)
Definition
session.py:65
session.get_segment_apps
list[object] get_segment_apps(object segment)
Definition
session.py:3
session.get_apps_in_any_session
dict[str, list[object]] get_apps_in_any_session(conffwk.Configuration confdb)
Definition
session.py:42
Generated on
for DUNE-DAQ by
1.17.0