summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2013-09-25 23:46:49 +0200
committerJan Pokorný <jpokorny@redhat.com>2013-09-25 23:46:49 +0200
commit5f7ac45e4dfe4849338f4a8c39652266689e3eea (patch)
treeea3891a17ca29543a68abf1a7f6a58f7a715939b
parentd4c95ff1132fd67a9c00aaddc01ca5ba0964f7e0 (diff)
downloadcluster-overview-5f7ac45e4dfe4849338f4a8c39652266689e3eea.zip
cluster-overview-5f7ac45e4dfe4849338f4a8c39652266689e3eea.tar.gz
cluster-overview-5f7ac45e4dfe4849338f4a8c39652266689e3eea.tar.xz
Expose tracked info upon entity click via tooltip + stdout text
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rw-r--r--lib.py42
-rw-r--r--lib_cman.py58
-rw-r--r--lib_shared.py8
3 files changed, 82 insertions, 26 deletions
diff --git a/lib.py b/lib.py
index d2025b0..e88fad7 100644
--- a/lib.py
+++ b/lib.py
@@ -66,6 +66,7 @@ class LibMeta(type):
for akey, avalue in getattr(cls, 'defaults', {}).iteritems():
kwargs.setdefault(akey, avalue)
+ kwargs['URL'] = "class://" + self.__class__.__name__
old_init(self, *args, **kwargs)
super(cls, self).__init__(*args, **kwargs)
@@ -133,6 +134,7 @@ def gen_graph(graph, blacklist=(), **kwargs):
def xdot_graph(*args, **kwargs):
import gtk
import gtk.gdk
+ import pango
try:
path[:] = [expanduser('~/wrkspc/goss-medium/jrfonseca.xdot')] + path[:]
import xdot
@@ -140,6 +142,44 @@ def xdot_graph(*args, **kwargs):
print 'missing xdot; use "pip install xdot" or equivalent'
raise
+ class LibDotWidget(xdot.DotWidget):
+ """Overriden so as to serve our info tooltip purpose"""
+ def __init__(self, *args, **kwargs):
+ super(LibDotWidget, self).__init__(*args, **kwargs)
+ self.connect('leave-notify-event',
+ lambda self, *args: self.set_tooltip_markup(None))
+
+ def on_click(self, element, event):
+ if element is None or not element.url:
+ return False
+ # create the resulting markup
+ print element.url
+ cls = REGISTRY[element.url.split('class://', 1)[1]]
+ markup = ""
+ if hasattr(cls, 'summary'):
+ markup += "<b>" + cls.summary + "</b>\n\n"
+ if hasattr(cls, 'web'):
+ markup += "<u>" + cls.web + "</u>\n\n"
+ if hasattr(cls, 'repo'):
+ markup += "repository:\n"
+ for name, value in cls.repo.iteritems():
+ markup += "* " + name + ": <u>" + value + "</u>\n"
+ markup += '\n'
+ if hasattr(cls, 'man'):
+ markup += "man:\n"
+ for item in cls.man:
+ markup += "* <i>" + item + "</i>\n"
+ markup += '\n'
+ if hasattr(cls, 'ids'):
+ markup += "identifiers:\n"
+ for name, value in cls.ids.iteritems():
+ markup += "* " + name + ": <i>" + value + "</i>\n"
+ markup += '\n'
+ markup = markup.rstrip('\n')
+ print pango.parse_markup(markup)[1].join(2 * ['\n' + 3*'=' + '\n'])
+ self.set_tooltip_markup(markup)
+ return False
+
class LibDotWindow(xdot.DotWindow):
# heavily inspired from http://zetcode.com/gui/pygtk/menus/
def on_toggle_item(self, widget):
@@ -186,7 +226,7 @@ def xdot_graph(*args, **kwargs):
self._args = args
self._kwargs = kwargs
self._can_change = True
- super(LibDotWindow, self).__init__()
+ super(LibDotWindow, self).__init__(LibDotWidget())
dotcode = gen_graph(*args, **kwargs).to_string()
title = dotcode[dotcode.find('digraph', 0, 512) + len('digraph')
:
diff --git a/lib_cman.py b/lib_cman.py
index 198ca34..60a0e63 100644
--- a/lib_cman.py
+++ b/lib_cman.py
@@ -64,9 +64,11 @@ class CmanCmanTool(Executable):
man = [
'cman_tool(8)'
]
- srpm = 'cluster'
- rpm = 'cman'
- rhbz = 'cluster'
+ ids = dict(
+ srpm='cluster',
+ rpm='cman',
+ rhbz='cluster',
+ )
class CmanRicci(Daemon):
@@ -83,9 +85,11 @@ class CmanRicci(Daemon):
man = [
'ricci(8)'
]
- srpm = 'ricci'
- rpm = 'ricci'
- rhbz = 'ricci'
+ ids = dict(
+ srpm='ricci',
+ rpm='ricci',
+ rhbz='ricci',
+ )
class CmanCcs(Executable):
@@ -103,9 +107,11 @@ class CmanCcs(Executable):
man = [
'ccs(8)'
]
- srpm = 'ricci'
- rpm = 'ccs'
- rhbz = 'ricci'
+ ids = dict(
+ srpm='ricci',
+ rpm='ccs',
+ rhbz='ricci',
+ )
class CmanCcsSync(Executable):
@@ -121,9 +127,11 @@ class CmanCcsSync(Executable):
man = [
'ccs_sync(8)'
]
- srpm = 'ricci'
- rpm = 'ricci'
- rhbz = 'ricci'
+ ids = dict(
+ srpm='ricci',
+ rpm='ricci',
+ rhbz='ricci',
+ )
class CmanLuci(Daemon):
@@ -139,9 +147,11 @@ class CmanLuci(Daemon):
web='https://git.fedorahosted.org/cgit/luci.git',
ml='https://lists.fedorahosted.org/mailman/listinfo/luci-commits',
)
- srpm = 'luci'
- rpm = 'luci'
- rhbz = 'luci'
+ ids = dict(
+ srpm='luci',
+ rpm='luci',
+ rhbz='luci',
+ )
class CmanModclusterd(Daemon):
@@ -154,12 +164,14 @@ class CmanModclusterd(Daemon):
git='git://git.fedorahosted.org/git/conga.git',
web='https://git.fedorahosted.org/cgit/conga.git',
)
- srpm = 'clustermon'
- rpm = 'modcluster'
- rhbz = 'clustermon'
+ ids = dict(
+ srpm='clustermon',
+ rpm='modcluster',
+ rhbz='clustermon',
+ )
-class CmanModcluster(Executable):
+class CmanModcluster(Executable):
defaults = dict((
LABEL('modcluster'),
))
@@ -169,6 +181,8 @@ class CmanModcluster(Executable):
git='git://git.fedorahosted.org/git/conga.git',
web='https://git.fedorahosted.org/cgit/conga.git',
)
- srpm = 'clustermon'
- rpm = 'modcluster'
- rhbz = 'clustermon'
+ ids = dict(
+ srpm='clustermon',
+ rpm='modcluster',
+ rhbz='clustermon',
+ )
diff --git a/lib_shared.py b/lib_shared.py
index 55bf527..e58b8d9 100644
--- a/lib_shared.py
+++ b/lib_shared.py
@@ -46,6 +46,8 @@ class SharedFenceVirt(Executable):
'fence_virt(8)',
'fence_xvm(8)',
]
- srpm = 'fence-virt'
- rpm = 'fence-virt'
- rhbz = 'fence-virt'
+ ids = dict(
+ srpm='fence-virt',
+ rpm='fence-virt',
+ rhbz='fence-virt',
+ )