Commits

Moises Henriquez committed 2ca6aac

Fixed problems creating slackbuild with user-provided config options and implemented history filtering

Comments (0)

Files changed (5)

src/vpackager/bot.py

             # cd back to the original workdir (just in case)
             os.chdir(os.path.dirname(sbpath))
             # Create build job object
-            job = srcob.buildSlackBuild()
+            #job = srcob.buildSlackBuild()
+            job = srcob.buildSlackBuild(config=job_info['config'])
             # Connect the observer so we can watch the matrix.
             job.observer.add_callback(self.view.PlayOutput)
             # start the job
                 proc.run()
                 while proc._popen_running:
                     time.sleep(1)
-                retval = proc._popen.returncode
+                retval = proc.popen.returncode
 
             # Log the output to a file
             logpath = os.path.join(os.path.dirname(srcob.srclocation),

src/vpackager/buildutils.py

 
         # call the sbbuilder binary
         proc = bottools.Execute(
-            'sbbuilder --package=%s --version=%s --type=%s --build=%s --user=%s --configure_options=%s' %(
+            'sbbuilder --package=%s --version=%s --type=%s --build=%s --user=%s --configure_options="%s"' %(
                 self.app, self.ver, self.builder, buildno, packager, config))
         proc.run()
         if proc.popen.returncode > 0:
 
         return None
 
-    def buildSlackBuild(self):
+    def buildSlackBuild(self, config=""):
         """ Execute the build script generated by sbbuilder"""
+        os.environ['CONFIG_OPTIONS'] = config
         return bottools.Execute('sh %s.SlackBuild'% self.app)
 
     def Extract(self, srcdir=None):
             raise MissingSourcesHomeError
         cm = 'sbbuilder --package=%s --version=%s --type=%s'% (self.app,
                 self.ver, self.builder) + \
-                '--build=%s --user=%s --link=%s --configure_options=%s'% (buildno,
+                '--build=%s --user=%s --link=%s --configure_options="%s"'% (buildno,
                         packager, self.link, config)
         proc = bottools.Execute(cm)
         proc.run()
         return bottools.Execute('installpkg %s'% pkgpath)
 
 
-    def buildSlackBuild(self):
+    def buildSlackBuild(self, config=""):
         """ Execute the build script generated by the class"""
         # Make sure we are at the correct location
         os.chdir(self.srclocation)
+        os.environ['CONFIG_OPTIONS'] = config
         return bottools.Execute('sh %s.SlackBuild'% self.app)
+        #return bottools.Execute('sh %s.SlackBuild'% self.app)

src/vpackager/dbutils.py

         self.close()
         return ret
 
+    def FilterHistory(self, filter):
+        """ Filters the history to show only the items whose result matches
+        the filter"""
+        db, cursor = self._open()
+        if filter is "all":
+            self.close()
+            return self.notify(self.GetHistory(), group='history')
+        elif filter in ('success, Success, successful'):
+            sql = '''select id, app, ver, release, buildstart, buildend,
+            result from history where result="Success"'''
+        elif filter in ('failed', 'Failed'):
+            sql = ''' select id, app, ver, release, buildstart, buildend,
+            result from history where result="Failed"'''
+        else:
+            self.close()
+            return self.notify(self.GetHistory(), group='history')
+        cursor.execute(sql)
+        ret = cursor.fetchall()
+        self.close()
+        return self.notify(ret, group='history')
+
+
     def WipeHistory(self):
         """ Deletes the entire job history. Only use after confirming with the
         user"""

src/vpackager/dbviews.py

     def connect_item(self, item, callback):
         return self.menu_actions[item].connect('activate', callback)
 
-
-
 class QueueView(gtk.VBox):
     """ Job manager container"""
     def __init__(self):
         self.pack_start(bottombar, False, True, 2)
         self._selectedjob = None
 
-    def connect_item(self, item, callback):
-        self.exposed_widgets[item].connect('clicked', callback)
+    def connect_item(self, item, callback, *kwargs):
+        if type(item) is gtk.RadioButton:
+            return self.exposed_widgets[item].connect(
+                'toggled', callback, *kwargs)
+        else:
+            return self.exposed_widgets[item].connect('clicked', callback, *kwargs)
 
     def _get_treeview(self):
         _model = gtk.ListStore(int, str, str, str)
             self.exposed_widgets['about_job']):
             button.set_property('sensitive', self._selectedjob is not None)
 
-
 class HistoryView(QueueView):
     """ History manager tree view """
     def __init__(self):
             stock = gtk.STOCK_INFO, label = 'About Task')
         self.exposed_widgets['wipe_history'] = guitools.vButton(
             stock = gtk.STOCK_DELETE, label='Delete History')
+        filters = []
+        self.exposed_widgets['filter_all'] = gtk.RadioButton(
+            label='All')
+        self.exposed_widgets['filter_successful'] = gtk.RadioButton(
+            group = self.exposed_widgets['filter_all'], label='Successful')
+        self.exposed_widgets['filter_failed'] = gtk.RadioButton(
+            group = self.exposed_widgets['filter_all'], label='Failed')
+        lb = gtk.Label('Filter: ')
 
-        for button in self.exposed_widgets.values():
-            box.pack_start(button, False, False, 2)
+        box.pack_start(self.exposed_widgets['wipe_history'], False, False, 2)
+        box.pack_end(self.exposed_widgets['filter_failed'], False, False, 2)
+        box.pack_end(self.exposed_widgets['filter_successful'], False, False, 2)
+        box.pack_end(self.exposed_widgets['filter_all'], False, False, 2)
+        box.pack_end(lb, False, False, False)
 
         return box
 

src/vpackager/viewcontrollers.py

             ret = dia.destroy
         return ret
 
-
-
 class HistoryController(QueueController):
     """ Controller for the history view """
     def __init__(self, model, view):
     def refresh_view(self):
         return self.model.RefreshHistory()
 
+    def apply_filter(self, widget=None, filter=None):
+	return self.model.FilterHistory(filter)
+
     def connect_signals(self):
         # Connect buttons
         self.view.connect_item('about_task', self._about_task_event)
         self.view.connect_item('wipe_history', self._wipe_history_event)
+	self.view.connect_item('filter_all', self.apply_filter, 'all')
+	self.view.connect_item('filter_successful', self.apply_filter,
+			       'successful')
+	self.view.connect_item('filter_failed', self.apply_filter, 'failed')
         # Connect menu items.
         self.view.rc_menu.connect_item('about_job', self._about_task_event)
         self.view.rc_menu.connect_item('rebuild_job', self._rebuild_job_event)
                 release = dia.release,
                 _type = dia.srctype,
                 install = dia.install,
+		doinstURI = dia.doinstURI,
+		config_options = dia.config_options,
                 patches = ','.join(dia.patches))
         else:
             ret = None
     view = dbviews.HistoryView()
     control = HistoryController(model = model,
                               view = view)
-    control.Run()
+    control.Run()