@@ -98,7 +98,8 @@ def handle_casting_failure(casting_state: str, log_file_paths: List[str]):
98
98
sys .exit (1 )
99
99
100
100
101
- def extract_value_from_string (line : str ) -> str :
101
+ # def extract_value_from_string(line: str) -> str: # SHAO OG
102
+ def extract_value_from_string (line : str , casting_state : str , log_paths ) -> str :
102
103
"""Extract and return value from given input string.
103
104
104
105
The string is expected to be in the following format as it is received
@@ -112,17 +113,31 @@ def extract_value_from_string(line: str) -> str:
112
113
\x1b [0;34m[1714583616179] [7029:2386956] [SVR] device Name: Test TV casting app\x1b [0m
113
114
The substring to be extracted here is 'Test TV casting app'.
114
115
"""
115
- if '=' in line :
116
- value = line .split ('=' )[- 1 ].strip ().replace (',\x1b [0m' , '' )
116
+ # if '=' in line:
117
+ # value = line.split('=')[-1].strip().replace(',\x1b[0m', '')
118
+ # else:
119
+ # value = line.split(':')[-1].strip().replace('\x1b[0m', '')
120
+
121
+ # return value
122
+
123
+ if ':' in line :
124
+ if '=' in line :
125
+ delimiter = '='
126
+ else :
127
+ delimiter = ':'
128
+
129
+ value = line .split (delimiter )[- 1 ].strip ().replace ('\x1b [0m' , '' ).rstrip (',' )
117
130
else :
118
- value = line .split (':' )[- 1 ].strip ().replace ('\x1b [0m' , '' )
131
+ logging .error ('Could not extract the value from the following line: %s' , line )
132
+ handle_casting_failure (casting_state , log_paths )
119
133
120
134
return value
121
135
122
136
123
137
def validate_value (casting_state : str , expected_value : Union [str , int ], log_paths : List [str ], line : str , value_name : str ) -> Optional [str ]:
124
138
"""Validate a value in a string against an expected value during a given casting state."""
125
- value = extract_value_from_string (line )
139
+ # value = extract_value_from_string(line) # SHAO OG
140
+ value = extract_value_from_string (line , casting_state , log_paths )
126
141
127
142
if isinstance (expected_value , int ):
128
143
value = int (value )
@@ -187,7 +202,8 @@ def initiate_cast_request_success(tv_casting_app_info: Tuple[subprocess.Popen, T
187
202
return True
188
203
189
204
190
- def extract_device_info_from_tv_casting_app (tv_casting_app_info : Tuple [subprocess .Popen , TextIO ]) -> Tuple [Optional [str ], Optional [int ], Optional [int ]]:
205
+ # def extract_device_info_from_tv_casting_app(tv_casting_app_info: Tuple[subprocess.Popen, TextIO]) -> Tuple[Optional[str], Optional[int], Optional[int]]: # SHAO OG
206
+ def extract_device_info_from_tv_casting_app (tv_casting_app_info : Tuple [subprocess .Popen , TextIO ], casting_state : str , log_paths : List [str ]) -> Tuple [Optional [str ], Optional [int ], Optional [int ]]:
191
207
"""Extract device information from the 'Identification Declaration' block in the Linux tv-casting-app output."""
192
208
tv_casting_app_process , linux_tv_casting_app_log_file = tv_casting_app_info
193
209
@@ -200,12 +216,15 @@ def extract_device_info_from_tv_casting_app(tv_casting_app_info: Tuple[subproces
200
216
linux_tv_casting_app_log_file .flush ()
201
217
202
218
if 'device Name' in line :
203
- device_name = extract_value_from_string (line )
219
+ # device_name = extract_value_from_string(line) # SHAO OG
220
+ device_name = extract_value_from_string (line , casting_state , log_paths )
204
221
elif 'vendor id' in line :
205
- vendor_id = extract_value_from_string (line )
222
+ # vendor_id = extract_value_from_string(line) # SHAO OG
223
+ vendor_id = extract_value_from_string (line , casting_state , log_paths )
206
224
vendor_id = int (vendor_id )
207
225
elif 'product id' in line :
208
- product_id = extract_value_from_string (line )
226
+ # product_id = extract_value_from_string(line) # SHAO OG
227
+ product_id = extract_value_from_string (line , casting_state , log_paths )
209
228
product_id = int (product_id )
210
229
211
230
if device_name and vendor_id and product_id :
@@ -354,13 +373,15 @@ def parse_tv_casting_app_for_report_data_msg(tv_casting_app_info: Tuple[subproce
354
373
report_data_message .append (tv_casting_line .rstrip ('\n ' ))
355
374
356
375
if 'Cluster =' in tv_casting_line :
357
- cluster_value = extract_value_from_string (tv_casting_line )
376
+ # cluster_value = extract_value_from_string(tv_casting_line) # SHAO OG
377
+ cluster_value = extract_value_from_string (tv_casting_line , 'Testing subscription' , log_paths )
358
378
if cluster_value != CLUSTER_MEDIA_PLAYBACK :
359
379
report_data_message .clear ()
360
380
continue_parsing = False
361
381
362
382
elif 'Attribute =' in tv_casting_line :
363
- attribute_value = extract_value_from_string (tv_casting_line )
383
+ # attribute_value = extract_value_from_string(tv_casting_line) # SHAO OG
384
+ attribute_value = extract_value_from_string (tv_casting_line , 'Testing subscription' , log_paths )
364
385
if attribute_value != ATTRIBUTE_CURRENT_PLAYBACK_STATE :
365
386
report_data_message .clear ()
366
387
continue_parsing = False
@@ -497,7 +518,8 @@ def test_commissioning_fn(valid_discovered_commissioner_number, tv_casting_app_i
497
518
handle_casting_failure ('Commissioning' , log_paths )
498
519
499
520
# Extract the values from the 'Identification Declaration' block in the tv-casting-app output that we want to validate against.
500
- expected_device_name , expected_vendor_id , expected_product_id = extract_device_info_from_tv_casting_app (tv_casting_app_info )
521
+ # expected_device_name, expected_vendor_id, expected_product_id = extract_device_info_from_tv_casting_app(tv_casting_app_info) # SHAO OG
522
+ expected_device_name , expected_vendor_id , expected_product_id = extract_device_info_from_tv_casting_app (tv_casting_app_info , 'Commissioning' , log_paths )
501
523
502
524
if not validate_identification_declaration_message_on_tv_app (tv_app_info , expected_device_name , expected_vendor_id , expected_product_id , log_paths ):
503
525
handle_casting_failure ('Commissioning' , log_paths )
0 commit comments