|
33 | 33 | import time |
34 | 34 | import signal |
35 | 35 | import random |
36 | | -import telnetlib |
| 36 | +try: |
| 37 | + import telnetlib |
| 38 | +except ModuleNotFoundError: |
| 39 | + # telnetlib was removed in Python 3.13, this is handled in telnetClass.py |
| 40 | + telnetlib = None |
37 | 41 | import os |
38 | 42 | import shlex, subprocess |
39 | 43 | import traceback |
|
52 | 56 | from framework.core.configParser import configParser |
53 | 57 | from framework.core.utilities import utilities |
54 | 58 | from framework.core.decodeParams import decodeParams |
55 | | -from framework.core.capture import capture |
56 | | -from framework.core.webpageController import webpageController |
| 59 | +try: |
| 60 | + from framework.core.capture import capture |
| 61 | +except ModuleNotFoundError as e: |
| 62 | + # cv2/pytesseract/PIL are optional dependencies (e.g. in Docker images) |
| 63 | + if e.name in ("cv2", "pytesseract", "PIL", "PIL.Image"): |
| 64 | + def _capture_missing_dependency(*args, **kwargs): |
| 65 | + raise ImportError( |
| 66 | + "The 'capture' functionality requires optional dependencies " |
| 67 | + "(cv2, pytesseract, and Pillow). One or more of these are not " |
| 68 | + f"installed (missing module: {e.name!r}). Please install the " |
| 69 | + "required packages to use capture-related features." |
| 70 | + ) |
| 71 | + |
| 72 | + capture = _capture_missing_dependency |
| 73 | + else: |
| 74 | + raise |
| 75 | +try: |
| 76 | + from framework.core.webpageController import webpageController |
| 77 | +except ModuleNotFoundError as e: |
| 78 | + # selenium is an optional dependency (e.g. in Docker images) |
| 79 | + if e.name == "selenium": |
| 80 | + def _missing_webpage_controller(*args, **kwargs): |
| 81 | + raise ImportError( |
| 82 | + "webpageController requires the 'selenium' package, which is not installed" |
| 83 | + ) |
| 84 | + webpageController = _missing_webpage_controller |
| 85 | + else: |
| 86 | + raise |
57 | 87 | from framework.core.deviceManager import deviceManager |
58 | 88 |
|
59 | 89 | class testController(): |
@@ -149,9 +179,30 @@ def __init__(self, testName="", qcId="", maxRunTime=TEST_MAX_RUN_TIME, level=log |
149 | 179 | #Start the rest of the testControl requirements |
150 | 180 | self.devices = deviceManager(self.slotInfo.config.get("devices"), self.log, self.testLogPath) |
151 | 181 |
|
152 | | - # Set up the session from the default console |
| 182 | + # Set up the session from the enabled console (not just "default") |
153 | 183 | self.dut = self.devices.getDevice( "dut" ) |
154 | | - self.session = self.dut.getConsoleSession() |
| 184 | + |
| 185 | + # CRITICAL: Select console based on which is enabled, not hardcoded "default" |
| 186 | + # Check console configuration to find the enabled one |
| 187 | + console_name = "default" # Fallback to default |
| 188 | + try: |
| 189 | + # Get the raw config to check enabled status |
| 190 | + dut_config = self.slotInfo.config.get("devices", [{}])[0].get("dut", {}) |
| 191 | + consoles_config = dut_config.get("consoles", []) |
| 192 | + |
| 193 | + # Find the enabled console |
| 194 | + for console_item in consoles_config: |
| 195 | + for name, config in console_item.items(): |
| 196 | + if config.get("enabled", False): |
| 197 | + console_name = name |
| 198 | + self.log.info(f"Using enabled console: {console_name} (type: {config.get('type')})") |
| 199 | + break |
| 200 | + if console_name != "default": |
| 201 | + break |
| 202 | + except Exception as e: |
| 203 | + self.log.warn(f"Failed to detect enabled console, using default: {e}") |
| 204 | + |
| 205 | + self.session = self.dut.getConsoleSession(console_name) |
155 | 206 | self.outboundClient = self.dut.outBoundClient |
156 | 207 | self.powerControl = self.dut.powerControl |
157 | 208 | self.commonRemote = self.dut.remoteController |
|
0 commit comments