diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py index db1bea8a47f..bfdb9ce4820 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py @@ -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)) @@ -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 @@ -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