bitbake: hob: add a progress indicator when you select 'view log'

- created a new file named "hobthreads.py", defining a thread
for opening the log file in a subprocess using subprocess module;
in the future I think we will add some other threads here, to
implement some other performance issues
- on "builddetailspage", "packageselectionpage" and "imagedetailspage"
I have changed the manner for opening the log file; it uses the thread
to open the file, and on main thread it creates a dialog to show a
progress bar, which pulses till the file is open
- this was added because when the log file is big, it takes time to
be opened; on the dialog you can use "Cancel" button to terminate the
process initiated to open the file

[YOCTO #2997]
(Bitbake rev: 165362a63f085991b6bab63ab90a0c7b9bf6b784)

Signed-off-by: Cristiana Voicu <cristiana.voicu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Cristiana Voicu 2012-10-25 13:36:23 +03:00 committed by Richard Purdie
parent e281bb3e35
commit a9c563b1b5
5 changed files with 136 additions and 3 deletions

View File

@ -30,6 +30,8 @@ from bb.ui.crumbs.runningbuild import RunningBuildTreeView
from bb.ui.crumbs.runningbuild import BuildFailureTreeView from bb.ui.crumbs.runningbuild import BuildFailureTreeView
from bb.ui.crumbs.hobpages import HobPage from bb.ui.crumbs.hobpages import HobPage
from bb.ui.crumbs.hobcolor import HobColors from bb.ui.crumbs.hobcolor import HobColors
from bb.ui.crumbs.hobthreads import OpeningLogThread
from bb.ui.crumbs.hig import OpeningLogDialog
class BuildConfigurationTreeView(gtk.TreeView): class BuildConfigurationTreeView(gtk.TreeView):
def __init__ (self): def __init__ (self):
@ -404,7 +406,18 @@ class BuildDetailsPage (HobPage):
def open_log_button_clicked_cb(self, button, log_file): def open_log_button_clicked_cb(self, button, log_file):
if log_file: if log_file:
os.system("xdg-open /%s" % log_file) self.stop = False
dialog = OpeningLogDialog(title = "Opening Log",
parent = None,
flags = gtk.DIALOG_MODAL
| gtk.DIALOG_DESTROY_WITH_PARENT
| gtk.DIALOG_NO_SEPARATOR)
#create a thread to open log file
background = OpeningLogThread(dialog, log_file, self)
background.start()
response = dialog.run()
self.stop = True
background.join()
def failure_activate_file_bug_link_cb(self, button): def failure_activate_file_bug_link_cb(self, button):
button.child.emit('activate-link', "http://bugzilla.yoctoproject.org") button.child.emit('activate-link', "http://bugzilla.yoctoproject.org")

View File

@ -1855,6 +1855,9 @@ class ImageSelectionDialog (CrumbsDialog):
break break
iter = self.image_store.iter_next(iter) iter = self.image_store.iter_next(iter)
#
# ProxyDetailsDialog
#
class ProxyDetailsDialog (CrumbsDialog): class ProxyDetailsDialog (CrumbsDialog):
def __init__(self, title, user, passwd, parent, flags, buttons=None): def __init__(self, title, user, passwd, parent, flags, buttons=None):
@ -1914,3 +1917,42 @@ class ProxyDetailsDialog (CrumbsDialog):
else: else:
self.user = None self.user = None
self.passwd = None self.passwd = None
#
# OpeningLogDialog
#
class OpeningLogDialog (CrumbsDialog):
def __init__(self, title, parent, flags, buttons=None):
super(OpeningLogDialog, self).__init__(title, parent, flags, buttons)
self.running = False
# create visual elements on the dialog
self.create_visual_elements()
def start(self):
if not self.running:
self.running = True
gobject.timeout_add(100, self.pulse)
def pulse(self):
self.progress_bar.pulse()
return self.running
def create_visual_elements(self):
hbox = gtk.HBox(False, 12)
self.user_label = gtk.Label("The log will open in a text editor")
hbox.pack_start(self.user_label, expand=False, fill=False)
self.vbox.pack_start(hbox, expand=False, fill=False)
hbox = gtk.HBox(False, 12)
# Progress bar
self.progress_bar = HobProgressBar()
hbox.pack_start(self.progress_bar)
self.start()
self.vbox.pack_start(hbox, expand=False, fill=False)
button = self.add_button("Cancel", gtk.RESPONSE_CANCEL)
HobAltButton.style_button(button)
self.show_all()

View File

@ -0,0 +1,51 @@
#!/usr/bin/env python
#
# BitBake Graphical GTK User Interface
#
# Copyright (C) 2012 Intel Corporation
#
# Authored by Cristiana Voicu <cristiana.voicu@intel.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import threading
import gtk
import subprocess
#
# OpeningLogThread
#
class OpeningLogThread(threading.Thread):
def __init__(self, dialog, log_file, parent):
threading.Thread.__init__(self)
self.dialog =dialog
self.log_file = log_file
self.parent = parent
def run(self):
p = subprocess.Popen(['xdg-open',self.log_file])
retcode = p.poll()
while (retcode == None):
if self.parent.stop:
try:
p.terminate()
except OSError, e:
if e.errno == 3:
pass # no such process
else:
raise
retcode = p.poll()
self.dialog.destroy()

View File

@ -27,6 +27,9 @@ from bb.ui.crumbs.hobwidget import hic, HobViewTable, HobAltButton, HobButton
from bb.ui.crumbs.hobpages import HobPage from bb.ui.crumbs.hobpages import HobPage
import subprocess import subprocess
from bb.ui.crumbs.hig import CrumbsDialog from bb.ui.crumbs.hig import CrumbsDialog
from bb.ui.crumbs.hobthreads import OpeningLogThread
from bb.ui.crumbs.hig import OpeningLogDialog
# #
# ImageDetailsPage # ImageDetailsPage
# #
@ -404,7 +407,18 @@ class ImageDetailsPage (HobPage):
def open_log_clicked_cb(self, button, log_file): def open_log_clicked_cb(self, button, log_file):
if log_file: if log_file:
os.system("xdg-open /%s" % log_file) self.stop = False
dialog = OpeningLogDialog(title = "Opening Log",
parent = None,
flags = gtk.DIALOG_MODAL
| gtk.DIALOG_DESTROY_WITH_PARENT
| gtk.DIALOG_NO_SEPARATOR)
#create a thread to open log file
background = OpeningLogThread(dialog, log_file, self)
background.start()
response = dialog.run()
self.stop = True
background.join()
def refresh_package_detail_box(self, image_size): def refresh_package_detail_box(self, image_size):
self.package_detail.update_line_widgets("Total image size: ", image_size) self.package_detail.update_line_widgets("Total image size: ", image_size)

View File

@ -26,6 +26,8 @@ from bb.ui.crumbs.hobcolor import HobColors
from bb.ui.crumbs.hobwidget import HobViewTable, HobNotebook, HobAltButton, HobButton from bb.ui.crumbs.hobwidget import HobViewTable, HobNotebook, HobAltButton, HobButton
from bb.ui.crumbs.hoblistmodel import PackageListModel from bb.ui.crumbs.hoblistmodel import PackageListModel
from bb.ui.crumbs.hobpages import HobPage from bb.ui.crumbs.hobpages import HobPage
from bb.ui.crumbs.hobthreads import OpeningLogThread
from bb.ui.crumbs.hig import OpeningLogDialog
# #
# PackageSelectionPage # PackageSelectionPage
@ -167,7 +169,18 @@ class PackageSelectionPage (HobPage):
def open_log_clicked_cb(self, button, log_file): def open_log_clicked_cb(self, button, log_file):
if log_file: if log_file:
os.system("xdg-open /%s" % log_file) self.stop = False
dialog = OpeningLogDialog(title = "Opening Log",
parent = None,
flags = gtk.DIALOG_MODAL
| gtk.DIALOG_DESTROY_WITH_PARENT
| gtk.DIALOG_NO_SEPARATOR)
#create a thread to open log file
background = OpeningLogThread(dialog, log_file, self)
background.start()
response = dialog.run()
self.stop = True
background.join()
def show_page(self, log_file): def show_page(self, log_file):
children = self.button_box.get_children() or [] children = self.button_box.get_children() or []