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
......@@ -24,73 +24,97 @@
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<object class="GtkVBox" id="MemoryAnalyzerDataBox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">etched-in</property>
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<object class="GtkTreeView" id="MemoryAnalyzerTable">
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">MemoryAnalyzerModel</property>
<property name="reorderable">True</property>
<property name="search_column">0</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">etched-in</property>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
<property name="title">Size (all) [kB]</property>
<property name="clickable">True</property>
<property name="sort_column_id">2</property>
<object class="GtkTreeView" id="MemoryAnalyzerTable">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">MemoryAnalyzerModel</property>
<property name="reorderable">True</property>
<property name="search_column">0</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext3"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
<property name="title">Size (all) [kB]</property>
<property name="clickable">True</property>
<property name="sort_column_id">2</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext3"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<property name="title">Count</property>
<property name="clickable">True</property>
<property name="sort_order">descending</property>
<property name="sort_column_id">1</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<property name="title">Count</property>
<property name="clickable">True</property>
<property name="sort_order">descending</property>
<property name="sort_column_id">1</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn4">
<property name="title">Average size [B]</property>
<property name="clickable">True</property>
<property name="sort_column_id">3</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext4"/>
<attributes>
<attribute name="text">3</attribute>
</attributes>
<object class="GtkTreeViewColumn" id="treeviewcolumn4">
<property name="title">Average size [B]</property>
<property name="clickable">True</property>
<property name="sort_column_id">3</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext4"/>
<attributes>
<attribute name="text">3</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="title">Type</property>
<property name="clickable">True</property>
<property name="sort_column_id">0</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="title">Type</property>
<property name="clickable">True</property>
<property name="sort_column_id">0</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="MemoryAnalyzerLoadingLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Updating memory usage data ...</property>
<attributes>
<attribute name="style" value="italic"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
......@@ -98,16 +122,14 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="MemoryAnalyzerLoadingLabel">
<object class="GtkLabel" id="MemoryAnalyzerBrokenLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Updating memory usage data ...</property>
<attributes>
<attribute name="style" value="italic"/>
</attributes>
<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="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
......
......@@ -24,9 +24,13 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
import StringIO
import csv
import gobject
import guppy
# guppy will be imported later
#import guppy
import pycam.Plugins
import pycam.Utils.log
_log = pycam.Utils.log.get_logger()
class MemoryAnalyzer(pycam.Plugins.PluginBase):
......@@ -64,6 +68,15 @@ class MemoryAnalyzer(pycam.Plugins.PluginBase):
self.model = self.gui.get_object("MemoryAnalyzerModel")
# window state
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)
return True
......@@ -105,7 +118,9 @@ class MemoryAnalyzer(pycam.Plugins.PluginBase):
gobject.idle_add(self._refresh_data_in_background)
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():
item = (row.name, row.count, row.size / 1024, row.size / row.count)
self.model.append(item)
......
......@@ -223,8 +223,9 @@ class PluginManager(object):
mod = imp.load_module(full_mod_name, mod_file,
mod_filename, mod_desc)
except ImportError:
_log.info("Skipping broken plugin %s" % os.path.join(
directory, filename))
_log.info(("Skipping plugin %s (broken or " + \
"dependencies missing)") % \
os.path.join(directory, filename))
continue
for attr in dir(mod):
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