astropy/astropy — pull request #908 by mdboom (2013-03-28 00:17:06+00:00)
Title: astropy.utils.data.download_file() crashes when show_progress=False

This is a follow-up of #865 by @mdboom .

```
>>> from astropy.utils.data import download_file
>>> download_file('https://github.com/astropy/astropy/blob/master/README.rst')
Downloading https://github.com/astropy/astropy/blob/master/README.rst
|===========================================| 24k/ 24k (100.00%) 00s
'/tmp/tmptcOh_V'
```

So far so good. But when I try to suppress the progress bar:

```
>>> download_file('https://github.com/astropy/astropy/blob/master/README.rst',
... show_progress=False)
ERROR: TypeError: 'unicode' does not have the buffer interface [astropy.utils.console]
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
----> 1 download_file('https://github.com/astropy/astropy/blob/master/README.rst', show_progress=False)

/home/lim/rhel6/lib/python2.7/site-packages/astropy-0.3.dev3725-py2.7-linux-x86_64.egg/astropy/utils/data.pyc in download_file(remote_url, cache, show_progress)
881 if os.path.exists(f.name):
882 os.remove(f.name)
--> 883 raise
884
885 if cache:

/home/lim/rhel6/lib/python2.7/site-packages/astropy-0.3.dev3725-py2.7-linux-x86_64.egg/astropy/utils/console.pyc in __exit__(self, exc_type, exc_value, traceback)
634
635 def __exit__(self, exc_type, exc_value, traceback):
--> 636 return self._obj.__exit__(exc_type, exc_value, traceback)
637
638 def update(self, value):

/home/lim/rhel6/lib/python2.7/site-packages/astropy-0.3.dev3725-py2.7-linux-x86_64.egg/astropy/utils/console.pyc in __exit__(self, exc_type, exc_value, traceback)
565 color_print(u' [Done]', 'green', file=file)
566 else:
--> 567 color_print(u' [Failed]', 'red', file=file)
568 flush()
569

/home/lim/rhel6/lib/python2.7/site-packages/astropy-0.3.dev3725-py2.7-linux-x86_64.egg/astropy/utils/console.pyc in color_print(*args, **kwargs)
159 if isinstance(msg, bytes):
160 msg = msg.decode('ascii')
--> 161 write(msg)
162 write(end)
163

TypeError: 'unicode' does not have the buffer interface
```