From: Mark Williamson Subject: [PATCH] [ANNOUNCE] xsview - a graphical Xenstore tool Date: Sat, 1 Sep 2007 00:31:42 +0100 Message-ID: <200709010031.43174.mark.williamson@cl.cam.ac.uk> Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_fTK2GtPuZuiE7pe" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --Boundary-00=_fTK2GtPuZuiE7pe Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline I got tired of viewing the output of xenstore-ls with less when trying to debug things, so I knocked together a simple little graphical app using PyQt which displays the contents of Xenstore as a tree. It should apply to xen-unstable. It has to be run out of tools/xsview/ because I've not yet added an install operation. Right now you can view the XenStore tree and get / set values in there. At some point in the future I'll probably add code for creating / deleting nodes in the tree, and possibly other things. Should be useful for testing and / or debugging. Hope that it's useful to folks, but it's not very thoroughly tested so please don't blame me if it makes your computer explode / causes gerbils to fall over. Cheers, Mark -- Dave: Just a question. What use is a unicyle with no seat? And no pedals! Mark: To answer a question with a question: What use is a skateboard? Dave: Skateboards have wheels. Mark: My wheel has a wheel! --Boundary-00=_fTK2GtPuZuiE7pe Content-Type: all/allfiles; name="xsview.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xsview.patch" diff -r 256160ff19b7 -r 30f60f9cedc8 tools/xsview/xsview --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/xsview/xsview Thu Aug 30 18:55:12 2007 +0100 @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +import sys +from xsviewer import * +from qt import * + +def main(args): + app = QApplication(args) + mainwin = XSViewer(app) + mainwin.show() + app.connect(app, SIGNAL("lastWindowClosed()"), + app, SLOT("quit()")) + app.exec_loop() + +main(sys.argv) + + diff -r 256160ff19b7 -r 30f60f9cedc8 tools/xsview/xsviewer.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/xsview/xsviewer.py Thu Aug 30 18:55:12 2007 +0100 @@ -0,0 +1,87 @@ +from qt import * + +import xen.lowlevel.xs + +class XSViewer(QMainWindow): + + def __init__(self, app): + apply(QMainWindow.__init__, (self,)) + + self.setCaption("XenStore Viewer") + + self.refresh = QAction(self, "Refresh") + self.refresh.setText("Refresh") + self.connect(self.refresh, SIGNAL("activated()"), + self.do_refresh) + + self.file_menu = QPopupMenu(self) + self.refresh.addTo(self.file_menu) + + self.menubar = QMenuBar(self) + self.menubar.insertItem("&File", self.file_menu) + + + self.splitter = QSplitter(self) + self.setCentralWidget(self.splitter) + + self.xs_tree = QListView(self.splitter) + self.xs_tree.addColumn("item") + self.xs_tree.setRootIsDecorated(1) + self.xs_tree.connect(self.xs_tree, SIGNAL("selectionChanged(QListViewItem*)"), self.showValue) + + self.info_box = QHBox(self.splitter) + self.info = QLineEdit(self.info_box) + self.setval = QPushButton(self.info_box) + self.setval.setText("Set") + self.setval.connect(self.setval, SIGNAL("clicked()"), self.setValue) + + self.xs_handle = xen.lowlevel.xs.xs() + + self.showtree() + + + def showtree(self): + xstransact = self.xs_handle.transaction_start() + ents = self.xs_handle.ls(xstransact, "/") + for e in ents: + i = QListViewItem(self.xs_tree, e) + i.full_path = "/" + e + self.walktree(xstransact, i.full_path, i) + self.xs_handle.transaction_end(xstransact) + + def walktree(self, trans, nodepath, parent_widget): + + print "Walking nodepath %s" % nodepath + + ents = self.xs_handle.ls(trans, nodepath) + if ents == None: + print "Terminating walk" + return + + for e in ents: + i = QListViewItem(parent_widget, e) + i.full_path = nodepath + "/" + e + self.walktree(trans, i.full_path, i) + + + def showValue(self, item): + trans = self.xs_handle.transaction_start() + val = self.xs_handle.read(trans, item.full_path) + self.info.setText(val) + self.xs_handle.transaction_end(trans) + + + def setValue(self): + trans = self.xs_handle.transaction_start() + item = self.xs_tree.currentItem() + newval = str(self.info.text()) + + self.xs_handle.write(trans, item.full_path, newval) + + self.xs_handle.transaction_end(trans) + + + def do_refresh(self): + self.xs_tree.clear() + self.info.clear() + self.showtree() --Boundary-00=_fTK2GtPuZuiE7pe Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-00=_fTK2GtPuZuiE7pe--