Initialise builder state and display status in main window.
authorTim Potter <tpot@hp.com>
Mon, 7 Apr 2008 01:48:41 +0000 (11:48 +1000)
committerTim Potter <tpot@hp.com>
Mon, 7 Apr 2008 01:48:41 +0000 (11:48 +1000)
gbuildbotclient

index d0536c8..d94b8b0 100755 (executable)
@@ -65,8 +65,10 @@ class BuildbotClient(pb.Referenceable):
 
 class App:
 
-    COL_BUILDER = 0
-    COL_BUILDER_NAME = 1
+    COL_BUILDER = 0             # PYOBJECT: RemoteBuilder objecr
+    COL_BUILDER_STATE = 1       # PYOBJECT: result of builder.getState() 
+    COL_BUILDER_NAME = 2        # str: Name of builder
+    COL_BUILDER_STATUS = 3      # str: Current status
 
     def __init__(self, host, port, username, password):
 
@@ -81,8 +83,10 @@ class App:
         self.win = self.xml.get_widget('toplevel')
         self.win.connect('destroy', gtk.main_quit)
 
-        self.model = gtk.ListStore(gobject.TYPE_PYOBJECT, str)
-        self.model.set_sort_column_id(1, gtk.SORT_ASCENDING)
+        self.model = gtk.ListStore(
+            gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT, str, str)
+
+        self.model.set_sort_column_id(2, gtk.SORT_ASCENDING)
 
         view = gtk.TreeView(self.model)
 
@@ -90,6 +94,10 @@ class App:
             gtk.TreeViewColumn('Name', gtk.CellRendererText(), 
                                text = self.COL_BUILDER_NAME))
 
+        view.append_column(
+            gtk.TreeViewColumn('State', gtk.CellRendererText(),
+                               text = self.COL_BUILDER_STATUS))
+
         view.show()
 
         scrolledwindow = self.xml.get_widget('builders_scrolledwindow')
@@ -98,7 +106,7 @@ class App:
 
         self.win.show()
 
-        # Fetch list of 
+        # Initialise model with list of builders
 
         d = self.client.connect(host, port, username, password)
         d.addCallback(self._initModel)
@@ -109,9 +117,19 @@ class App:
         # and add (builder, name) tuple to the model.
 
         def addBuilderAndName(builder, name):
+
             iter = self.model.append()
+
             self.model.set_value(iter, self.COL_BUILDER, builder)
             self.model.set_value(iter, self.COL_BUILDER_NAME, name)
+            
+            # Fetch state of builder and initialise state and status
+
+            def setStateAndStatus(state):
+                self.model.set_value(iter, self.COL_BUILDER_STATE, state)
+                self.model.set_value(iter, self.COL_BUILDER_STATUS, state[0])
+
+            d = builder.callRemote('getState').addCallback(setStateAndStatus)
 
         self.client.callRemote('getBuilderNames').addCallback(
             lambda names: