From 5ba0d18fe172101a1855023c883ba0bb4020a918 Mon Sep 17 00:00:00 2001 From: mle Date: Wed, 8 May 2024 19:29:56 +0200 Subject: [PATCH] Add pip warning to inverter_check.py --- tests/inverter_check.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/inverter_check.py b/tests/inverter_check.py index 4f4548f..9c56862 100644 --- a/tests/inverter_check.py +++ b/tests/inverter_check.py @@ -2,9 +2,12 @@ import asyncio import logging import sys +from importlib.metadata import version # Force the local files, not pip installed lib +sys.path.insert(0, '../goodwe') sys.path.insert(0, '../../goodwe') + import goodwe logging.basicConfig( @@ -16,6 +19,19 @@ if sys.platform.startswith('win'): asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) +module_ver = None +try: + module_ver = version('goodwe') +except ModuleNotFoundError: + pass + +if module_ver: + print("WARNING !!!") + print("==============================") + print(f"You are executing code with installed pip version goodwe:{module_ver}") + print("You are not testing the local files, if that was what you meant !!!") + print("==============================") + # Set the appropriate IP address IP_ADDRESS = "192.168.2.14" PORT = 8899