Moises Henriquez avatar Moises Henriquez committed 0703e58

Adding informational dialog about completed job

Comments (0)

Files changed (3)

src/vpackager/dbutils.py

     descURI text,
     release text,
     type text,
+    patches text,
     buildstart text,
     buildend text,
     stdout text,
         return ret[0]
     return None
 
+def GetTaskDetails(jobid):
+    """ Returns all information from the job history about jobid"""
+    db = sqlite3.connect(dbpath)
+    c = db.cursor()
+    c.execute('select * from history where id=?',jobid)
+    try:
+        ret = c.next()
+    except StopIteration:
+        ret = None
+    c.close()
+    db.close()
+    return ret
+
 def GetNextJob():
     """ Find the next job in line to be built"""
     db = sqlite3.connect(dbpath)
     db.close()
     return ret
 
+def WipeHistory():
+    """ Delete the entire build history """
+    db = sqlite3.connect(dbpath)
+    c = db.cursor()
+    ret = c.execute('delete from history where id > 0')
+    c.close()
+    db.close()
+    return
 
+

src/vpackager/guitools.py

         info['patches'] = dbutils.GetJobProp(jobid, 'patches')
         return info
 
+class AboutTask(gtk.Dialog):
+    """Info dialog used to diaplsy details about a performed job. Similar to
+    AboutJob, but the information for this one comes from the job history (as
+    in past jobs) rather than the queue (to-do list)"""
+    def __init__(self, jobid, title='Task Details', parent=None):
+        gtk.Dialog.__init__(self, parent=parent)
+        self.set_title(title)
+        self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
+        self.body = self.get_content_area()
+        topbox = gtk.HBox()
+        img = gtk.Image()
+        img.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
+        lbl = gtk.Label()
+        lbl.set_markup('<b>Build task details</b>')
+        topbox.pack_start(img, False, False, 2)
+        topbox.pack_start(lbl, True, True, 2)
+        lbl.set_property('xalign', 0.0)
+        self.body.pack_start(topbox, False, True, 4)
+
+        self.body.pack_start(self._get_tree(), True, True, 2)
+        self.set_size_request(500,400)
+
+        self.show_all()
+
+    def _get_tree(self):
+        scroll = gtk.ScrolledWindow()
+        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+        mod = gtk.ListStore(str, str)
+        tree = gtk.TreeView(model=mod)
+        col0 = gtk.TreeviewColumn()
+        col1 = gtk.TreeviewColumn()
+        cr0 = gtk.CellRendererText()
+        cr1 = gtk.CellRendererText()
+        col0.pack_start(cr0)
+        col1.pack_start(cr1)
+        col0.add_attribute(cr0, 'markup', 0)
+        col1.add_attribute(cr1, 'markup', 1)
+        tree.set_headers_visible(False)
+
+        # Get the data we need
+        jobid = self._selected_jobid
+        (_id, app, ver, src, desc, rel,
+                _type, patches, buildstart,
+                buildend, stdout, result) = dbutils.GetTaskDetails(jobid)
+        # Add the data to the model
+        mod.append(['Job ID', _id])
+        mod.append(['Application', app])
+        mod.append(['Version', ver])
+        mod.append(['Package Release', rel])
+        mod.append(['Source URI', src])
+        mod.append(['Description URI', desc])
+        mod.append(['Source type', _type])
+        mod.append(['Build started', buildstart])
+        mod.append(['Build ended', buildend])
+        mod.append(['Build result', result])
+        mod.append(['Output log', stdout])
+        lpatches = patches.split(',')
+        mod.append(['Patches applied', lpatches[0]])
+        for x in range(1, len(lpatches)):
+            mod.append(['',lpatches[x]])
+
+
+
+        return scroll
+
+
+
+
 class About(gtk.AboutDialog):
     """ About dialog for vpackager"""
     def __init__(self):

src/vpackager/historymanager.py

 
 import gtk
 import dbutils
+import guitools
+import message
 
 __author__ = 'M0E-lnx'
 __author_email__ = 'moc.liamg@xnl.E0M'[::-1]
     job history'''
     def __init__(self):
         gtk.VBox.__init__(self)
+        self._selected_jobid = None
         self.model = gtk.ListStore(
                 int, str, str, str, str, str)
         self.pack_start(gtk.Label('Job History'), False, True, 2)
                 gtk.POLICY_AUTOMATIC)
         self.pack_start(scroll, True, True, 2)
         scroll.add(self._get_tree())
-        #self.pack_start(self._get_tree())
+
         self.show_all()
+        self.pack_start(self._get_bottom_toolbar(), False, True, 2)
         self._refresh_history_display()
+        self.btWipeHistory.set_property('sensitive',
+                len(dbutils.GetHistory()) > 0)
 
+    def _task_details_event(self, widget=None):
+        pass
+
+    def _get_bottom_toolbar(self):
+        '''toolbar at the bottom of the job history'''
+        box = gtk.HBox()
+        btWipe = guitools.vButton(stock=gtk.STOCK_DELETE,
+                label='Erase History')
+        self.btWipeHistory = btWipe
+        self.btTaskDetails = guitools.vButton(stock=gtk.STOCK_INFO,
+                label='Build Details')
+        self.btTaskDetails.connect('clicked', self._task_details_event)
+        self.btWipeHistory.connect('clicked', self._do_wipe_history)
+        btWipe.connect('clicked', self._do_wipe_history)
+        box.pack_start(btWipe, False, False, 2)
+        box.pack_start(self.btTaskDetails, False, False, 2)
+
+        return box
+
+    def _tree_click_event(self, tree=None):
+        """ Events triggered by clicking on the treeview"""
+        sel = tree.get_selection()
+        (model, _iter) = sel.get_selected()
+        selrow = tree.get_model()[_iter][0]
+        self._selected_jobid = selrow
+        self.btTaskDetails.set_property('sensitive',
+                self._selected_jobid != None)
 
     def _get_tree(self):
+        """ Create the treeview that displays the history"""
         self.tree = gtk.TreeView(model = self.model)
         i = 0
         for field in ('ID','Application', 'Version',
                 'Build Start', 'Build End', 'Result'):
-        #for field in ('ID', 'Package', 'Version', 'Source URI', 'Description',
-        #   'Release','Type', 'Build Start', 'Build End', 'Output', 'Result'):
             col = gtk.TreeViewColumn(field)
             col.set_resizable(True)
             crt = gtk.CellRendererText()
             col.add_attribute(crt, 'text', i)
             self.tree.append_column(col)
             i += 1
+        self.tree.connect('cursor-changed', self._tree_click_event)
         return self.tree
 
+    def _do_wipe_history(self, widget=None):
+        """ Wipe the entire history """
+        dia = message.Question(parent = self.parent,
+                text='This will erase you entire build history. \n' + \
+                        'Are you sure you want to continue?')
+        res = dia.run()
+        dia.hide()
+        if dia.response == gtk.RESPONSE_YES:
+            dbutils.WipeHistory()
+        dia.destroy()
+        return self._refresh_history_display()
+
     def _refresh_history_display(self):
         self.tree.set_model(
                 gtk.ListStore(int,str, str, str, str, str))
         lst = dbutils.GetHistory()
         for entry in lst:
             self.tree.get_model().append(entry)
+        self.btWipeHistory.set_property('sensitive', (len(lst) > 0))
+        self.btTaskDetails.set_property('sensitive',
+                self._selected_jobid != None)
 
+if __name__ == '__main__':
+    w = gtk.Window(gtk.WINDOW_TOPLEVEL)
+    w.add(Main())
+    w.set_size_request(500,300)
+    w.connect('destroy', gtk.main_quit)
+    w.show_all()
+    gtk.gdk.threads_init()
+    gtk.gdk.threads_enter()
+    gtk.main()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.