Skip to content

Commit

Permalink
Python 3 compliance (sonic-net#85)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jleveque authored Aug 11, 2020
1 parent da3dfbb commit 7a30ae0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions sonic-ledd/scripts/ledd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ try:

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

#============================= Constants =============================
Expand Down Expand Up @@ -45,17 +45,17 @@ class DaemonLedd(daemon_base.DaemonBase):
(options, remainder) = getopt.getopt(sys.argv[1:],
'hv',
['help', 'version'])
except getopt.GetoptError, e:
print e
print USAGE_HELP
except getopt.GetoptError as e:
print(e)
print(USAGE_HELP)
sys.exit(2)

for opt, arg in options:
if opt == '--help' or opt == '-h':
print USAGE_HELP
print(USAGE_HELP)
sys.exit(0)
elif opt == '--version' or opt == '-v':
print 'ledd version ' + VERSION
print('ledd version ' + VERSION)
sys.exit(0)

# Load platform-specific LedControl module
Expand Down
2 changes: 1 addition & 1 deletion sonic-pcied/scripts/pcied
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ try:
import swsssdk
from sonic_py_common.daemon_base import DaemonBase
from sonic_py_common.device_info import get_platform
except ImportError, e:
except ImportError as e:
raise ImportError(str(e) + " - required module not found")

#
Expand Down
2 changes: 1 addition & 1 deletion sonic-psud/scripts/psud
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ try:

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

#
Expand Down
2 changes: 1 addition & 1 deletion sonic-syseepromd/scripts/syseepromd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ try:

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

PLATFORM_SPECIFIC_MODULE_NAME = 'eeprom'
Expand Down
4 changes: 2 additions & 2 deletions sonic-xcvrd/scripts/xcvrd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ try:
from enum import Enum
from sonic_py_common import daemon_base, device_info, logger
from swsscommon import swsscommon
except ImportError, e:
except ImportError as e:
raise ImportError (str(e) + " - required module not found")

#
Expand Down Expand Up @@ -1128,7 +1128,7 @@ class DaemonXcvrd(daemon_base.DaemonBase):
try:
port_config_file_path = device_info.get_path_to_port_config_file()
platform_sfputil.read_porttab_mappings(port_config_file_path)
except Exception, e:
except Exception as e:
self.log_error("Failed to read port info: %s" % (str(e)), True)
sys.exit(PORT_CONFIG_LOAD_ERROR)

Expand Down

0 comments on commit 7a30ae0

Please sign in to comment.