From 2176009adaa86ad36e4ac79ac1f9f820c473f5fc Mon Sep 17 00:00:00 2001 From: Capocchi L Date: Fri, 27 Nov 2020 11:05:29 +0100 Subject: [PATCH] bug fix --- Components.py | 12 +++++++++--- Patterns/Factory.py | 2 ++ SimulationGUI.py | 15 +++++++-------- ZipManager.py | 3 ++- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Components.py b/Components.py index 7bb1446c..9584180a 100644 --- a/Components.py +++ b/Components.py @@ -82,9 +82,15 @@ def GetClass(elem): if isinstance(clsmembers, dict): moduleName = path_to_module(elem) - for cls in list(clsmembers.values()): - if str(cls.__module__) in str(moduleName): - return cls + DomainClass = clsmembers['DomainBehavior'] if 'DomainBehavior' in clsmembers else clsmembers['DomainStructure'] + + ### return only the class that inherite of DomainBehavoir or DomainStructure which are present in the clsmembers dict + return next(filter(lambda c: c != DomainClass and issubclass(c, DomainClass), clsmembers.values()), None) + + #for cls in [c for c in clsmembers.values() if c != DomainClass]: + # if issubclass(cls, DomainClass): + #if str(cls.__module__) in str(moduleName): + # return cls else: return clsmembers diff --git a/Patterns/Factory.py b/Patterns/Factory.py index 2d91d83c..40f20897 100644 --- a/Patterns/Factory.py +++ b/Patterns/Factory.py @@ -106,6 +106,8 @@ def __init__(self, model=None, strategy='', prof=False, ntl=False, verbose=False self.dynamic_structure_flag = dynamic_structure_flag self.real_time_flag = real_time_flag + #self.deamon = True + self.end_flag = False self.thread_suspend = False self.sleep_time = 0.0 diff --git a/SimulationGUI.py b/SimulationGUI.py index abc8657b..c8d8ad05 100644 --- a/SimulationGUI.py +++ b/SimulationGUI.py @@ -533,12 +533,11 @@ def OnStop(self, event): if self.thread: self.thread.terminate(False) - import os - import signal - import platform + #import signal + #import platform # get the current PID for safe terminate server if needed: - PID = os.getpid() + #PID = os.getpid() # if platform.system() != 'Windows': # PGID = os.getgid(PID) @@ -547,10 +546,10 @@ def OnStop(self, event): # else: # os.kill(PID, signal.SIGTERM) - main_thread = threading.currentThread() - for t in threading.enumerate(): - if t is not main_thread: - pass + #main_thread = threading.currentThread() + #for t in threading.enumerate(): + # if t is not main_thread: + # pass self.timer.Stop() diff --git a/ZipManager.py b/ZipManager.py index c4065afd..8bc64776 100644 --- a/ZipManager.py +++ b/ZipManager.py @@ -397,7 +397,8 @@ def GetModule(self, rcp: bool=False)->types.ModuleType: PluginManager.trigger_event("IMPORT_STRATEGIES", fn=self.fn) try: - return self.ImportModule() if self.GetFullName() not in sys.modules else sys.modules[self.GetFullName()] + module = self.ImportModule() if self.GetFullName() not in sys.modules else sys.modules[self.GetFullName()] + return module ### model has not python file ! except Exception as e: return e