Skip to content

Commit 7a30ae0

Browse files
authored
Python 3 compliance (sonic-net#85)
As part of the migration from Python 2 to Python 3, this PR ensures that all Python files in sonic-platform-daemons are Python 3-compliant, and work with both Python 2 and Python 3. Once this is merged, we can begin building Python 3-based versions of the sonic-platform-daemons packages.
1 parent da3dfbb commit 7a30ae0

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

sonic-ledd/scripts/ledd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ try:
1111

1212
from sonic_py_common import daemon_base
1313
from swsscommon import swsscommon
14-
except ImportError, e:
14+
except ImportError as e:
1515
raise ImportError (str(e) + " - required module not found")
1616

1717
#============================= Constants =============================
@@ -45,17 +45,17 @@ class DaemonLedd(daemon_base.DaemonBase):
4545
(options, remainder) = getopt.getopt(sys.argv[1:],
4646
'hv',
4747
['help', 'version'])
48-
except getopt.GetoptError, e:
49-
print e
50-
print USAGE_HELP
48+
except getopt.GetoptError as e:
49+
print(e)
50+
print(USAGE_HELP)
5151
sys.exit(2)
5252

5353
for opt, arg in options:
5454
if opt == '--help' or opt == '-h':
55-
print USAGE_HELP
55+
print(USAGE_HELP)
5656
sys.exit(0)
5757
elif opt == '--version' or opt == '-v':
58-
print 'ledd version ' + VERSION
58+
print('ledd version ' + VERSION)
5959
sys.exit(0)
6060

6161
# Load platform-specific LedControl module

sonic-pcied/scripts/pcied

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ try:
1515
import swsssdk
1616
from sonic_py_common.daemon_base import DaemonBase
1717
from sonic_py_common.device_info import get_platform
18-
except ImportError, e:
18+
except ImportError as e:
1919
raise ImportError(str(e) + " - required module not found")
2020

2121
#

sonic-psud/scripts/psud

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ try:
1616

1717
from sonic_py_common import daemon_base
1818
from swsscommon import swsscommon
19-
except ImportError, e:
19+
except ImportError as e:
2020
raise ImportError (str(e) + " - required module not found")
2121

2222
#

sonic-syseepromd/scripts/syseepromd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ try:
1515

1616
from sonic_py_common import daemon_base
1717
from swsscommon import swsscommon
18-
except ImportError, e:
18+
except ImportError as e:
1919
raise ImportError (str(e) + " - required module not found")
2020

2121
PLATFORM_SPECIFIC_MODULE_NAME = 'eeprom'

sonic-xcvrd/scripts/xcvrd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ try:
1919
from enum import Enum
2020
from sonic_py_common import daemon_base, device_info, logger
2121
from swsscommon import swsscommon
22-
except ImportError, e:
22+
except ImportError as e:
2323
raise ImportError (str(e) + " - required module not found")
2424

2525
#
@@ -1128,7 +1128,7 @@ class DaemonXcvrd(daemon_base.DaemonBase):
11281128
try:
11291129
port_config_file_path = device_info.get_path_to_port_config_file()
11301130
platform_sfputil.read_porttab_mappings(port_config_file_path)
1131-
except Exception, e:
1131+
except Exception as e:
11321132
self.log_error("Failed to read port info: %s" % (str(e)), True)
11331133
sys.exit(PORT_CONFIG_LOAD_ERROR)
11341134

0 commit comments

Comments
 (0)