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
6 changes: 2 additions & 4 deletions Decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,8 @@ def wrapper(*args):
thread = ThreadWithReturnValue(target = f, args = args)
thread.start()

### isAlive is deprecated since python 3.9
cond = thread.isAlive() if hasattr(thread,'isAlive') else thread.is_alive()

while cond:
### isAlive is deprecated since python 3.9
while thread.isAlive() if hasattr(thread,'isAlive') else thread.is_alive():

if progress_dlg.WasCancelled() or progress_dlg.WasSkipped():
thread.kill()
Expand Down
18 changes: 12 additions & 6 deletions InteractionSocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ def handle(self):
self.request.send(json.dumps(response))

class MySocketServer(Server):

"""
"""
def __init__(self, server_address, RequestHandlerClass, simulation_thread):

"""
"""
if sys.platform == "win32":
socketserver.TCPServer.__init__(self, server_address, RequestHandlerClass)
else:
Expand All @@ -89,9 +91,11 @@ def handle_error(self, request, client_address):
sys.stderr.write(' ***')

class InteractionManager(threading.Thread):

"""
"""
def __init__(self, socket_id, simulation_thread):

"""
"""
threading.Thread.__init__(self)
self.daemon = True
log('SocketServer thread init ** ')
Expand All @@ -112,13 +116,15 @@ def __init__(self, socket_id, simulation_thread):


def run(self):

"""
"""
if self.server:
log('SocketServer serve_forever ** ')
self.server.serve_forever()

def stop(self):

"""
"""
if self.server:
log('SocketSserver shutdown')
self.server.shutdown()
Expand Down
5 changes: 4 additions & 1 deletion Menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,14 +703,15 @@ class PropertiesCtrlPopupMenu(wx.Menu):
""" PropertiesCtrl popup menu.
"""

def __init__(self, parent, row, col):
def __init__(self, parent, row, col, pos):
""" Constructor.
"""
wx.Menu.__init__(self)

self.parent = parent
self.row = row
self.col = col
self.pos = pos

edit = wx.MenuItem(self, ID_EDIT_ATTR, _('Edit'), _('Edit attribute'))
insert = wx.MenuItem(self, ID_INSERT_ATTR, _('Insert'), _('Insert attribute'))
Expand All @@ -737,6 +738,8 @@ def GetRow(self):
def GetCol(self):
return self.col

def GetPosition(self):
return self.pos
class ItemLibraryPopupMenu(wx.Menu):
""" Item library popup menu.
"""
Expand Down
2 changes: 2 additions & 0 deletions PreferencesGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,8 @@ def InitUI(self):
if BuzyCursorNotification(install(editor)):
dial = wx.MessageDialog(self.parent, _('You need to restart DEVSimPy to use the %s code editor.')%editor, _("Code Editor Installation"), wx.OK | wx.ICON_INFORMATION)
val = dial.ShowModal()
except:
pass
else:
choices.append(editor)

Expand Down
5 changes: 3 additions & 2 deletions PropertiesGridCtrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,12 +766,13 @@ def OnRightClick(self, event):

row = event.GetRow()
col = event.GetCol()
pos = event.GetPosition()
prop = self.GetCellValue(row, col-1)

### menu popup onlu on the column 1
if col == 1:
menu = Menu.PropertiesCtrlPopupMenu(self, row, col)
self.PopupMenu(menu, event.GetPosition())
menu = Menu.PropertiesCtrlPopupMenu(self, row, col, pos)
self.PopupMenu(menu, pos)
menu.Destroy()

def OnGridColSort(self, event):
Expand Down
14 changes: 7 additions & 7 deletions SimulationGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,17 +439,17 @@ def OnOk(self, event):
self.current_master = self.master

if isinstance(self.parent, wx.Panel):
# redirection du stdout ici dans le cas du Panel (sinon dans OnSimulation)
# stdout redirect only for the Panel mode (if not in OnSimulation)
mainW = self.parent.GetTopLevelParent()
sys.stdout = mainW.stdioWin

### test si le modele et bien charge
if (self.current_master == None) or (self.current_master.getComponentSet() == []):
### check is model is well loaded
if (self.current_master is None) or (len(self.current_master.getComponentSet()) == 0):
return self.MsgBoxEmptyModel()

### dont erase the gauge if ntl
if not self.ntl:
# stockage du temps de simulation dans le master
# simulation time stored in the master model
self.current_master.FINAL_TIME = float(self._value.GetValue())
self._gauge.SetValue(0)
### if _gauge is wx.Slider
Expand Down Expand Up @@ -484,7 +484,7 @@ def OnOk(self, event):
self.thread = simulator_factory(self.current_master, self.selected_strategy, self.prof, self.ntl, self.verbose, self.dynamic_structure_flag, self.real_time_flag)
self.thread.setName(self.title)

### si le modele n'a pas de couplage, ou si pas de generateur: alors pas besoin de simuler
### if simulation model has no connection or no generators, no need to simulate
if self.thread.end_flag:
self.OnTimer(event)
else:
Expand All @@ -510,7 +510,7 @@ def OnOk(self, event):

if self.count >= 100:
return

### interaction with the model is not possible
#self.parent.Enable(False)

Expand Down
4 changes: 1 addition & 3 deletions SimulationNoGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import gettext
_ = gettext.gettext

import InteractionSocket
import json
import pusher

Expand Down Expand Up @@ -131,8 +130,7 @@ def makeSimulation(master, T, simu_name="simu", is_remote=False, json_trace=True
progress = 0

if not builtins.__dict__['NTL']:
cond = thread.isAlive() if hasattr(thread,'isAlive') else thread.is_alive()
while cond:
while thread.isAlive() if hasattr(thread,'isAlive') else thread.is_alive():
new_real_time = time.time()
CPUduration = new_real_time - first_real_time
new_progress = 100.0*(thread.model.timeLast / T)
Expand Down
4 changes: 2 additions & 2 deletions devsimpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ def OnCloseWindow(self, event):
self.SaveSize()
self._mgr.UnInit()
del self._mgr
self.Destroy()
#self.Close()

#win = wx.Window_FindFocus()
#if win != None:
Expand All @@ -988,7 +988,7 @@ def OnCloseWindow(self, event):
#win.Disconnect(-1, -1, wx.wxEVT_KILL_FOCUS)
#self.Destroy()

#event.Skip()
event.Skip()

def OnSpin(self, event):
""" Spin button has been invoked (on the toolbar of the main windows or detached frame).
Expand Down