Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mellanox] fix sfp issue in reading qsfp_status #3386

Merged
merged 3 commits into from
Sep 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import subprocess
from sonic_sfp.sfputilbase import *
import syslog
import sys
except ImportError as e:
raise ImportError("%s - required module not found" % str(e))

Expand Down Expand Up @@ -103,12 +104,11 @@ def get_presence(self, port_num):

try:
reg_file = open(self.qsfp_sysfs_path + "qsfp{}_status".format(port_num + 1))
content = reg_file.readline().rstrip()
except IOError as e:
print "Error: unable to open file: %s" % str(e)
print >> sys.stderr, "Error: unable to access file: %s" % str(e)
return False

content = reg_file.readline().rstrip()

# content is a string with the qsfp status
if content == SFP_STATUS_INSERTED:
return True
Expand All @@ -127,7 +127,7 @@ def get_low_power_mode(self, port_num):
if 'LPM ON' in output:
return True
except subprocess.CalledProcessError as e:
print "Error! Unable to get LPM for {}, rc = {}, err msg: {}".format(port_num, e.returncode, e.output)
print >> sys.stderr, "Error! Unable to get LPM for {}, rc = {}, err msg: {}".format(port_num, e.returncode, e.output)
return False

return False
Expand Down