10
10
import re
11
11
import subprocess
12
12
import sys
13
+ import os
13
14
from swsssdk import ConfigDBConnector
15
+ from sonic_py_common import device_info
14
16
except ImportError as e :
15
17
raise ImportError ("%s - required module not found" % str (e ))
16
18
27
29
FLOW_KEY = "flow_control"
28
30
DEFAULT_BAUD = "9600"
29
31
32
+ FILENAME = "udevprefix.conf"
33
+
30
34
# QUIET == True => picocom will not output any messages, and pexpect will wait for console
31
35
# switch login or command line to let user interact with shell
32
36
# Downside: if console switch output ever does not match DEV_READY_MSG, program will think connection failed
37
41
DEV_READY_MSG = r"([Ll]ogin:|[Pp]assword:|[$>#])" # login prompt or command line prompt
38
42
TIMEOUT_SEC = 0.2
39
43
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
+
40
53
# runs command, exit if stderr is written to, returns stdout otherwise
41
54
# input: cmd (str), output: output of cmd (str)
42
55
def run_command (cmd ):
@@ -119,4 +132,4 @@ def getLine(target, deviceBool=False):
119
132
lineNumber = line [LINE_KEY ]
120
133
targetLine = line
121
134
122
- return targetLine if lineNumber else None
135
+ return targetLine if lineNumber else None
0 commit comments