Commit b57f264f authored by sumpfralle's avatar sumpfralle

don't abort the initialization of the memory analyzer plugin, if guppy is missing

* show a descriptive message in the plugin's dialog instead
* change the "broken plugin" message to "broken or dependency missing"


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1246 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent b127973b
...@@ -23,6 +23,11 @@ ...@@ -23,6 +23,11 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">4</property> <property name="spacing">4</property>
<child>
<object class="GtkVBox" id="MemoryAnalyzerDataBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child> <child>
<object class="GtkScrolledWindow" id="scrolledwindow1"> <object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -94,7 +99,7 @@ ...@@ -94,7 +99,7 @@
</child> </child>
</object> </object>
<packing> <packing>
<property name="position">1</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -108,6 +113,23 @@ ...@@ -108,6 +113,23 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="MemoryAnalyzerBrokenLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">The memory analyzer requires the Python module &lt;i&gt;guppy&lt;/i&gt;, but it seems to be missing.</property>
<property name="use_markup">True</property>
<property name="justify">center</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
......
...@@ -24,9 +24,13 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>. ...@@ -24,9 +24,13 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
import StringIO import StringIO
import csv import csv
import gobject import gobject
import guppy # guppy will be imported later
#import guppy
import pycam.Plugins import pycam.Plugins
import pycam.Utils.log
_log = pycam.Utils.log.get_logger()
class MemoryAnalyzer(pycam.Plugins.PluginBase): class MemoryAnalyzer(pycam.Plugins.PluginBase):
...@@ -64,6 +68,15 @@ class MemoryAnalyzer(pycam.Plugins.PluginBase): ...@@ -64,6 +68,15 @@ class MemoryAnalyzer(pycam.Plugins.PluginBase):
self.model = self.gui.get_object("MemoryAnalyzerModel") self.model = self.gui.get_object("MemoryAnalyzerModel")
# window state # window state
self._window_position = None self._window_position = None
# check if "heapy" is available - this disables all widgets
try:
import guppy
except ImportError:
self._guppy = None
self.gui.get_object("MemoryAnalyzerDataBox").hide()
else:
self._guppy = guppy
self.gui.get_object("MemoryAnalyzerBrokenLabel").hide()
self.register_gtk_handlers(self._gtk_handlers) self.register_gtk_handlers(self._gtk_handlers)
return True return True
...@@ -105,7 +118,9 @@ class MemoryAnalyzer(pycam.Plugins.PluginBase): ...@@ -105,7 +118,9 @@ class MemoryAnalyzer(pycam.Plugins.PluginBase):
gobject.idle_add(self._refresh_data_in_background) gobject.idle_add(self._refresh_data_in_background)
def _refresh_data_in_background(self): def _refresh_data_in_background(self):
memory_state = guppy.hpy().heap() if not self._guppy:
return
memory_state = self._guppy.hpy().heap()
for row in memory_state.stat.get_rows(): for row in memory_state.stat.get_rows():
item = (row.name, row.count, row.size / 1024, row.size / row.count) item = (row.name, row.count, row.size / 1024, row.size / row.count)
self.model.append(item) self.model.append(item)
......
...@@ -223,8 +223,9 @@ class PluginManager(object): ...@@ -223,8 +223,9 @@ class PluginManager(object):
mod = imp.load_module(full_mod_name, mod_file, mod = imp.load_module(full_mod_name, mod_file,
mod_filename, mod_desc) mod_filename, mod_desc)
except ImportError: except ImportError:
_log.info("Skipping broken plugin %s" % os.path.join( _log.info(("Skipping plugin %s (broken or " + \
directory, filename)) "dependencies missing)") % \
os.path.join(directory, filename))
continue continue
for attr in dir(mod): for attr in dir(mod):
item = getattr(mod, attr) item = getattr(mod, attr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment