Skip to content

Commit 3a7457c

Browse files
[celestica] consutil to support customize tty device name (#1155)
* Update lib.py * Keep the code format align see add spaces for special symbols * remove unused code
1 parent b6af9f4 commit 3a7457c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

consutil/lib.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
import re
1111
import subprocess
1212
import sys
13+
import os
1314
from swsssdk import ConfigDBConnector
15+
from sonic_py_common import device_info
1416
except ImportError as e:
1517
raise ImportError("%s - required module not found" % str(e))
1618

@@ -27,6 +29,8 @@
2729
FLOW_KEY = "flow_control"
2830
DEFAULT_BAUD = "9600"
2931

32+
FILENAME = "udevprefix.conf"
33+
3034
# QUIET == True => picocom will not output any messages, and pexpect will wait for console
3135
# switch login or command line to let user interact with shell
3236
# Downside: if console switch output ever does not match DEV_READY_MSG, program will think connection failed
@@ -37,6 +41,15 @@
3741
DEV_READY_MSG = r"([Ll]ogin:|[Pp]assword:|[$>#])" # login prompt or command line prompt
3842
TIMEOUT_SEC = 0.2
3943

44+
platform_path, _ = device_info.get_paths_to_platform_and_hwsku_dirs()
45+
PLUGIN_PATH = "/".join([platform_path, "plugins", FILENAME])
46+
47+
if os.path.exists(PLUGIN_PATH):
48+
fp = open(PLUGIN_PATH, 'r')
49+
line = fp.readlines()
50+
DEVICE_PREFIX = "/dev/" + line[0]
51+
52+
4053
# runs command, exit if stderr is written to, returns stdout otherwise
4154
# input: cmd (str), output: output of cmd (str)
4255
def run_command(cmd):
@@ -119,4 +132,4 @@ def getLine(target, deviceBool=False):
119132
lineNumber = line[LINE_KEY]
120133
targetLine = line
121134

122-
return targetLine if lineNumber else None
135+
return targetLine if lineNumber else None

0 commit comments

Comments
 (0)