-
Notifications
You must be signed in to change notification settings - Fork 3
/
global_configurations.py
293 lines (258 loc) · 10.5 KB
/
global_configurations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# -*- coding: utf-8 -*-
"""DPCTF device observation framework Global Configurations
loads global configurations form config.ini file
default values are used when file not found or value not defined
The Software is provided to you by the Licensor under the License, as
defined below, subject to the following condition.
Without limiting other conditions in the License, the grant of rights under
the License will not include, and the License does not grant to you, the
right to Sell the Software.
For purposes of the foregoing, “Sell” means practicing any or all of the
rights granted to you under the License to provide to third parties, for a
fee or other consideration (including without limitation fees for hosting
or consulting/ support services related to the Software), a product or
service whose value derives, entirely or substantially, from the
functionality of the Software. Any license notice or attribution required
by the License must also include this Commons Clause License Condition
notice.
Software: WAVE Observation Framework
License: Apache 2.0 https://www.apache.org/licenses/LICENSE-2.0.txt
Licensor: Consumer Technology Association
Contributor: Resillion UK Limited
"""
import configparser
import logging
from typing import Dict, List
logger = logging.getLogger(__name__)
class GlobalConfigurations:
"""Global Configurations class"""
config: configparser.RawConfigParser
ignore_corrupted: str
"""special condition to ignore
used to ignore corrupted frames for gopro9"""
system_mode: str
"""system mode for debugging purpose only"""
qr_search_range: List[int]
"""Runs the test runner over a specific range"""
def __init__(self):
self.config = configparser.ConfigParser()
self.config.read("config.ini", "UTF-8")
self.ignore = ""
self.system_mode = ""
self.qr_search_range = []
def set_qr_search_range(self, qr_search_range: str):
"""Set range"""
if qr_search_range:
temp_range = qr_search_range.split(":")
if len(temp_range) != 3:
raise ValueError("Not enough arguments specified for range")
if (
int(temp_range[0]) < 0
or int(temp_range[1]) < 0
or int(temp_range[2]) < 0
):
raise ValueError("Input arguments for range must be positive integers")
test_range = [int(num) for num in temp_range]
self.qr_search_range = test_range
def get_qr_search_range(self) -> List[int]:
"""Get range"""
return self.qr_search_range
def set_ignore_corrupted(self, ignore_corrupted: str) -> str:
"""Set ignore"""
self.ignore_corrupted = ignore_corrupted
def get_ignore_corrupted(self) -> str:
"""Get ignore"""
return self.ignore_corrupted
def set_system_mode(self, mode: str) -> str:
"""Set system_mode"""
self.system_mode = mode
def get_system_mode(self) -> str:
"""Get system_mode"""
return self.system_mode
def get_sort_input_files_by(self) -> str:
"""Get sort_input_files_by"""
try:
sort_input_files_by = self.config["GENERAL"]["sort_input_files_by"]
except KeyError:
sort_input_files_by = ""
return sort_input_files_by
def get_log_file_path(self) -> str:
"""Get log_file_path"""
try:
log_file_path = self.config["GENERAL"]["log_file_path"]
except KeyError:
log_file_path = "logs"
return log_file_path
def get_result_file_path(self) -> str:
"""Get result_file_path"""
try:
result_file_path = self.config["GENERAL"]["result_file_path"]
except KeyError:
result_file_path = "results"
return result_file_path
def get_audio_mezzanine_file_path(self) -> str:
"""Get audio_mezzanine_file_path"""
try:
audio_mezzanine_file_path = self.config["GENERAL"][
"audio_mezzanine_file_path"
]
except KeyError:
audio_mezzanine_file_path = "audio_mezzanine"
return audio_mezzanine_file_path
def get_session_log_threshold(self) -> int:
"""Get session_log_threshold"""
try:
session_log_threshold = int(self.config["GENERAL"]["session_log_threshold"])
except KeyError:
session_log_threshold = 100
return session_log_threshold
def get_test_runner_url(self) -> str:
"""Get test_runner_url"""
try:
test_runner_url = self.config["GENERAL"]["test_runner_url"]
except KeyError:
test_runner_url = "http://web-platform.test:8000"
return test_runner_url
def get_missing_frame_threshold(self) -> int:
"""Get missing_frame_threshold"""
try:
missing_frame_threshold = int(
self.config["GENERAL"]["missing_frame_threshold"]
)
except KeyError:
missing_frame_threshold = 0
return missing_frame_threshold
def get_consecutive_no_qr_threshold(self) -> int:
"""Get consecutive_no_qr_threshold"""
try:
consecutive_no_qr_threshold = int(
self.config["GENERAL"]["consecutive_no_qr_threshold"]
)
except KeyError:
consecutive_no_qr_threshold = 0
return consecutive_no_qr_threshold
def get_end_of_session_timeout(self) -> int:
"""Get end_of_session_timeout"""
try:
end_of_session_timeout = int(
self.config["GENERAL"]["end_of_session_timeout"]
)
except KeyError:
end_of_session_timeout = 10
return end_of_session_timeout
def get_no_qr_code_timeout(self) -> int:
"""Get no_qr_code_timeout"""
try:
no_qr_code_timeout = int(self.config["GENERAL"]["no_qr_code_timeout"])
except KeyError:
no_qr_code_timeout = 5
return no_qr_code_timeout
def get_search_qr_area_to(self) -> int:
"""Get search_qr_area_to"""
try:
search_qr_area_to = int(self.config["GENERAL"]["search_qr_area_to"])
except KeyError:
search_qr_area_to = 60
return search_qr_area_to
def get_qr_area_margin(self) -> int:
"""Get qr_area_margin"""
try:
qr_area_margin = int(self.config["GENERAL"]["qr_area_margin"])
except KeyError:
qr_area_margin = 50
return qr_area_margin
def get_duplicated_qr_check_count(self) -> int:
"""Get duplicated_qr_check_count"""
try:
duplicated_qr_check_count = int(
self.config["GENERAL"]["duplicated_qr_check_count"]
)
except KeyError:
duplicated_qr_check_count = 3
return duplicated_qr_check_count
def get_audio_observation_neighborhood(self) -> int:
"""Get audio_observation_neighborhood"""
try:
audio_observation_neighborhood = int(
self.config["GENERAL"]["audio_observation_neighborhood"]
)
except KeyError:
audio_observation_neighborhood = 500
return audio_observation_neighborhood
def get_audio_alignment_check_count(self) -> int:
"""Get audio_alignment_check_count"""
try:
audio_alignment_check_count = int(
self.config["GENERAL"]["audio_alignment_check_count"]
)
except KeyError:
audio_alignment_check_count = 10
return audio_alignment_check_count
def get_max_search_frames_for_video_shift(self) -> int:
"""Get max_search_frames_for_video_shift"""
try:
max_search_frames_for_video_sift = int(
self.config["GENERAL"]["max_search_frames_for_video_shift"]
)
except KeyError:
max_search_frames_for_video_sift = 16
return max_search_frames_for_video_sift
def get_enable_cropped_scan_for_pre_test_qr(self) -> bool:
"""Get enable_cropped_scan_for_pre_test_qr"""
try:
config_value = self.config["GENERAL"]["enable_cropped_scan_for_pre_test_qr"]
if config_value == "True":
enable_cropped_scan_for_pre_test_qr = True
else:
enable_cropped_scan_for_pre_test_qr = False
except KeyError:
enable_cropped_scan_for_pre_test_qr = False
return enable_cropped_scan_for_pre_test_qr
def get_tolerances(self) -> Dict[str, int]:
"""Get tolerances"""
tolerances = {
"start_frame_num_tolerance": 0,
"end_frame_num_tolerance": 0,
"mid_frame_num_tolerance": 0,
"splice_start_frame_num_tolerance": 0,
"splice_end_frame_num_tolerance": 0,
"start_segment_num_tolerance": 0,
"end_segment_num_tolerance": 0,
"mid_segment_num_tolerance": 10,
"splice_start_segment_num_tolerance": 0,
"splice_end_segment_num_tolerance": 0,
}
try:
tolerances["start_frame_num_tolerance"] = int(
self.config["TOLERANCES"]["start_frame_num_tolerance"]
)
tolerances["end_frame_num_tolerance"] = int(
self.config["TOLERANCES"]["end_frame_num_tolerance"]
)
tolerances["mid_frame_num_tolerance"] = int(
self.config["TOLERANCES"]["mid_frame_num_tolerance"]
)
tolerances["splice_start_frame_num_tolerance"] = int(
self.config["TOLERANCES"]["splice_start_frame_num_tolerance"]
)
tolerances["splice_end_frame_num_tolerance"] = int(
self.config["TOLERANCES"]["splice_end_frame_num_tolerance"]
)
tolerances["start_segment_num_tolerance"] = int(
self.config["TOLERANCES"]["start_segment_num_tolerance"]
)
tolerances["end_segment_num_tolerance"] = int(
self.config["TOLERANCES"]["end_segment_num_tolerance"]
)
tolerances["mid_segment_num_tolerance"] = int(
self.config["TOLERANCES"]["mid_segment_num_tolerance"]
)
tolerances["splice_start_segment_num_tolerance"] = int(
self.config["TOLERANCES"]["splice_start_segment_num_tolerance"]
)
tolerances["splice_end_segment_num_tolerance"] = int(
self.config["TOLERANCES"]["splice_end_segment_num_tolerance"]
)
except KeyError:
pass
return tolerances