run_bzr() fails unless you set a ui factory

Bug #499637 reported by Michael Hudson-Doyle
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Medium
Martin Pool

Bug Description

If you just call run_bzr() without setting a ui factory, it fails.

mwh@grond:~$ python
Python 2.6.4 (r264:75706, Dec 7 2009, 18:43:55)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from bzrlib.commands import run_bzr
>>> run_bzr([])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 976, in run_bzr
    cmd_help().run_argv_aliases([])
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 636, in run_argv_aliases
    self._setup_outf()
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 600, in _setup_outf
    encoding_type=self.encoding_type)
  File "/usr/lib/python2.6/dist-packages/bzrlib/ui/__init__.py", line 149, in make_output_stream
    out_stream = self._make_output_stream_explicit(encoding, encoding_type)
  File "/usr/lib/python2.6/dist-packages/bzrlib/ui/__init__.py", line 154, in _make_output_stream_explicit
    % (self.__class__.__name__))
NotImplementedError: SilentUIFactory doesn't support make_output_stream
>>>

This is a bit unfriendly. This is with version 2.1.0+b1+4902+129~8.10 from the nightly ppa, but it happens in bzr 2.1b4 too.

Tags: uifactory
Revision history for this message
Martin Pool (mbp) wrote :

Easy to do, but the question is: should the default be to silently absorb the output, or to write it to stdout? Or maybe the default should actually be a text uifactory?

Changed in bzr:
status: New → Confirmed
importance: Undecided → Medium
tags: added: uifactory
Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 499637] Re: run_bzr() fails unless you set a ui factory

On Wed, 2009-12-23 at 00:23 +0000, Martin Pool wrote:
> Easy to do, but the question is: should the default be to silently
> absorb the output, or to write it to stdout? Or maybe the default
> should actually be a text uifactory?

The older behaviour would have written to stdout; the ui factory at
those times simply meant 'no progress bar'. FWIW that behaviour seemed
to make folk happy.

-Rob

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Robert Collins wrote:
> On Wed, 2009-12-23 at 00:23 +0000, Martin Pool wrote:
>> Easy to do, but the question is: should the default be to silently
>> absorb the output, or to write it to stdout? Or maybe the default
>> should actually be a text uifactory?
>
> The older behaviour would have written to stdout; the ui factory at
> those times simply meant 'no progress bar'. FWIW that behaviour seemed
> to make folk happy.

I think I agree with this -- output to stdout by default makes sense.
Probably erroring if input is requested is fine.

Cheers,
mwh

Revision history for this message
Martin Pool (mbp) wrote :

ok, and with the new uifactory code, we should automatically make a
sensible decision about whether to show progress bars or not, with no
special intervention. Just calling
make_uifactory_for_stream(sys.stdout) should be enough. Want to try
it, mwh?

--
Martin <http://launchpad.net/~mbp/>

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Calling

ui.ui_factory = ui.make_ui_for_terminal(sys.stdin, sys.stdout, sys.stderr)

makes it work as I expected, yes.

Revision history for this message
Martin Pool (mbp) wrote :

bzrlib.initialize must be called before using the library, and it will create a UI by default.

imbn to just do this at import time, but callers need a chance to provide arguments and it's a bit hard to implement.

Changed in bzr:
assignee: nobody → Martin Pool (mbp)
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.