jhbuild r1781 - in trunk: . jhbuild jhbuild/frontends
- From: fpeters svn gnome org
- To: svn-commits-list gnome org
- Subject: jhbuild r1781 - in trunk: . jhbuild jhbuild/frontends
- Date: Sun, 6 Jan 2008 21:01:51 +0000 (GMT)
Author: fpeters
Date: Sun Jan 6 21:01:51 2008
New Revision: 1781
URL: http://svn.gnome.org/viewvc/jhbuild?rev=1781&view=rev
Log:
* jhbuild/config.py, jhbuild/defaults.jhbuildrc,
jhbuild/frontends/terminal.py: added a progress bar in quiet mode, as
in mockup in bug #503925; on by default, with possibility to disable
with progress_bar configuration variable.
Modified:
trunk/ChangeLog
trunk/jhbuild/config.py
trunk/jhbuild/defaults.jhbuildrc
trunk/jhbuild/frontends/terminal.py
Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog (original)
+++ trunk/ChangeLog Sun Jan 6 21:01:51 2008
@@ -1,5 +1,12 @@
2008-01-06 Frederic Peters <fpeters 0d be>
+ * jhbuild/config.py, jhbuild/defaults.jhbuildrc,
+ jhbuild/frontends/terminal.py: added a progress bar in quiet mode, as
+ in mockup in bug #503925; on by default, with possibility to disable
+ with progress_bar configuration variable.
+
+2008-01-06 Frederic Peters <fpeters 0d be>
+
* jhbuild/defaults.jhbuildrc, jhbuild/config.py,
jhbuild/commands/base.py, jhbuild/frontends/terminal.py: added a quiet
mode, activated by the quiet_mode variable in configuration variable or
Modified: trunk/jhbuild/config.py
==============================================================================
--- trunk/jhbuild/config.py (original)
+++ trunk/jhbuild/config.py Sun Jan 6 21:01:51 2008
@@ -38,7 +38,8 @@
'tarballdir', 'pretty_print', 'svn_program', 'makedist',
'makedistcheck', 'nonotify', 'cvs_program',
'checkout_mode', 'copy_dir', 'module_checkout_mode',
- 'build_policy', 'trycheckout', 'nopoison', 'quiet_mode']
+ 'build_policy', 'trycheckout', 'nopoison', 'quiet_mode',
+ 'progress_bar']
env_prepends = {}
def prependpath(envvar, path):
Modified: trunk/jhbuild/defaults.jhbuildrc
==============================================================================
--- trunk/jhbuild/defaults.jhbuildrc (original)
+++ trunk/jhbuild/defaults.jhbuildrc Sun Jan 6 21:01:51 2008
@@ -57,6 +57,7 @@
interact = True # whether to interact with the user.
quiet_mode = False # whether to display running commands output
+progress_bar = True # whether to display a progress bar when running in quiet mode
# checkout modes. For VCS directories, it specifies how the checkout
# is done. We can also specify checkout modes for specific modules
Modified: trunk/jhbuild/frontends/terminal.py
==============================================================================
--- trunk/jhbuild/frontends/terminal.py (original)
+++ trunk/jhbuild/frontends/terminal.py Sun Jan 6 21:01:51 2008
@@ -46,6 +46,9 @@
user_shell = os.environ.get('SHELL', '/bin/sh')
+import curses
+curses.setupterm()
+
# tray icon stuff ...
icondir = os.path.join(os.path.dirname(__file__), 'icons')
phase_map = {
@@ -63,6 +66,7 @@
class TerminalBuildScript(buildscript.BuildScript):
triedcheckout = False
+ is_end_of_build = False
def __init__(self, config, module_list):
buildscript.BuildScript.__init__(self, config, module_list)
@@ -78,9 +82,16 @@
progress = ' [%d/%d]' % (module_num, len(self.modulelist))
else:
progress = ''
- print '%s*** %s ***%s%s' % (t_bold, msg, progress, t_reset)
+
+ if not (self.config.quiet_mode and self.config.progress_bar):
+ print '%s*** %s ***%s%s' % (t_bold, msg, progress, t_reset)
+ else:
+ progress = 1.0 * (module_num-1) / len(self.modulelist)
+ self.display_status_line(progress, module_num, msg)
+
if is_xterm:
- print '\033]0;jhbuild: %s%s\007' % (msg, progress)
+ sys.stdout.write('\033]0;jhbuild: %s%s\007' % (msg, progress))
+ sys.stdout.flush()
self.trayicon.set_tooltip('%s%s' % (msg, progress))
def set_action(self, action, module, module_num=-1, action_target=None):
@@ -90,6 +101,32 @@
action_target = module.name
self.message('%s %s' % (action, action_target), module_num)
+ def display_status_line(self, progress, module_num, message):
+ if self.is_end_of_build:
+ # hardcode progress to 100% at the end of the build
+ progress = 1
+
+ columns = curses.tigetnum('cols')
+ width = columns / 2
+ num_hashes = int(round(progress * width))
+ progress_bar = '[' + (num_hashes * '=') + ((width - num_hashes) * '-') + ']'
+
+ module_no_digits = len(str(len(self.modulelist)))
+ format_str = '%%%dd' % module_no_digits
+ module_pos = '[' + format_str % module_num + '/' + format_str % len(self.modulelist) + ']'
+
+ output = '%s %s %s%s%s' % (progress_bar, module_pos, t_bold, message, t_reset)
+ if len(output) > columns:
+ output = output[:columns]
+ else:
+ output += ' ' * (columns-len(output))
+
+ sys.stdout.write(output + '\r')
+ if self.is_end_of_build:
+ sys.stdout.write('\n')
+ sys.stdout.flush()
+
+
def execute(self, command, hint=None, cwd=None, extra_env=None):
if not command:
raise CommandError('No command given')
@@ -188,6 +225,7 @@
phase_map.get(state, 'build.png')))
def end_build(self, failures):
+ self.is_end_of_build = True
if len(failures) == 0:
self.message('success')
else:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]