@@ -78,7 +78,7 @@ def __exit__(self, exception_type, exception_value, traceback):
78
78
def dump_temporary_logs_to_console (log_file_path : str ):
79
79
"""Dump log file to the console; log file will be removed once the function exits."""
80
80
"""Write the entire content of `log_file_path` to the console."""
81
- print ('\n Dumping logs from: ' , log_file_path )
81
+ print (f '\n Dumping logs from: { log_file_path } ' )
82
82
83
83
with open (log_file_path , 'r' ) as file :
84
84
for line in file :
@@ -87,13 +87,13 @@ def dump_temporary_logs_to_console(log_file_path: str):
87
87
88
88
def handle_casting_failure (casting_state : str , log_file_paths : List [str ]):
89
89
"""Log '{casting_state} failed!' as error, dump log files to console, exit on error."""
90
- logging .error (casting_state + ' failed!' )
90
+ logging .error (f' { casting_state } failed!' )
91
91
92
92
for log_file_path in log_file_paths :
93
93
try :
94
94
dump_temporary_logs_to_console (log_file_path )
95
95
except Exception as e :
96
- logging .exception (f" Failed to dump { log_file_path } : { e } " )
96
+ logging .exception (f' Failed to dump { log_file_path } : { e } ' )
97
97
98
98
sys .exit (1 )
99
99
@@ -178,8 +178,8 @@ def initiate_cast_request_success(tv_casting_app_info: Tuple[subprocess.Popen, T
178
178
while True :
179
179
# Check if we exceeded the maximum wait time for initiating 'cast request' from the Linux tv-casting-app to the Linux tv-app.
180
180
if time .time () - start_wait_time > COMMISSIONING_STAGE_MAX_WAIT_SEC :
181
- logging .error ('The command `cast request ' + valid_discovered_commissioner_number +
182
- ' ` was not issued to the Linux tv-casting-app process within the timeout.' )
181
+ logging .error (
182
+ f'The command `cast request { valid_discovered_commissioner_number } ` was not issued to the Linux tv-casting-app process within the timeout.' )
183
183
return False
184
184
185
185
tv_casting_app_output_line = tv_casting_app_process .stdout .readline ()
@@ -194,7 +194,9 @@ def initiate_cast_request_success(tv_casting_app_info: Tuple[subprocess.Popen, T
194
194
next_line = tv_casting_app_process .stdout .readline ()
195
195
linux_tv_casting_app_log_file .write (next_line )
196
196
linux_tv_casting_app_log_file .flush ()
197
- logging .info ('Sent `' + next_line .rstrip ('\n ' ) + '` to the Linux tv-casting-app process.' )
197
+ next_line = next_line .rstrip ('\n ' )
198
+ logging .info (f'Sent `{ next_line } ` to the Linux tv-casting-app process.' )
199
+
198
200
return True
199
201
200
202
@@ -291,8 +293,8 @@ def validate_tv_casting_request_approval(tv_app_info: Tuple[subprocess.Popen, Te
291
293
tv_app_line = tv_app_process .stdout .readline ()
292
294
linux_tv_app_log_file .write (tv_app_line )
293
295
linux_tv_app_log_file .flush ()
294
-
295
- logging .info ('Sent `' + tv_app_line . rstrip ( ' \n ' ) + ' ` to the Linux tv-app process.' )
296
+ tv_app_line = tv_app_line . rstrip ( ' \n ' )
297
+ logging .info (f 'Sent `{ tv_app_line } ` to the Linux tv-app process.' )
296
298
return True
297
299
298
300
@@ -512,6 +514,12 @@ def test_commissioning_fn(valid_discovered_commissioner_number, tv_casting_app_i
512
514
expected_device_name , expected_vendor_id , expected_product_id = extract_device_info_from_tv_casting_app (
513
515
tv_casting_app_info , 'Commissioning' , log_paths )
514
516
517
+ if not expected_device_name or not expected_vendor_id or not expected_product_id :
518
+ logging .error ('The is an error with the expected device info values that were extracted from the `Identification Declaration` block.' )
519
+ logging .error (
520
+ f'expected_device_name: { expected_device_name } , expected_vendor_id: { expected_vendor_id } , expected_product_id: { expected_product_id } ' )
521
+ handle_casting_failure ('Commissioning' , log_paths )
522
+
515
523
if not validate_identification_declaration_message_on_tv_app (tv_app_info , expected_device_name , expected_vendor_id , expected_product_id , log_paths ):
516
524
handle_casting_failure ('Commissioning' , log_paths )
517
525
0 commit comments