[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [augeas-devel] Simple pyGTK Augeas viewer

On Thu, 2009-03-12 at 22:32 -0400, David Malcolm wrote:
> On Tue, 2009-03-10 at 17:11 -0700, David Lutterkort wrote:

> > But even with that, it still dies 3 out of 4 times somewhere deep in the
> > guts of python - but at leasy I've seen the UI ;)

Turns out to be a threading problem. The attached patch protects all
accesses to Augeas with a lock (there must be more elegant ways to do

> Attached is an updated version, with the above change, plus a right-hand
> pane which tried to show you the file corresponding to the
> currently-selected node.

Nice. It would be really nice if we could show where exactly in the file
you are with a certain subnode/tree. I am just not sure how to relay
this information without cluttering the public API too much, since it's
only needed for this one use. It would either require that I keep two or
four additional ints for each tree node (start/end of where the label
was found and start/end for the value in the file), or addition of some
API that would reparse the file and return this information about each

Do you have any plans what you want to use augview for ?


diff --git a/augview.py.orig b/augview.py
index 128cc8a..9549adc 100644
--- a/augview.py.orig
+++ b/augview.py
@@ -3,12 +3,32 @@ import pygtk
 import gtk
 import os
+import threading
 def add_with_scrolling(parent, child):
     sw = gtk.ScrolledWindow()
+class AugeasSynced:
+    def __init__(self):
+        self.lock = threading.Lock()
+        self.aug = Augeas()
+    def get(self, path):
+        self.lock.acquire()
+        try:
+            return self.aug.get(path)
+        finally:
+            self.lock.release()
+    def match(self, path):
+        self.lock.acquire()
+        try:
+            return self.aug.match(path);
+        finally:
+            self.lock.release()
 class AugeasViewer:
     def delete_event(self, widget, event, data=None):
@@ -26,7 +46,7 @@ class AugeasViewer:
             self.populate_tree_store(path, iter),
     def __init__(self):
-        self.aug = Augeas()
+        self.aug = AugeasSynced()
         self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
         self.window.set_title("Augeas viewer")

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]