WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xsview: a xenstore viewer written in PyQT

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xsview: a xenstore viewer written in PyQT.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 04 Oct 2007 17:41:48 -0700
Delivery-date: Thu, 04 Oct 2007 18:31:39 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1191502371 -3600
# Node ID 56b543dd0da23176662d1a50efdbb3222f1e64a1
# Parent  062fe1c7b09f1b3dc906ed6718dea8cd72c5416b
xsview: a xenstore viewer written in PyQT.
From: Mark Williamson <mark.williamson@xxxxxxxxxxxx>
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 tools/misc/Makefile                 |    2 
 tools/misc/xsview                   |   11 ++
 tools/python/setup.py               |    1 
 tools/python/xen/xsview/main.py     |   10 ++
 tools/python/xen/xsview/xsviewer.py |  168 ++++++++++++++++++++++++++++++++++++
 5 files changed, 191 insertions(+), 1 deletion(-)

diff -r 062fe1c7b09f -r 56b543dd0da2 tools/misc/Makefile
--- a/tools/misc/Makefile       Thu Oct 04 10:31:44 2007 +0100
+++ b/tools/misc/Makefile       Thu Oct 04 13:52:51 2007 +0100
@@ -14,7 +14,7 @@ TARGETS := $(TARGETS-y)
 TARGETS := $(TARGETS-y)
 
 INSTALL_BIN  = $(TARGETS) xencons
-INSTALL_SBIN = netfix xm xen-bugtool xen-python-path xend xenperf
+INSTALL_SBIN = netfix xm xen-bugtool xen-python-path xend xenperf xsview
 
 .PHONY: all
 all: build
diff -r 062fe1c7b09f -r 56b543dd0da2 tools/misc/xsview
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/misc/xsview Thu Oct 04 13:52:51 2007 +0100
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+
+import sys
+
+sys.path.append('/usr/lib/python')
+sys.path.append('/usr/lib64/python')
+from xen.xsview import main
+
+main.main(sys.argv)
+
+
diff -r 062fe1c7b09f -r 56b543dd0da2 tools/python/setup.py
--- a/tools/python/setup.py     Thu Oct 04 10:31:44 2007 +0100
+++ b/tools/python/setup.py     Thu Oct 04 13:52:51 2007 +0100
@@ -79,6 +79,7 @@ setup(name            = 'xen',
                          'xen.xm',
                          'xen.web',
                          'xen.sv',
+                         'xen.xsview',
 
                          'xen.xend.tests',
                          'xen.xend.server.tests',
diff -r 062fe1c7b09f -r 56b543dd0da2 tools/python/xen/xsview/main.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/python/xen/xsview/main.py   Thu Oct 04 13:52:51 2007 +0100
@@ -0,0 +1,10 @@
+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()
diff -r 062fe1c7b09f -r 56b543dd0da2 tools/python/xen/xsview/xsviewer.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/python/xen/xsview/xsviewer.py       Thu Oct 04 13:52:51 2007 +0100
@@ -0,0 +1,168 @@
+from qt import *
+
+import xen.lowlevel.xs
+
+class XSViewer(QMainWindow):
+    
+    def __init__(self, app):
+        apply(QMainWindow.__init__, (self,))
+        
+        self.setCaption('XenStore Viewer')
+
+        self.new_node = QAction(self, 'New Node')
+        self.new_node.setText('New Node...')
+        self.connect(self.new_node, SIGNAL('activated()'),
+                     self.do_new_node)
+        
+        self.rm_node = QAction(self, 'Remove Node')
+        self.rm_node.setText('Remove Node')
+        self.connect(self.rm_node, SIGNAL('activated()'),
+                     self.do_rm_node)
+
+        self.refresh = QAction(self, 'Refresh')
+        self.refresh.setText('Refresh')
+        self.connect(self.refresh, SIGNAL('activated()'),
+                     self.do_refresh)
+ 
+        self.file_menu = QPopupMenu(self)
+        self.new_node.addTo(self.file_menu)
+        self.rm_node.addTo(self.file_menu)
+        self.refresh.addTo(self.file_menu)
+
+
+        self.about = QAction(self, 'About')
+        self.about.setText('About...')
+        self.connect(self.about, SIGNAL('activated()'),
+                     self.do_about)
+
+        self.help_menu = QPopupMenu(self)
+        self.about.addTo(self.help_menu)
+
+        self.menubar = QMenuBar(self)
+        self.menubar.insertItem('&File', self.file_menu)
+        self.menubar.insertItem('&Help', self.help_menu)
+
+        self.vbox = QVBox(self)
+        self.setCentralWidget(self.vbox)
+
+        self.xs_tree = QListView(self.vbox)
+        self.xs_tree.addColumn('Key')
+        self.xs_tree.setRootIsDecorated(1)
+        self.xs_tree.connect(self.xs_tree, 
SIGNAL('selectionChanged(QListViewItem*)'), self.showValue)
+
+        self.info_box = QHBox(self.vbox)
+        self.info_box.setMargin(2)
+        self.info_box.setSpacing(2)
+        self.info_label = QLabel(self.info_box)
+        self.info_label.setText('Value')
+        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()
+        self.walktree(xstransact, '/', '/', self.xs_tree)
+        self.xs_handle.transaction_end(xstransact)
+
+    def walktree(self, trans, node, subdir_prepend, parent_widget):
+
+        ents = self.xs_handle.ls(trans, node)
+        if ents == None:
+            return
+
+        for e in ents:
+            i = QListViewItem(parent_widget, e)
+            i.full_path = subdir_prepend + e
+            self.walktree(trans, i.full_path, 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()
+
+    def do_new_node(self):
+        dia = QDialog(self)
+        dia.setCaption('Create new node')
+
+        vbox = QVBox(dia)
+
+        setting_hbox = QHBox(vbox)
+        
+        path_label = QLabel(setting_hbox)
+        path_label.setText('Node path')
+        path = QLineEdit(setting_hbox)
+        
+        value_label = QLabel(setting_hbox)
+        value_label.setText('Node value')
+        val = QLineEdit(setting_hbox)
+
+        button_hbox = QHBox(vbox)
+
+        set = QPushButton(button_hbox)
+        set.setText('Set')
+        self.connect(set, SIGNAL('clicked()'), dia, SLOT('accept()'))
+
+        cancel = QPushButton(button_hbox)
+        cancel.setText('Cancel')
+        self.connect(cancel, SIGNAL('clicked()'), dia, SLOT('reject()'))
+
+        setting_hbox.adjustSize()
+        button_hbox.adjustSize()
+        vbox.adjustSize()
+
+        if dia.exec_loop() == QDialog.Accepted:
+            trans = self.xs_handle.transaction_start()
+            self.xs_handle.write(trans, str(path.text()), str(val.text()))
+            
+            self.xs_handle.transaction_end(trans)
+
+            self.do_refresh()
+        
+        # nothing to set.
+
+    def do_rm_node(self):
+        trans = self.xs_handle.transaction_start()
+        item = self.xs_tree.currentItem()
+        newval = str(self.info.text())
+
+        self.xs_handle.rm(trans, item.full_path)
+
+        self.xs_handle.transaction_end(trans)
+
+        self.do_refresh()
+
+    def do_about(self):
+        about_dia = QMessageBox(self)
+        about_dia.setIcon(QMessageBox.Information)
+
+        about_dia.setCaption('About XenStore Viewer')
+        about_dia.setText('XenStore Viewer\n'
+                          'by Mark Williamson <mark.williamson@xxxxxxxxxxxx>')
+
+        about_dia.exec_loop()
+        
+        

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xsview: a xenstore viewer written in PyQT., Xen patchbot-unstable <=