DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq
sourcecode
daqconf
python
daqconf
utils.py
Go to the documentation of this file.
1
import
glob
2
import
logging
3
import
os
4
from
rich.logging
import
RichHandler
5
6
7
log_levels = [
"DEBUG"
,
"INFO"
,
"WARNING"
,
"ERROR"
,
"CRITICAL"
]
8
9
10
def
setup_logging
(level:str=
"INFO"
):
11
level = level.upper()
12
13
loglevel = logging.INFO
14
15
match level:
16
case
"DEBUG"
:
17
loglevel = logging.DEBUG
18
case
"INFO"
:
19
loglevel = logging.INFO
20
case
"WARNING"
:
21
loglevel = logging.WARNING
22
case
"ERROR"
:
23
loglevel = logging.ERROR
24
case
"CRITICAL"
:
25
loglevel = logging.CRITICAL
26
case _:
27
loglevel = logging.INFO
28
29
FORMAT =
"%(message)s"
30
logging.basicConfig(
31
level=
"NOTSET"
, format=FORMAT, datefmt=
"[%X]"
, handlers=[RichHandler()]
32
)
33
logging.getLogger().setLevel(loglevel)
34
35
36
def
find_oksincludes
(includes:list[str], extra_dirs:list[str] = []):
37
includefiles = []
38
39
searchdirs = [path
for
path
in
os.environ[
"DUNEDAQ_DB_PATH"
].split(
":"
)]
40
for
dir
in
extra_dirs:
41
searchdirs.append(dir)
42
43
for
inc
in
includes:
44
# print (f"Searching for {inc}")
45
match =
False
46
inc = inc.removesuffix(
".xml"
)
47
if
inc.endswith(
".data"
):
48
sub_dirs = [
"config"
,
"data"
]
49
elif
inc.endswith(
".schema"
):
50
sub_dirs = [
"schema"
]
51
else
:
52
sub_dirs = [
"*"
]
53
inc = inc +
"*"
54
for
path
in
searchdirs:
55
# print (f" {path}/{inc}.xml")
56
matches = glob.glob(f
"{inc}.xml"
, root_dir=path)
57
if
len(matches) == 0:
58
for
search_dir
in
sub_dirs:
59
# print (f" {path}/{search_dir}/{inc}.xml")
60
matches = glob.glob(f
"{search_dir}/{inc}.xml"
, root_dir=path)
61
for
filename
in
matches:
62
if
filename
not
in
includefiles:
63
print(f
"Adding {filename} to include list"
)
64
includefiles.append(filename)
65
#else:
66
# print(f"{filename} already in include list")
67
match =
True
68
break
69
if
match:
70
break
71
if
match:
72
break
73
else
:
74
for
filename
in
matches:
75
if
filename
not
in
includefiles:
76
print(f
"Adding {filename} to include list"
)
77
includefiles.append(filename)
78
#else:
79
# print(f"{filename} already in include list")
80
match =
True
81
break
82
83
if
not
match:
84
print(f
"Error could not find include file for {inc}"
)
85
return
[
False
, []]
86
87
return
[
True
, includefiles]
utils.find_oksincludes
find_oksincludes(list[str] includes, list[str] extra_dirs=[])
Definition
utils.py:36
utils.setup_logging
setup_logging(str level="INFO")
Definition
utils.py:10
Generated on Sat Jun 28 2025 for DUNE-DAQ by
1.12.0