summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorCristiana Voicu <cristiana.voicu@intel.com>2012-10-25 13:36:23 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-10-27 09:55:54 +0100
commita9c563b1b5879ea597e00097ac7e399d531a0704 (patch)
treeb2c728bd5c233b449047eb8af3211376c6ff89cd /bitbake/lib
parente281bb3e35ca7ffabaa6742c126fd6f6079c000f (diff)
downloadpoky-a9c563b1b5879ea597e00097ac7e399d531a0704.tar.gz
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>
Diffstat (limited to 'bitbake/lib')
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/builddetailspage.py15
-rw-r--r--bitbake/lib/bb/ui/crumbs/hig.py42
-rw-r--r--bitbake/lib/bb/ui/crumbs/hobthreads.py51
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/imagedetailspage.py16
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/packageselectionpage.py15
5 files changed, 136 insertions, 3 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/builddetailspage.py b/bitbake/lib/bb/ui/crumbs/builddetailspage.py
index 971cda0c59..1afacf85bd 100755
--- a/bitbake/lib/bb/ui/crumbs/builddetailspage.py
+++ b/bitbake/lib/bb/ui/crumbs/builddetailspage.py
@@ -30,6 +30,8 @@ from bb.ui.crumbs.runningbuild import RunningBuildTreeView
30from bb.ui.crumbs.runningbuild import BuildFailureTreeView 30from bb.ui.crumbs.runningbuild import BuildFailureTreeView
31from bb.ui.crumbs.hobpages import HobPage 31from bb.ui.crumbs.hobpages import HobPage
32from bb.ui.crumbs.hobcolor import HobColors 32from bb.ui.crumbs.hobcolor import HobColors
33from bb.ui.crumbs.hobthreads import OpeningLogThread
34from bb.ui.crumbs.hig import OpeningLogDialog
33 35
34class BuildConfigurationTreeView(gtk.TreeView): 36class BuildConfigurationTreeView(gtk.TreeView):
35 def __init__ (self): 37 def __init__ (self):
@@ -404,7 +406,18 @@ class BuildDetailsPage (HobPage):
404 406
405 def open_log_button_clicked_cb(self, button, log_file): 407 def open_log_button_clicked_cb(self, button, log_file):
406 if log_file: 408 if log_file:
407 os.system("xdg-open /%s" % log_file) 409 self.stop = False
410 dialog = OpeningLogDialog(title = "Opening Log",
411 parent = None,
412 flags = gtk.DIALOG_MODAL
413 | gtk.DIALOG_DESTROY_WITH_PARENT
414 | gtk.DIALOG_NO_SEPARATOR)
415 #create a thread to open log file
416 background = OpeningLogThread(dialog, log_file, self)
417 background.start()
418 response = dialog.run()
419 self.stop = True
420 background.join()
408 421
409 def failure_activate_file_bug_link_cb(self, button): 422 def failure_activate_file_bug_link_cb(self, button):
410 button.child.emit('activate-link', "http://bugzilla.yoctoproject.org") 423 button.child.emit('activate-link', "http://bugzilla.yoctoproject.org")
diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py
index 4f4fecb58a..d030beda22 100644
--- a/bitbake/lib/bb/ui/crumbs/hig.py
+++ b/bitbake/lib/bb/ui/crumbs/hig.py
@@ -1855,6 +1855,9 @@ class ImageSelectionDialog (CrumbsDialog):
1855 break 1855 break
1856 iter = self.image_store.iter_next(iter) 1856 iter = self.image_store.iter_next(iter)
1857 1857
1858#
1859# ProxyDetailsDialog
1860#
1858class ProxyDetailsDialog (CrumbsDialog): 1861class ProxyDetailsDialog (CrumbsDialog):
1859 1862
1860 def __init__(self, title, user, passwd, parent, flags, buttons=None): 1863 def __init__(self, title, user, passwd, parent, flags, buttons=None):
@@ -1914,3 +1917,42 @@ class ProxyDetailsDialog (CrumbsDialog):
1914 else: 1917 else:
1915 self.user = None 1918 self.user = None
1916 self.passwd = None 1919 self.passwd = None
1920
1921
1922#
1923# OpeningLogDialog
1924#
1925class OpeningLogDialog (CrumbsDialog):
1926
1927 def __init__(self, title, parent, flags, buttons=None):
1928 super(OpeningLogDialog, self).__init__(title, parent, flags, buttons)
1929
1930 self.running = False
1931 # create visual elements on the dialog
1932 self.create_visual_elements()
1933
1934 def start(self):
1935 if not self.running:
1936 self.running = True
1937 gobject.timeout_add(100, self.pulse)
1938
1939 def pulse(self):
1940 self.progress_bar.pulse()
1941 return self.running
1942
1943 def create_visual_elements(self):
1944 hbox = gtk.HBox(False, 12)
1945 self.user_label = gtk.Label("The log will open in a text editor")
1946 hbox.pack_start(self.user_label, expand=False, fill=False)
1947 self.vbox.pack_start(hbox, expand=False, fill=False)
1948
1949 hbox = gtk.HBox(False, 12)
1950 # Progress bar
1951 self.progress_bar = HobProgressBar()
1952 hbox.pack_start(self.progress_bar)
1953 self.start()
1954 self.vbox.pack_start(hbox, expand=False, fill=False)
1955
1956 button = self.add_button("Cancel", gtk.RESPONSE_CANCEL)
1957 HobAltButton.style_button(button)
1958 self.show_all()
diff --git a/bitbake/lib/bb/ui/crumbs/hobthreads.py b/bitbake/lib/bb/ui/crumbs/hobthreads.py
new file mode 100644
index 0000000000..64ef91245a
--- /dev/null
+++ b/bitbake/lib/bb/ui/crumbs/hobthreads.py
@@ -0,0 +1,51 @@
1#!/usr/bin/env python
2#
3# BitBake Graphical GTK User Interface
4#
5# Copyright (C) 2012 Intel Corporation
6#
7# Authored by Cristiana Voicu <cristiana.voicu@intel.com>
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License version 2 as
11# published by the Free Software Foundation.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License along
19# with this program; if not, write to the Free Software Foundation, Inc.,
20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22import threading
23import gtk
24import subprocess
25
26#
27# OpeningLogThread
28#
29class OpeningLogThread(threading.Thread):
30 def __init__(self, dialog, log_file, parent):
31 threading.Thread.__init__(self)
32 self.dialog =dialog
33 self.log_file = log_file
34 self.parent = parent
35
36 def run(self):
37 p = subprocess.Popen(['xdg-open',self.log_file])
38 retcode = p.poll()
39 while (retcode == None):
40 if self.parent.stop:
41 try:
42 p.terminate()
43 except OSError, e:
44 if e.errno == 3:
45 pass # no such process
46 else:
47 raise
48 retcode = p.poll()
49
50 self.dialog.destroy()
51
diff --git a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
index c47d67a222..a1c133edee 100755
--- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
+++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
@@ -27,6 +27,9 @@ from bb.ui.crumbs.hobwidget import hic, HobViewTable, HobAltButton, HobButton
27from bb.ui.crumbs.hobpages import HobPage 27from bb.ui.crumbs.hobpages import HobPage
28import subprocess 28import subprocess
29from bb.ui.crumbs.hig import CrumbsDialog 29from bb.ui.crumbs.hig import CrumbsDialog
30from bb.ui.crumbs.hobthreads import OpeningLogThread
31from bb.ui.crumbs.hig import OpeningLogDialog
32
30# 33#
31# ImageDetailsPage 34# ImageDetailsPage
32# 35#
@@ -404,7 +407,18 @@ class ImageDetailsPage (HobPage):
404 407
405 def open_log_clicked_cb(self, button, log_file): 408 def open_log_clicked_cb(self, button, log_file):
406 if log_file: 409 if log_file:
407 os.system("xdg-open /%s" % log_file) 410 self.stop = False
411 dialog = OpeningLogDialog(title = "Opening Log",
412 parent = None,
413 flags = gtk.DIALOG_MODAL
414 | gtk.DIALOG_DESTROY_WITH_PARENT
415 | gtk.DIALOG_NO_SEPARATOR)
416 #create a thread to open log file
417 background = OpeningLogThread(dialog, log_file, self)
418 background.start()
419 response = dialog.run()
420 self.stop = True
421 background.join()
408 422
409 def refresh_package_detail_box(self, image_size): 423 def refresh_package_detail_box(self, image_size):
410 self.package_detail.update_line_widgets("Total image size: ", image_size) 424 self.package_detail.update_line_widgets("Total image size: ", image_size)
diff --git a/bitbake/lib/bb/ui/crumbs/packageselectionpage.py b/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
index 17b1dfe3c4..ac9cc7e135 100755
--- a/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
+++ b/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
@@ -26,6 +26,8 @@ from bb.ui.crumbs.hobcolor import HobColors
26from bb.ui.crumbs.hobwidget import HobViewTable, HobNotebook, HobAltButton, HobButton 26from bb.ui.crumbs.hobwidget import HobViewTable, HobNotebook, HobAltButton, HobButton
27from bb.ui.crumbs.hoblistmodel import PackageListModel 27from bb.ui.crumbs.hoblistmodel import PackageListModel
28from bb.ui.crumbs.hobpages import HobPage 28from bb.ui.crumbs.hobpages import HobPage
29from bb.ui.crumbs.hobthreads import OpeningLogThread
30from bb.ui.crumbs.hig import OpeningLogDialog
29 31
30# 32#
31# PackageSelectionPage 33# PackageSelectionPage
@@ -167,7 +169,18 @@ class PackageSelectionPage (HobPage):
167 169
168 def open_log_clicked_cb(self, button, log_file): 170 def open_log_clicked_cb(self, button, log_file):
169 if log_file: 171 if log_file:
170 os.system("xdg-open /%s" % log_file) 172 self.stop = False
173 dialog = OpeningLogDialog(title = "Opening Log",
174 parent = None,
175 flags = gtk.DIALOG_MODAL
176 | gtk.DIALOG_DESTROY_WITH_PARENT
177 | gtk.DIALOG_NO_SEPARATOR)
178 #create a thread to open log file
179 background = OpeningLogThread(dialog, log_file, self)
180 background.start()
181 response = dialog.run()
182 self.stop = True
183 background.join()
171 184
172 def show_page(self, log_file): 185 def show_page(self, log_file):
173 children = self.button_box.get_children() or [] 186 children = self.button_box.get_children() or []