diff options
author | Cristiana Voicu <cristiana.voicu@intel.com> | 2012-10-25 13:36:23 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-10-27 09:51:21 +0100 |
commit | 165362a63f085991b6bab63ab90a0c7b9bf6b784 (patch) | |
tree | 5ba0614a96905892065742a9f595af2da3164e4c /lib | |
parent | 1c540541c5397c38dca880a79df9ebfcda576d4c (diff) | |
download | bitbake-165362a63f085991b6bab63ab90a0c7b9bf6b784.tar.gz |
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]
Signed-off-by: Cristiana Voicu <cristiana.voicu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/bb/ui/crumbs/builddetailspage.py | 15 | ||||
-rw-r--r-- | lib/bb/ui/crumbs/hig.py | 42 | ||||
-rw-r--r-- | lib/bb/ui/crumbs/hobthreads.py | 51 | ||||
-rwxr-xr-x | lib/bb/ui/crumbs/imagedetailspage.py | 16 | ||||
-rwxr-xr-x | lib/bb/ui/crumbs/packageselectionpage.py | 15 |
5 files changed, 136 insertions, 3 deletions
diff --git a/lib/bb/ui/crumbs/builddetailspage.py b/lib/bb/ui/crumbs/builddetailspage.py index 971cda0c5..1afacf85b 100755 --- a/lib/bb/ui/crumbs/builddetailspage.py +++ b/lib/bb/ui/crumbs/builddetailspage.py @@ -30,6 +30,8 @@ from bb.ui.crumbs.runningbuild import RunningBuildTreeView from bb.ui.crumbs.runningbuild import BuildFailureTreeView from bb.ui.crumbs.hobpages import HobPage 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): def __init__ (self): @@ -404,7 +406,18 @@ class BuildDetailsPage (HobPage): def open_log_button_clicked_cb(self, button, 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): button.child.emit('activate-link', "http://bugzilla.yoctoproject.org") diff --git a/lib/bb/ui/crumbs/hig.py b/lib/bb/ui/crumbs/hig.py index 4f4fecb58..d030beda2 100644 --- a/lib/bb/ui/crumbs/hig.py +++ b/lib/bb/ui/crumbs/hig.py @@ -1855,6 +1855,9 @@ class ImageSelectionDialog (CrumbsDialog): break iter = self.image_store.iter_next(iter) +# +# ProxyDetailsDialog +# class ProxyDetailsDialog (CrumbsDialog): def __init__(self, title, user, passwd, parent, flags, buttons=None): @@ -1914,3 +1917,42 @@ class ProxyDetailsDialog (CrumbsDialog): else: self.user = 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() diff --git a/lib/bb/ui/crumbs/hobthreads.py b/lib/bb/ui/crumbs/hobthreads.py new file mode 100644 index 000000000..64ef91245 --- /dev/null +++ b/lib/bb/ui/crumbs/hobthreads.py @@ -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() + diff --git a/lib/bb/ui/crumbs/imagedetailspage.py b/lib/bb/ui/crumbs/imagedetailspage.py index c47d67a22..a1c133ede 100755 --- a/lib/bb/ui/crumbs/imagedetailspage.py +++ b/lib/bb/ui/crumbs/imagedetailspage.py @@ -27,6 +27,9 @@ from bb.ui.crumbs.hobwidget import hic, HobViewTable, HobAltButton, HobButton from bb.ui.crumbs.hobpages import HobPage import subprocess from bb.ui.crumbs.hig import CrumbsDialog +from bb.ui.crumbs.hobthreads import OpeningLogThread +from bb.ui.crumbs.hig import OpeningLogDialog + # # ImageDetailsPage # @@ -404,7 +407,18 @@ class ImageDetailsPage (HobPage): def open_log_clicked_cb(self, button, 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): self.package_detail.update_line_widgets("Total image size: ", image_size) diff --git a/lib/bb/ui/crumbs/packageselectionpage.py b/lib/bb/ui/crumbs/packageselectionpage.py index 17b1dfe3c..ac9cc7e13 100755 --- a/lib/bb/ui/crumbs/packageselectionpage.py +++ b/lib/bb/ui/crumbs/packageselectionpage.py @@ -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.hoblistmodel import PackageListModel from bb.ui.crumbs.hobpages import HobPage +from bb.ui.crumbs.hobthreads import OpeningLogThread +from bb.ui.crumbs.hig import OpeningLogDialog # # PackageSelectionPage @@ -167,7 +169,18 @@ class PackageSelectionPage (HobPage): def open_log_clicked_cb(self, button, 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): children = self.button_box.get_children() or [] |