1212import Engine .rx_tx_app_client_json
1313import Engine .rx_tx_app_connection_json
1414from Engine .const import LOG_FOLDER , RX_TX_APP_ERROR_KEYWORDS , DEFAULT_OUTPUT_PATH
15- from Engine .mcm_apps import get_media_proxy_port , output_validator , save_process_log , get_mcm_path
15+ from Engine .mcm_apps import (
16+ get_media_proxy_port ,
17+ output_validator ,
18+ save_process_log ,
19+ get_mcm_path ,
20+ )
1621from Engine .rx_tx_app_file_validation_utils import validate_file
1722
1823logger = logging .getLogger (__name__ )
1924
2025
21- def create_client_json (build : str , client : Engine .rx_tx_app_client_json .ClientJson ) -> None :
26+ def create_client_json (
27+ build : str , client : Engine .rx_tx_app_client_json .ClientJson
28+ ) -> None :
2229 logger .debug ("Client JSON:" )
2330 for line in client .to_json ().splitlines ():
2431 logger .debug (line )
@@ -33,7 +40,9 @@ def create_connection_json(
3340 logger .debug ("Connection JSON:" )
3441 for line in rx_tx_app_connection .to_json ().splitlines ():
3542 logger .debug (line )
36- output_path = str (Path (build , "tests" , "tools" , "TestApp" , "build" , "connection.json" ))
43+ output_path = str (
44+ Path (build , "tests" , "tools" , "TestApp" , "build" , "connection.json" )
45+ )
3746 logger .debug (f"Connection JSON path: { output_path } " )
3847 rx_tx_app_connection .prepare_and_save_json (output_path = output_path )
3948
@@ -61,29 +70,40 @@ def __init__(
6170 self .file_dict = file_dict
6271 self .file = file
6372 self .rx_tx_app_connection = rx_tx_app_connection ()
64- self .payload = payload_type .from_file_info (media_path = self .media_path , file_info = file_dict )
73+ self .payload = payload_type .from_file_info (
74+ media_path = self .media_path , file_info = file_dict
75+ )
6576 self .media_proxy_port = get_media_proxy_port (host )
6677 self .rx_tx_app_client_json = Engine .rx_tx_app_client_json .ClientJson (
67- host ,
68- apiConnectionString = f"Server=127.0.0.1; Port={ self .media_proxy_port } "
78+ host , apiConnectionString = f"Server=127.0.0.1; Port={ self .media_proxy_port } "
79+ )
80+ self .rx_tx_app_connection_json = (
81+ Engine .rx_tx_app_connection_json .ConnectionJson (
82+ host = host ,
83+ rx_tx_app_connection = self .rx_tx_app_connection ,
84+ payload = self .payload ,
85+ )
6986 )
70- self .rx_tx_app_connection_json = Engine . rx_tx_app_connection_json . ConnectionJson (
71- host = host , rx_tx_app_connection = self .rx_tx_app_connection , payload = self . payload
87+ self .app_path = host . connection . path (
88+ self .mcm_path , "tests" , "tools" , "TestApp" , "build"
7289 )
73- self .app_path = host .connection .path (self .mcm_path , "tests" , "tools" , "TestApp" , "build" )
7490 self .client_cfg_file = host .connection .path (self .app_path , "client.json" )
75- self .connection_cfg_file = host .connection .path (self .app_path , "connection.json" )
91+ self .connection_cfg_file = host .connection .path (
92+ self .app_path , "connection.json"
93+ )
7694 self .input = input_file
77- self .output_path = getattr (host .topology .extra_info , "output_path" , DEFAULT_OUTPUT_PATH )
78-
95+ self .output_path = getattr (
96+ host .topology .extra_info , "output_path" , DEFAULT_OUTPUT_PATH
97+ )
98+
7999 # Handle output file path construction
80100 if output_file and output_path :
81101 self .output = host .connection .path (output_path , output_file )
82102 elif output_file :
83103 self .output = host .connection .path (self .output_path , output_file )
84104 else :
85105 self .output = None
86-
106+
87107 self .no_proxy = no_proxy
88108 self .loop = loop
89109 self .process = None
@@ -133,7 +153,7 @@ def start(self):
133153 def stop (self ):
134154 validation_info = []
135155 file_validation_passed = True
136-
156+
137157 if self .process :
138158 try :
139159 if self .process .running :
@@ -158,11 +178,13 @@ def stop(self):
158178 logger .warning (f"Errors found: { result ['errors' ]} " )
159179
160180 self .is_pass = result ["is_pass" ]
161-
181+
162182 # Collect log validation info
163183 validation_info .append (f"=== { self .direction } App Log Validation ===" )
164184 validation_info .append (f"Log file: { log_file_path } " )
165- validation_info .append (f"Validation result: { 'PASS' if result ['is_pass' ] else 'FAIL' } " )
185+ validation_info .append (
186+ f"Validation result: { 'PASS' if result ['is_pass' ] else 'FAIL' } "
187+ )
166188 validation_info .append (f"Errors found: { len (result ['errors' ])} " )
167189 if result ["errors" ]:
168190 validation_info .append ("Error details:" )
@@ -171,40 +193,50 @@ def stop(self):
171193 if result ["phrase_mismatches" ]:
172194 validation_info .append ("Phrase mismatches:" )
173195 for phrase , found , expected in result ["phrase_mismatches" ]:
174- validation_info .append (f" - { phrase } : found '{ found } ', expected '{ expected } '" )
196+ validation_info .append (
197+ f" - { phrase } : found '{ found } ', expected '{ expected } '"
198+ )
175199
176200 # File validation for Rx only run if output path isn't "/dev/null"
177201 if self .direction == "Rx" and self .output and self .output_path != "/dev/null" :
178202 validation_info .append (f"\n === { self .direction } Output File Validation ===" )
179203 validation_info .append (f"Expected output file: { self .output } " )
180-
181- file_info , file_validation_passed = validate_file (self .host .connection , self .output , cleanup = False )
204+
205+ file_info , file_validation_passed = validate_file (
206+ self .host .connection , self .output , cleanup = False
207+ )
182208 validation_info .extend (file_info )
183209 self .is_pass = self .is_pass and file_validation_passed
184210
185211 # Save validation report to file
186212 if validation_info :
187213 validation_info .append (f"\n === Overall Validation Summary ===" )
188- overall_status = "PASS" if self .is_pass and file_validation_passed else "FAIL"
214+ overall_status = (
215+ "PASS" if self .is_pass and file_validation_passed else "FAIL"
216+ )
189217 validation_info .append (f"Overall validation: { overall_status } " )
190- validation_info .append (f"App log validation: { 'PASS' if result ['is_pass' ] else 'FAIL' } " )
218+ validation_info .append (
219+ f"App log validation: { 'PASS' if result ['is_pass' ] else 'FAIL' } "
220+ )
191221 if self .direction == "Rx" :
192222 file_status = "PASS" if file_validation_passed else "FAIL"
193223 validation_info .append (f"File validation: { file_status } " )
194224 # Add note about overall validation logic
195225 if not self .is_pass or not file_validation_passed :
196- validation_info .append ("Note: Overall validation fails if either app log or file validation fails" )
197-
226+ validation_info .append (
227+ "Note: Overall validation fails if either app log or file validation fails"
228+ )
229+
198230 # Save to validation report file
199231 log_dir = self .log_path if self .log_path else LOG_FOLDER
200232 subdir = f"RxTx/{ self .host .name } "
201233 validation_filename = f"{ self .direction .lower ()} _validation.log"
202-
234+
203235 save_process_log (
204236 subdir = subdir ,
205237 filename = validation_filename ,
206238 text = "\n " .join (validation_info ),
207- log_dir = log_dir
239+ log_dir = log_dir ,
208240 )
209241
210242 @property
@@ -225,9 +257,13 @@ def __init__(self, *args, **kwargs):
225257
226258 def start (self ):
227259 super ().start ()
228- logger .debug (f"Starting Tx app with payload: { self .payload .payload_type } on { self .host } " )
260+ logger .debug (
261+ f"Starting Tx app with payload: { self .payload .payload_type } on { self .host } "
262+ )
229263 cmd = self ._get_app_cmd ("Tx" )
230- self .process = self .host .connection .start_process (cmd , shell = True , stderr_to_stdout = True , cwd = self .app_path )
264+ self .process = self .host .connection .start_process (
265+ cmd , shell = True , stderr_to_stdout = True , cwd = self .app_path
266+ )
231267
232268 # Start background logging thread
233269 subdir = f"RxTx/{ self .host .name } "
@@ -240,7 +276,7 @@ def log_output():
240276 filename = filename ,
241277 text = line .rstrip (),
242278 cmd = cmd ,
243- log_dir = self .log_path
279+ log_dir = self .log_path ,
244280 )
245281
246282 threading .Thread (target = log_output , daemon = True ).start ()
0 commit comments