Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ConnectionThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def __init__(self, parent):
self.setDaemon(True)
self.start()


def LoadZip(self, url):
"""
"""
Expand Down
2 changes: 1 addition & 1 deletion Container.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def CheckClass(m):
devs = getInstance(cls, args)

### check instance error
return devs if isinstance(devs, tuple) else None
return devs if isinstance(devs, tuple) or isinstance(devs, Exception) else None

################################################################
# #
Expand Down
2 changes: 1 addition & 1 deletion DEVSKernel/PyPDEVS/pypdevs221/src/classicDEVSWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ def outputFnc(self):
:returns: the changed dictionary
"""
retval = self.model.outputFnc()
print(self.model, retval)
#print(self.model, retval)
return {i: [retval[i]] for i in retval}
6 changes: 3 additions & 3 deletions LibraryTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ def OnMotion(self, evt):
module = BlockFactory.GetModule(path)
info = Container.CheckClass(path)

if isinstance(info, tuple):
doc = str(info)
elif isinstance(module, tuple):
if isinstance(module, tuple) or isinstance(module, Exception):
doc = str(module)
elif isinstance(info, tuple):
doc = str(info)
else:
doc = inspect.getdoc(module)

Expand Down
3 changes: 1 addition & 2 deletions Patterns/Factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ def terminate(self, error = False, msg = None):

### error sound
wx.CallAfter(playSound, SIMULATION_ERROR_SOUND_PATH)

else:
for m in [a for a in list(self.model.getFlatComponentSet().values()) if hasattr(a, 'finish')]:
### call finished method
Expand All @@ -187,7 +186,7 @@ def terminate(self, error = False, msg = None):
wx.CallAfter(playSound, SIMULATION_SUCCESS_SOUND_PATH)

self.end_flag = True

def set_sleep(self, sleeptime):
""" Set the sleep.
"""
Expand Down
1 change: 0 additions & 1 deletion Patterns/Strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ def simulate(self, T = 100000000):
def terminate_never(model, clock):
return False


class SimStrategy4(SimStrategy):
""" classic strategy for PyPDEVS simulation
setClassicDEVS is True and confTransition in disabled
Expand Down
31 changes: 28 additions & 3 deletions PluginsGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ def __init__(self, *args, **kw):

CheckListCtrlMixin.__init__(self)

if wx.VERSION_STRING < '4.0':
self.SetStringItem = self.SetStringItem
self.InsertStringItem = self.InsertStringItem
else:
self.SetStringItem = self.SetItem
self.InsertStringItem = self.InsertItem

self.id = -100000000
self.map = {}

Expand Down Expand Up @@ -175,7 +182,24 @@ def isOk(self, item):
return module and module.__file__

def GetPath(self,item):
return self.GetPyData(item)[0].__file__ if self.GetPyData(item) else None
""" Get the path stored as PyData of the file
"""
py_data = self.GetPyData(item)

### return path if the first elem of tuple (py_data) is file (can be a function for local plugin...)
if py_data:
### is function (global plugin)?
if callable(py_data[0]):
func = py_data[0]
return func.__code__.co_filename
### is file (local plugin) ?
elif os.path.isfile(py_data[0]):
file = py_data[0]
return file.__file__
else:
return None
else:
return None

def OnEnable(self, event):
""" Ebnable the current item.
Expand Down Expand Up @@ -440,7 +464,7 @@ class BlockPluginsList(CheckListCtrl):
def __init__(self, *args, **kwargs):
""" Constructor.
"""
super(CheckListCtrl, self).__init__(*args, **kwargs)
CheckListCtrl.__init__(self,*args, **kwargs)

self.InsertColumn(0, _('Name'), width=180)
self.InsertColumn(1, _('Type'), width=180)
Expand Down Expand Up @@ -867,7 +891,8 @@ def __init__(self, *args, **kwargs):
self.CheckList.OnEdit = self.OnEdit

self.CenterOnParent(wx.BOTH)
self.Fit()
self.Layout()
#self.Fit()

@staticmethod
def GetEditor(parent, model, filename=None):
Expand Down
26 changes: 24 additions & 2 deletions SimulationGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def OnViewLog(self, event):

###
def OnOk(self, event):
""" When Run button is clicked
""" When Run button is clicked.
"""

assert(self.master is not None)
Expand Down Expand Up @@ -529,9 +529,31 @@ def OnStop(self, event):
"""

self.Interact()
if self.thread :

if self.thread:
self.thread.terminate(False)

import os
import signal
import platform

# get the current PID for safe terminate server if needed:
PID = os.getpid()
# if platform.system() != 'Windows':
# PGID = os.getgid(PID)

# if platform.system() != 'Windows':
# os.killpg(PGID, signal.SIGKILL)
# else:
# os.kill(PID, signal.SIGTERM)

main_thread = threading.currentThread()
for t in threading.enumerate():
if t is not main_thread:
pass

self.timer.Stop()

wx.Bell()

self._gauge.SetValue(0)
Expand Down
2 changes: 1 addition & 1 deletion Utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ def getInstance(cls, args = {}):
if inspect.isclass(cls):
try:
devs = cls(**args)
except Exception:
except Exception as info:
sys.stderr.write(_("Error in getInstance: %s not instanciated with %s.\n"%(cls,str(args))))
PrintException()
return sys.exc_info()
Expand Down
24 changes: 13 additions & 11 deletions ZipManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,18 +434,20 @@ def ImportModule(self)->types.ModuleType:
module = None

dial.Destroy()
finally:
if module:
module.__name__ = path_to_module(module_name)

### allows to import with a reference from the parent directory (like parentName.model).
### Now import of .amd or .cmd module is composed by DomainModel (no point!).
### Example : import CollectorMessageCollectoramd or CollectorMessageCollectorcmd
sys.modules[self.GetFullName()] = module
except Exception as e:
return e

if module:
module.__name__ = path_to_module(module_name)

### allows to import with a reference from the parent directory (like parentName.model).
### Now import of .amd or .cmd module is composed by DomainModel (no point!).
### Example : import CollectorMessageCollectoramd or CollectorMessageCollectorcmd
sys.modules[self.GetFullName()] = module

return module
else:
return None
return module
else:
return None

def ReImport(self):
""" Reimport the module from zip file.
Expand Down