From 7e23e63896f6efbbc4e87fe0162b098d579130ec Mon Sep 17 00:00:00 2001 From: Junchao-Mellanox <57339448+Junchao-Mellanox@users.noreply.github.com> Date: Tue, 15 Dec 2020 09:22:08 +0800 Subject: [PATCH] [y_cable] Skip ImportError in y_cable.py (#154) When build python3 xcvrd, it tries to do basic check which will import this y_cable.py. However, not all platform supports python3 API now, so it could cause an issue when importing sonic_platform.platform We skip the ImportError here to make the builder happy. And this is safe because: - If any python package is not available, there will be exception when use it - Vendors know their platform API version, they are responsible to use correct python version when importing this file. --- sonic_y_cable/y_cable.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sonic_y_cable/y_cable.py b/sonic_y_cable/y_cable.py index 809239d15c..95b11a5992 100644 --- a/sonic_y_cable/y_cable.py +++ b/sonic_y_cable/y_cable.py @@ -6,12 +6,16 @@ try: import struct - - import sonic_platform.platform from sonic_py_common import logger - + import sonic_platform.platform except ImportError as e: - raise ImportError(str(e) + " - required module not found") + # When build python3 xcvrd, it tries to do basic check which will import this file. However, + # not all platform supports python3 API now, so it could cause an issue when importing + # sonic_platform.platform. We skip the ImportError here. This is safe because: + # 1. If any python package is not available, there will be exception when use it + # 2. Vendors know their platform API version, they are responsible to use correct python + # version when importing this file. + pass # definitions of the offset with width accommodated for values # of MUX register specs of upper page 0x04 starting at 640