Skip to content

Commit f8bfbc9

Browse files
authored
Migrate from sonic-daemon-base package to sonic-py-common package (sonic-net#103)
As part of consolidating all common Python-based functionality into the new sonic-py-common package, this pull request migrates from importing the sonic-daemon-base package to importing the sonic-py-common package. This is the next step toward resolving sonic-net/sonic-buildimage#4999. - Also reorganize imports for consistency
1 parent 3ff137c commit f8bfbc9

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

setup.py

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
'sonic_sfp',
2525
'sonic_thermal',
2626
],
27+
install_requires=[
28+
'sonic-config-engine', # For portconfig. TODO: Remove this dependency
29+
'sonic-py-common'
30+
],
2731
classifiers=[
2832
'Development Status :: 3 - Alpha',
2933
'Environment :: Plugins',

sonic_platform_base/sonic_sfp/sfputilbase.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@
1010
import binascii
1111
import os
1212
import re
13+
import sys
14+
from collections import OrderedDict
15+
16+
from natsort import natsorted
17+
from portconfig import get_port_config
18+
from sonic_py_common import device_info
19+
1320
from . import bcmshell # Dot module supports both Python 2 and Python 3 using explicit relative import methods
1421
from sonic_eeprom import eeprom_dts
1522
from .sff8472 import sff8472InterfaceId # Dot module supports both Python 2 and Python 3 using explicit relative import methods
1623
from .sff8472 import sff8472Dom # Dot module supports both Python 2 and Python 3 using explicit relative import methods
1724
from .sff8436 import sff8436InterfaceId # Dot module supports both Python 2 and Python 3 using explicit relative import methods
1825
from .sff8436 import sff8436Dom # Dot module supports both Python 2 and Python 3 using explicit relative import methods
1926
from .inf8628 import inf8628InterfaceId # Dot module supports both Python 2 and Python 3 using explicit relative import methods
20-
from portconfig import get_port_config
21-
from collections import OrderedDict
22-
from natsort import natsorted
23-
from sonic_daemon_base.daemon_base import DaemonBase
24-
import sys
2527
except ImportError as e:
2628
raise ImportError("%s - required module not found" % str(e))
2729

@@ -384,7 +386,7 @@ def read_porttab_mappings(self, porttabfile):
384386
parse_fmt_port_config_ini = (os.path.basename(porttabfile) == PORT_CONFIG_INI)
385387
parse_fmt_platform_json = (os.path.basename(porttabfile) == PLATFORM_JSON)
386388

387-
(platform, hwsku) = DaemonBase().get_platform_and_hwsku()
389+
(platform, hwsku) = device_info.get_platform_and_hwsku()
388390
if(parse_fmt_platform_json):
389391
ports, _ = get_port_config(hwsku, platform)
390392
if not ports:

sonic_platform_base/sonic_sfp/sfputilhelper.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
import binascii
1111
import os
1212
import re
13-
from portconfig import get_port_config
13+
import sys
1414
from collections import OrderedDict
15+
1516
from natsort import natsorted
16-
from sonic_daemon_base.daemon_base import DaemonBase
17-
import sys
17+
from portconfig import get_port_config
18+
from sonic_py_common import device_info
1819
except ImportError as e:
1920
raise ImportError("%s - required module not found" % str(e))
2021

@@ -55,7 +56,7 @@ def read_porttab_mappings(self, porttabfile):
5556
parse_fmt_port_config_ini = (os.path.basename(porttabfile) == PORT_CONFIG_INI)
5657
parse_fmt_platform_json = (os.path.basename(porttabfile) == PLATFORM_JSON)
5758

58-
(platform, hwsku) = DaemonBase().get_platform_and_hwsku()
59+
(platform, hwsku) = device_info.get_platform_and_hwsku()
5960
if(parse_fmt_platform_json):
6061
ports, _ = get_port_config(hwsku, platform)
6162
if not ports:

0 commit comments

Comments
 (0)