Commits

Moises Henriquez committed 439b3f2

Added build log viewer for processed jobs

Comments (0)

Files changed (2)

src/vpackager/guitools.py

 __author_email__ = 'moc.liamg@xnl.E0M'[::-1]
 __version__ = '0.1'
 
+class LogDisplay(gtk.Dialog):
+    """ Dialog used to display the build log"""
+    def __init__(self, logpath, parent, title='Build Log'):
+        gtk.Dialog.__init__(self, parent=parent)
+        self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
+        self.body = self.get_content_area()
+        self.logpath = logpath
+        self.set_size_request(600, 400)
+        self.set_has_separator(True)
+        self.body.pack_start(self._get_logview(), True, True, 2)
+        self.set_title(title)
+        self.show_all()
+
+    def _get_logview(self):
+        scrl = gtk.ScrolledWindow()
+        scrl.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+        textview = gtk.TextView()
+        for edge in (gtk.TEXT_WINDOW_LEFT, gtk.TEXT_WINDOW_RIGHT,
+                     gtk.TEXT_WINDOW_TOP, gtk.TEXT_WINDOW_BOTTOM):
+            textview.set_border_window_size(edge, 4)
+        scrl.add(textview)
+        f = open(self.logpath, 'r')
+        data = f.read()
+        f.close()
+        textview.get_buffer().set_text(data)
+
+        return scrl
+
 class TabStrip(gtk.Notebook):
     """Tabstrip used in the main GUI"""
     def __init__(self):
         self.pack_start(img, False, False, 2)
         self.show_all()
 
-
 class TableTree(gtk.TreeView):
     """Generic treeview widget that will be used to display the contents of the
     database tables. Will be used to display both queue and history"""

src/vpackager/viewcontrollers.py

 import dbutils
 import dbviews
 import guitools
+import os
 
 __author__ = 'M0E-lnx'
 __author_email__ = 'moc.liamg@xnl.E0M'[::-1]
 
     def _view_build_log_event(self, widget=None):
         """ Display the build log if it is still present"""
-        dia = guitools.message.Error(
-            text = "Feature not yet available",
-            parent = self._parentwindow)
+        details = self.model.GetTaskDetails(self.view._selectedjob)
+        if not os.path.exists(details['stdout']):
+            dia = guitools.message.Error(
+                parent = self._parentwindow,
+                text = \
+                "Build log is no longer available in the system. " +\
+                "This usually means the file was deleted.",
+                )
+        else:
+            dia = guitools.LogDisplay(
+                title = '%s build log'% details['app'],
+                parent = self._parentwindow,
+                logpath = details['stdout'])
+
         if dia.run():
             return dia.destroy()