88
99from .config .app_mappings import DEFAULT_PAYLOAD_TYPE_CONFIG , DEFAULT_PORT_CONFIG
1010from .config .universal_params import UNIVERSAL_PARAMS
11-
12- # Import execution utilities with fallback
13- try :
14- from .execute import run
15- from .RxTxApp import prepare_tcpdump
16- except ImportError :
17- # Fallback for direct execution
18- from execute import run
19- from RxTxApp import prepare_tcpdump
11+ from .execute import run
2012
2113logger = logging .getLogger (__name__ )
2214
@@ -130,45 +122,29 @@ def get_session_default_payload_type(self, session_type: str) -> int:
130122 "ancillary" : DEFAULT_PAYLOAD_TYPE_CONFIG ["ancillary_payload_type" ],
131123 "fastmetadata" : DEFAULT_PAYLOAD_TYPE_CONFIG ["fastmetadata_payload_type" ],
132124 }
133- return payload_map .get (
134- session_type , DEFAULT_PAYLOAD_TYPE_CONFIG ["st20p_payload_type" ]
135- )
125+ return payload_map .get (session_type , DEFAULT_PAYLOAD_TYPE_CONFIG ["st20p_payload_type" ])
136126
137127 def get_common_session_params (self , session_type : str ) -> dict :
138128 """Get common session parameters used across all session types."""
139129 default_port = self .get_session_default_port (session_type )
140130 default_payload = self .get_session_default_payload_type (session_type )
141131
142132 return {
143- "replicas" : self .universal_params .get (
144- "replicas" , UNIVERSAL_PARAMS ["replicas" ]
145- ),
146- "start_port" : int (
147- self .universal_params .get ("port" )
148- if self .was_user_provided ("port" )
149- else default_port
150- ),
133+ "replicas" : self .universal_params .get ("replicas" , UNIVERSAL_PARAMS ["replicas" ]),
134+ "start_port" : int (self .universal_params .get ("port" ) if self .was_user_provided ("port" ) else default_port ),
151135 "payload_type" : (
152- self .universal_params .get ("payload_type" )
153- if self .was_user_provided ("payload_type" )
154- else default_payload
136+ self .universal_params .get ("payload_type" ) if self .was_user_provided ("payload_type" ) else default_payload
155137 ),
156138 }
157139
158140 def get_common_video_params (self ) -> dict :
159141 """Get common video parameters used across video session types."""
160142 return {
161143 "width" : int (self .universal_params .get ("width" , UNIVERSAL_PARAMS ["width" ])),
162- "height" : int (
163- self .universal_params .get ("height" , UNIVERSAL_PARAMS ["height" ])
164- ),
165- "interlaced" : self .universal_params .get (
166- "interlaced" , UNIVERSAL_PARAMS ["interlaced" ]
167- ),
144+ "height" : int (self .universal_params .get ("height" , UNIVERSAL_PARAMS ["height" ])),
145+ "interlaced" : self .universal_params .get ("interlaced" , UNIVERSAL_PARAMS ["interlaced" ]),
168146 "device" : self .universal_params .get ("device" , UNIVERSAL_PARAMS ["device" ]),
169- "enable_rtcp" : self .universal_params .get (
170- "enable_rtcp" , UNIVERSAL_PARAMS ["enable_rtcp" ]
171- ),
147+ "enable_rtcp" : self .universal_params .get ("enable_rtcp" , UNIVERSAL_PARAMS ["enable_rtcp" ]),
172148 }
173149
174150 def execute_test (
@@ -210,35 +186,26 @@ def execute_test(
210186 cmd = self .add_timeout (self .command , test_time )
211187 logger .info (f"[single] Running { framework_name } command: { cmd } " )
212188 # Optional tcpdump capture hook retained for RxTxApp compatibility
213- if (
214- capture_cfg
215- and capture_cfg .get ("enable" )
216- and "prepare_tcpdump" in globals ()
217- ):
189+ if capture_cfg and capture_cfg .get ("enable" ) and "prepare_tcpdump" in globals ():
218190 try :
219- prepare_tcpdump (capture_cfg , host )
191+ # prepare_tcpdump not yet implemented; left to change in the future
192+ # prepare_tcpdump(capture_cfg, host)
193+ pass
220194 except Exception as e :
221195 logger .warning (f"capture setup failed: { e } " )
222196 proc = self .start_process (cmd , build , test_time , host )
223197 try :
224- proc .wait (
225- timeout = (test_time or 0 )
226- + self .universal_params .get ("process_timeout_buffer" , 90 )
227- )
198+ proc .wait (timeout = (test_time or 0 ) + self .universal_params .get ("process_timeout_buffer" , 90 ))
228199 except Exception :
229- logger .warning (
230- f"{ framework_name } process wait timed out (continuing to capture output)"
231- )
200+ logger .warning (f"{ framework_name } process wait timed out (continuing to capture output)" )
232201 self .last_output = self .capture_stdout (proc , framework_name )
233202 self .last_return_code = getattr (proc , "returncode" , None )
234203 return self .validate_results ()
235204
236205 # Dual-host execution (tx self, rx rx_app)
237206 assert rx_app is not None
238207 if not rx_app .command :
239- raise RuntimeError (
240- "rx_app has no prepared command (call create_command first)"
241- )
208+ raise RuntimeError ("rx_app has no prepared command (call create_command first)" )
242209 tx_cmd = self .add_timeout (self .command , test_time )
243210 rx_cmd = rx_app .add_timeout (rx_app .command , test_time )
244211 primary_first = tx_first
@@ -258,16 +225,12 @@ def execute_test(
258225 logger .info (f"[dual] Starting second: { second_label } -> { second_cmd } " )
259226 second_proc = self .start_process (second_cmd , build , test_time , second_host )
260227 # Wait processes
261- total_timeout = (test_time or 0 ) + self .universal_params .get (
262- "process_timeout_buffer" , 90
263- )
228+ total_timeout = (test_time or 0 ) + self .universal_params .get ("process_timeout_buffer" , 90 )
264229 for p , label in [(first_proc , first_label ), (second_proc , second_label )]:
265230 try :
266231 p .wait (timeout = total_timeout )
267232 except Exception :
268- logger .warning (
269- f"Process { label } wait timeout; capturing partial output"
270- )
233+ logger .warning (f"Process { label } wait timeout; capturing partial output" )
271234 # Capture outputs
272235 if primary_first :
273236 self .last_output = self .capture_stdout (first_proc , first_label )
@@ -310,9 +273,7 @@ def add_timeout(self, command: str, test_time: int, grace: int = None) -> str:
310273 return f"timeout { effective_test_time + grace } { command } "
311274 return command
312275
313- def start_and_capture (
314- self , command : str , build : str , test_time : int , host , process_name : str
315- ):
276+ def start_and_capture (self , command : str , build : str , test_time : int , host , process_name : str ):
316277 """Start a single process and capture its stdout safely."""
317278 process = self .start_process (command , build , test_time , host )
318279 output = self .capture_stdout (process , process_name )
@@ -362,9 +323,7 @@ def extract_framerate(self, framerate_str, default: int = None) -> int:
362323 try :
363324 return int (float (num ))
364325 except ValueError :
365- logger .warning (
366- f"Could not parse framerate '{ framerate_str } ', defaulting to { default } "
367- )
326+ logger .warning (f"Could not parse framerate '{ framerate_str } ', defaulting to { default } " )
368327 return default
369328
370329 # Legacy execute_* abstract methods removed; unified execute_test used instead.
@@ -382,9 +341,7 @@ def capture_stdout(self, process, process_name: str) -> str:
382341 # Remote process objects (from mfd_connect) expose stdout via 'stdout_text'
383342 if hasattr (process , "stdout_text" ) and process .stdout_text :
384343 output = process .stdout_text
385- logger .debug (
386- f"{ process_name } output (captured stdout_text): { output [:200 ]} ..."
387- )
344+ logger .debug (f"{ process_name } output (captured stdout_text): { output [:200 ]} ..." )
388345 return output
389346 # Local fallback (subprocess) may expose .stdout already consumed elsewhere
390347 if hasattr (process , "stdout" ) and process .stdout :
@@ -394,9 +351,7 @@ def capture_stdout(self, process, process_name: str) -> str:
394351 output = process .stdout .read ()
395352 else :
396353 output = str (process .stdout )
397- logger .debug (
398- f"{ process_name } output (captured stdout): { output [:200 ]} ..."
399- )
354+ logger .debug (f"{ process_name } output (captured stdout): { output [:200 ]} ..." )
400355 return output
401356 except Exception :
402357 pass
0 commit comments