From da89f9e450fb03e565f1c53408a17a779faa2c3e Mon Sep 17 00:00:00 2001 From: jgyates Date: Sat, 14 Oct 2023 16:56:58 -0400 Subject: [PATCH] V1.18.18 --- OtherApps/modbusdump.py | 9 ++++++++- OtherApps/serialtest.py | 13 +++++++++++-- genloader.py | 6 ------ genmonlib/mycommon.py | 11 +++++++++++ 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/OtherApps/modbusdump.py b/OtherApps/modbusdump.py index 1009dc08..15ffbfb5 100644 --- a/OtherApps/modbusdump.py +++ b/OtherApps/modbusdump.py @@ -21,7 +21,14 @@ from genmonlib.mymodbus import ModbusProtocol except Exception as e1: print("\n\nThis program is used for the testing of modbus registers.") - print("\n\nThis program requires the modules mymodbus.py and myserial.py to reside in the genmonlib directory.\n") + managedfile = f"/usr/lib/python{sys.version_info.major:d}.{sys.version_info.minor:d}/EXTERNALLY-MANAGED" + if os.path.isfile(managedfile): + print("\n\nYou appear to be running in a managed python environemnt. To run this program see this page: ") + print("\n\n https://github.com/jgyates/genmon/wiki/Appendix-S---Working-in-a-Managed-Python-Environment\n") + else: + print("\nThe required python libraries are not installed. You must run the setup script first.\n") + print("\n\n https://github.com/jgyates/genmon/wiki/3.3--Setup-genmon-software") + print("\n\nError: " + str(e1)) sys.exit(2) diff --git a/OtherApps/serialtest.py b/OtherApps/serialtest.py index 07fdaa4f..52960998 100644 --- a/OtherApps/serialtest.py +++ b/OtherApps/serialtest.py @@ -14,8 +14,17 @@ import sys import time -import serial - +try: + import serial +except Exception as e1: + managedfile = f"/usr/lib/python{sys.version_info.major:d}.{sys.version_info.minor:d}/EXTERNALLY-MANAGED" + if os.path.isfile(managedfile): + print("\n\nYou appear to be running in a managed python environemnt. To run this program see this page: ") + print("\n\n https://github.com/jgyates/genmon/wiki/Appendix-S---Working-in-a-Managed-Python-Environment\n") + else: + print("\nThe python serial libary is not install. You must run the setup script first.\n") + print("\n\n https://github.com/jgyates/genmon/wiki/3.3--Setup-genmon-software") + sys.exit(1) # ------------ VersionTuple ----------------------------------------------------- def VersionTuple(value): diff --git a/genloader.py b/genloader.py index dc2bd192..b3146fb3 100644 --- a/genloader.py +++ b/genloader.py @@ -278,12 +278,6 @@ def CheckBaseSoftware(self): if not self.ExecuteCommandList(command_list): self.InstallBaseSoftware() - # /usr/lib/python3.11/EXTERNALLY-MANAGED - managedfile = f"/usr/lib/python{sys.version_info.major:d}.{sys.version_info.minor:d}/EXTERNALLY-MANAGED" - if os.path.isfile(managedfile): - self.OverrideManagedPackages = True - else: - self.OverrideManagedPackages = False self.PipChecked = True return True except Exception as e1: diff --git a/genmonlib/mycommon.py b/genmonlib/mycommon.py index febfd1a1..ba578b23 100644 --- a/genmonlib/mycommon.py +++ b/genmonlib/mycommon.py @@ -34,6 +34,17 @@ def InVirtualEnvironment(self): (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix)) except: return False + # ------------ MyCommon::InManagedLibaries ---------------------------------- + def ManagedLibariesEnabled(self): + try: + # /usr/lib/python3.11/EXTERNALLY-MANAGED + managedfile = f"/usr/lib/python{sys.version_info.major:d}.{sys.version_info.minor:d}/EXTERNALLY-MANAGED" + if os.path.isfile(managedfile): + return True + else: + return False + except: + return False # ------------ MyCommon::VersionTuple --------------------------------------- def VersionTuple(self, value):