Commit 77ed256 yiwenxiu
committed
1 parent b2d92fd commit 77ed256 Copy full SHA for 77ed256
File tree 1 file changed +17
-3
lines changed
1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 9
9
import netifaces
10
10
from typing import Tuple
11
11
from pytest_embedded import Dut
12
+ import os
13
+ import yaml
14
+
12
15
13
16
CURRENT_DIR_LIGHT = str (pathlib .Path (__file__ ).parent )+ '/light'
14
17
CHIP_TOOL_EXE = str (pathlib .Path (__file__ ).parent )+ '/../connectedhomeip/connectedhomeip/out/host/chip-tool'
@@ -137,9 +140,20 @@ def test_matter_commissioning_c6(dut:Dut) -> None:
137
140
138
141
# get the host interface name
139
142
def get_host_interface_name () -> str :
140
- interfaces = netifaces .interfaces ()
141
- interface_name = [s for s in interfaces if 'wl' in s ][0 ]
142
- return str (interface_name )
143
+ home_dir = os .path .expanduser ("~" )
144
+ config_path = os .path .join (home_dir , "config" , "env_config.yml" )
145
+ if os .path .exists (config_path ):
146
+ with open (config_path , 'r' ) as file :
147
+ config = yaml .safe_load (file )
148
+ interface_name = config .get ("interface_name" )
149
+ if interface_name :
150
+ return str (interface_name )
151
+ else :
152
+ print ("Warning: Configuration file found but 'interface_name' is not defined." )
153
+
154
+ if "eth1" in netifaces .interfaces ():
155
+ return "eth1"
156
+ raise Exception ("No valid network interface found. Please ensure 'eth1' exists or configure 'interface_name' in config/env_config file." )
143
157
144
158
145
159
# reset host interface
You can’t perform that action at this time.
0 commit comments