Skip to content

Commit 95b1696

Browse files
authored
[xcvrd] Remove dependence on enum; Add 'sonic-py-common' as dependencies in setup.py (sonic-net#106)
Remove dependence on the 'enum' package, as we are currently transitioning from Python 2 to Python 3 and there are installation conflict issues between the `enum` package and the `enum34` package. Add 'sonic-py-common' as dependencies in setup.py for xcvrd, also add spaces around "equals" signs.
1 parent 61ed24e commit 95b1696

File tree

2 files changed

+33
-22
lines changed

2 files changed

+33
-22
lines changed

sonic-xcvrd/scripts/xcvrd

+16-9
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ try:
1616
import threading
1717
import time
1818

19-
from enum import Enum
2019
from sonic_py_common import daemon_base, device_info, logger
21-
from swsscommon import swsscommon
2220
from sonic_py_common import multi_asic
21+
from swsscommon import swsscommon
2322
except ImportError, e:
2423
raise ImportError (str(e) + " - required module not found")
2524

@@ -46,13 +45,21 @@ XCVRD_MAIN_THREAD_SLEEP_SECS = 60
4645
SFP_STATUS_REMOVED = '0'
4746
SFP_STATUS_INSERTED = '1'
4847

49-
# SFP error code enum, new elements can be added to the enum if new errors need to be supported.
50-
SFP_STATUS_ERR_ENUM = Enum('SFP_STATUS_ERR_ENUM', ['SFP_STATUS_ERR_I2C_STUCK', 'SFP_STATUS_ERR_BAD_EEPROM',
51-
'SFP_STATUS_ERR_UNSUPPORTED_CABLE', 'SFP_STATUS_ERR_HIGH_TEMP',
52-
'SFP_STATUS_ERR_BAD_CABLE'], start=2)
53-
54-
# Convert the error code to string and store them in a set for convenience
55-
errors_block_eeprom_reading = set(str(error_code.value) for error_code in SFP_STATUS_ERR_ENUM)
48+
# SFP error codes, stored as strings. Can add more as needed.
49+
SFP_STATUS_ERR_I2C_STUCK = '2'
50+
SFP_STATUS_ERR_BAD_EEPROM = '3'
51+
SFP_STATUS_ERR_UNSUPPORTED_CABLE = '4'
52+
SFP_STATUS_ERR_HIGH_TEMP = '5'
53+
SFP_STATUS_ERR_BAD_CABLE = '6'
54+
55+
# Store the error codes in a set for convenience
56+
errors_block_eeprom_reading = {
57+
SFP_STATUS_ERR_I2C_STUCK,
58+
SFP_STATUS_ERR_BAD_EEPROM,
59+
SFP_STATUS_ERR_UNSUPPORTED_CABLE,
60+
SFP_STATUS_ERR_HIGH_TEMP,
61+
SFP_STATUS_ERR_BAD_CABLE
62+
}
5663

5764
EVENT_ON_ALL_SFP = '-1'
5865
# events definition

sonic-xcvrd/setup.py

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
from setuptools import setup
22

33
setup(
4-
name='sonic-xcvrd',
5-
version='1.0',
6-
description='Transceiver monitoring daemon for SONiC',
7-
license='Apache 2.0',
8-
author='SONiC Team',
9-
author_email='[email protected]',
10-
url='https://github.com/Azure/sonic-platform-daemons',
11-
maintainer='Kebo Liu',
12-
maintainer_email='[email protected]',
13-
scripts=[
4+
name = 'sonic-xcvrd',
5+
version = '1.0',
6+
description = 'Transceiver monitoring daemon for SONiC',
7+
license = 'Apache 2.0',
8+
author = 'SONiC Team',
9+
author_email = '[email protected]',
10+
url = 'https://github.com/Azure/sonic-platform-daemons',
11+
maintainer = 'Kebo Liu',
12+
maintainer_email = '[email protected]',
13+
scripts = [
1414
'scripts/xcvrd',
1515
],
16-
setup_requires= [
16+
install_requires = [
17+
# NOTE: This package also requires swsscommon, but it is not currently installed as a wheel
18+
'sonic-py-common',
19+
],
20+
setup_requires = [
1721
'wheel'
1822
],
19-
classifiers=[
23+
classifiers = [
2024
'Development Status :: 4 - Beta',
2125
'Environment :: No Input/Output (Daemon)',
2226
'Intended Audience :: Developers',
@@ -28,5 +32,5 @@
2832
'Programming Language :: Python :: 2.7',
2933
'Topic :: System :: Hardware',
3034
],
31-
keywords='sonic SONiC TRANSCEIVER transceiver daemon XCVRD xcvrd',
35+
keywords = 'sonic SONiC TRANSCEIVER transceiver daemon XCVRD xcvrd',
3236
)

0 commit comments

Comments
 (0)