From 0553d4d01e98989b38ad3d25be2a00e43c414566 Mon Sep 17 00:00:00 2001 From: Julian Kent Date: Mon, 3 Jun 2019 17:30:59 +0200 Subject: [PATCH] Fix px_uploader.py to work in 16.04 with Python 2.7. Before, the pyserial check would fail before it could check for the VERSION that the Python 2.7 version contains. This fixes it to check for the VERSION independently. --- Tools/px_uploader.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Tools/px_uploader.py b/Tools/px_uploader.py index 3bf0e043ba..602f890a3c 100755 --- a/Tools/px_uploader.py +++ b/Tools/px_uploader.py @@ -727,10 +727,20 @@ def main(): # We need to check for pyserial because the import itself doesn't # seem to fail, at least not on macOS. + pyserial_installed = False try: - if serial.__version__ or serial.VERSION: - pass + if serial.__version__: + pyserial_installed = True except: + pass + + try: + if serial.VERSION: + pyserial_installed = True + except: + pass + + if not pyserial_installed: print("Error: pyserial not installed!") print(" (Install using: sudo pip install pyserial)") sys.exit(1)