diff --git a/consutil/lib.py b/consutil/lib.py index fe718f12ff..7a6239c786 100644 --- a/consutil/lib.py +++ b/consutil/lib.py @@ -10,7 +10,9 @@ import re import subprocess import sys + import os from swsssdk import ConfigDBConnector + from sonic_py_common import device_info except ImportError as e: raise ImportError("%s - required module not found" % str(e)) @@ -27,6 +29,8 @@ FLOW_KEY = "flow_control" DEFAULT_BAUD = "9600" +FILENAME = "udevprefix.conf" + # QUIET == True => picocom will not output any messages, and pexpect will wait for console # switch login or command line to let user interact with shell # Downside: if console switch output ever does not match DEV_READY_MSG, program will think connection failed @@ -37,6 +41,15 @@ DEV_READY_MSG = r"([Ll]ogin:|[Pp]assword:|[$>#])" # login prompt or command line prompt TIMEOUT_SEC = 0.2 +platform_path, _ = device_info.get_paths_to_platform_and_hwsku_dirs() +PLUGIN_PATH = "/".join([platform_path, "plugins", FILENAME]) + +if os.path.exists(PLUGIN_PATH): + fp = open(PLUGIN_PATH, 'r') + line = fp.readlines() + DEVICE_PREFIX = "/dev/" + line[0] + + # runs command, exit if stderr is written to, returns stdout otherwise # input: cmd (str), output: output of cmd (str) def run_command(cmd): @@ -119,4 +132,4 @@ def getLine(target, deviceBool=False): lineNumber = line[LINE_KEY] targetLine = line - return targetLine if lineNumber else None \ No newline at end of file + return targetLine if lineNumber else None