From 8069151b2cd642f2e7752e1787e8ee8388096293 Mon Sep 17 00:00:00 2001 From: Capocchi L Date: Mon, 9 Mar 2020 15:37:01 +0100 Subject: [PATCH 1/5] bug fix for profiling on windows --- devsimpy.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/devsimpy.py b/devsimpy.py index 9c4be3a2..8b2d19ed 100644 --- a/devsimpy.py +++ b/devsimpy.py @@ -46,6 +46,7 @@ import webbrowser import platform import threading +import subprocess import pickle import itertools import shutil @@ -1905,8 +1906,10 @@ def OnProfiling(self, event): response = dlg.GetStringSelection() if response == 'snakeviz': dlg.Destroy() - r = install_and_import(response) - if r: os.system(" ".join([response,prof_file_path,"&"])) + if install_and_import(response): + threading.Thread(target=self.longRunning1, + args=(response,prof_file_path), + ).start() elif response == 'gprof2dot': dlg.Destroy() r = install_and_import(response) @@ -1920,6 +1923,9 @@ def OnProfiling(self, event): d.ShowModal() else: dlg.Destroy() + @staticmethod + def longRunning1(response, prof_file_path): + subprocess.call(" ".join([response,prof_file_path])) @staticmethod @redirectStdout From 8534759e2addfcfeade7bd93a83a5ccfec944062 Mon Sep 17 00:00:00 2001 From: Capocchi L Date: Mon, 9 Mar 2020 15:50:15 +0100 Subject: [PATCH 2/5] update for linux --- devsimpy.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/devsimpy.py b/devsimpy.py index 8b2d19ed..4e3c6eed 100644 --- a/devsimpy.py +++ b/devsimpy.py @@ -1912,9 +1912,10 @@ def OnProfiling(self, event): ).start() elif response == 'gprof2dot': dlg.Destroy() - r = install_and_import(response) - png_file_path = prof_file_path.replace('.prof', '.png') - os.system(" ".join([response,'-f pstats',prof_file_path,"|", "dot", "-Tpng", "-o", png_file_path, "&&", "eog", png_file_path])) + if install_and_import(response): + threading.Thread(target=self.longRunning2, + args=(response,prof_file_path), + ).start() elif response == _('Embedded in DEVSimPy'): dlg.Destroy() output = self.LoadProfFile(prof_file_path) @@ -1923,9 +1924,15 @@ def OnProfiling(self, event): d.ShowModal() else: dlg.Destroy() + @staticmethod def longRunning1(response, prof_file_path): - subprocess.call(" ".join([response,prof_file_path])) + subprocess.call(" ".join([response,prof_file_path]), shell=True) + + @staticmethod + def longRunning2(response, prof_file_path): + png_file_path = prof_file_path.replace('.prof', '.png') + subprocess.call(" ".join([response,'-f pstats',prof_file_path,"|", "dot", "-Tpng", "-o", png_file_path, "&&", "eog", png_file_path])) @staticmethod @redirectStdout From 74c69df6be847c8bda067ee61a4096e29f1e0121 Mon Sep 17 00:00:00 2001 From: Capocchi L Date: Mon, 9 Mar 2020 15:51:20 +0100 Subject: [PATCH 3/5] update --- devsimpy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devsimpy.py b/devsimpy.py index 4e3c6eed..26665448 100644 --- a/devsimpy.py +++ b/devsimpy.py @@ -1932,7 +1932,7 @@ def longRunning1(response, prof_file_path): @staticmethod def longRunning2(response, prof_file_path): png_file_path = prof_file_path.replace('.prof', '.png') - subprocess.call(" ".join([response,'-f pstats',prof_file_path,"|", "dot", "-Tpng", "-o", png_file_path, "&&", "eog", png_file_path])) + subprocess.call(" ".join([response,'-f pstats',prof_file_path,"|", "dot", "-Tpng", "-o", png_file_path, "&&", "eog", png_file_path]), shell=True) @staticmethod @redirectStdout From 1eb953a958b1c8d3f4c104bc88d70a7515153fd3 Mon Sep 17 00:00:00 2001 From: Capocchi L Date: Mon, 9 Mar 2020 15:55:14 +0100 Subject: [PATCH 4/5] update --- devsimpy.py | 1 + 1 file changed, 1 insertion(+) diff --git a/devsimpy.py b/devsimpy.py index 26665448..5e3f87e9 100644 --- a/devsimpy.py +++ b/devsimpy.py @@ -1899,6 +1899,7 @@ def OnProfiling(self, event): prof_file_path = os.path.join(gettempdir(), fn) ### list of item in single choice dialogue + ### gprof2dot needs graphviz choices = ['snakeviz','gprof2dot',_('Embedded in DEVSimPy')] dlg = wx.SingleChoiceDialog(self, _('What profiling software are you using?'), _('Single Choice'), choices) From 95bdd3bd96680521507dd085d451021dcad28595 Mon Sep 17 00:00:00 2001 From: lcapocchi Date: Tue, 10 Mar 2020 05:22:47 -0400 Subject: [PATCH 5/5] Add Crust to replace Shell --- devsimpy.py | 59 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/devsimpy.py b/devsimpy.py index 5e3f87e9..9774fa07 100644 --- a/devsimpy.py +++ b/devsimpy.py @@ -302,7 +302,7 @@ def __init__(self, parent, id, title): # Shell panel self.panel4 = wx.Panel(self, wx.NewIdRef(), style=wx.WANTS_CHARS) sizer4 = wx.BoxSizer(wx.VERTICAL) - sizer4.Add(py.shell.Shell(self.panel4, introText=_("Welcome to DEVSimPy: The GUI for Python DEVS Simulator")), 1, wx.EXPAND) + sizer4.Add(py.crust.Crust(self.panel4, intro=_("Welcome to DEVSimPy: The GUI for Python DEVS Simulator")), 1, wx.EXPAND) self.panel4.SetSizer(sizer4) self.panel4.SetAutoLayout(True) @@ -1900,31 +1900,40 @@ def OnProfiling(self, event): ### list of item in single choice dialogue ### gprof2dot needs graphviz - choices = ['snakeviz','gprof2dot',_('Embedded in DEVSimPy')] + choices = ['snakeviz', 'gprof2dot', _('Embedded in DEVSimPy')] - dlg = wx.SingleChoiceDialog(self, _('What profiling software are you using?'), _('Single Choice'), choices) - if dlg.ShowModal() == wx.ID_OK: - response = dlg.GetStringSelection() - if response == 'snakeviz': - dlg.Destroy() - if install_and_import(response): - threading.Thread(target=self.longRunning1, - args=(response,prof_file_path), - ).start() - elif response == 'gprof2dot': - dlg.Destroy() - if install_and_import(response): - threading.Thread(target=self.longRunning2, - args=(response,prof_file_path), - ).start() - elif response == _('Embedded in DEVSimPy'): - dlg.Destroy() - output = self.LoadProfFile(prof_file_path) - d = wx.lib.dialogs.ScrolledMessageDialog(self, output, _("Statistic of profiling"), style=wx.OK|wx.ICON_EXCLAMATION|wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) - d.CenterOnParent(wx.BOTH) - d.ShowModal() - else: - dlg.Destroy() + if os.path.exists(prof_file_path): + + dlg = wx.SingleChoiceDialog(self, _('What profiling software are you using?'), _('Single Choice'), choices) + if dlg.ShowModal() == wx.ID_OK: + + response = dlg.GetStringSelection() + if response == 'snakeviz': + dlg.Destroy() + if install_and_import(response): + threading.Thread(target=self.longRunning1, + args=(response,prof_file_path), + ).start() + else: + wx.MessageBox(_('%s is not installed.'%(response)), _('Error'), wx.OK | wx.ICON_ERROR) + elif response == 'gprof2dot': + dlg.Destroy() + if install_and_import(response): + threading.Thread(target=self.longRunning2, + args=(response,prof_file_path), + ).start() + else: + wx.MessageBox(_('%s is not installed.'%(response)), _('Error'), wx.OK | wx.ICON_ERROR) + elif response == _('Embedded in DEVSimPy'): + dlg.Destroy() + output = self.LoadProfFile(prof_file_path) + d = wx.lib.dialogs.ScrolledMessageDialog(self, output, _("Statistic of profiling"), style=wx.OK|wx.ICON_EXCLAMATION|wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) + d.CenterOnParent(wx.BOTH) + d.ShowModal() + else: + dlg.Destroy() + else: + wx.MessageBox(_('The profile file %s does not exist.'%(prof_file_path)), _('Error'), wx.OK | wx.ICON_ERROR) @staticmethod def longRunning1(response, prof_file_path):