1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-29 03:06:15 +01:00

Merge branch 'improve_missing_progressbar_module_handling' of https://github.com/lethliel/osc

Unbreak "osc build" output in case of a missing progressbar module (this
slipped in in commit 8a6abe3a6c ("warn user
if python-progressbar is not installed")). This change has some
"disadvantages":
- a print in fetch.py, which is always executed in in case of a missing
  progressbar (an external user might just import the verify_* functions)
- an explicit print in get_binary_file, which is actually the task of
  *some* progress_obj

For an alternative "fix", see [1]. Anyway, merged...

[1] https://github.com/openSUSE/osc/pull/502#issuecomment-453165987
This commit is contained in:
Marcus Huewe 2019-01-14 00:29:16 +01:00
commit 40ffe7e488
4 changed files with 10 additions and 12 deletions

View File

@ -167,7 +167,8 @@ class Osc(cmdln.Cmdln):
self.download_progress = None
if conf.config.get('show_download_progress', False):
from .meter import TextMeter
self.download_progress = TextMeter()
if TextMeter:
self.download_progress = TextMeter()
def get_cmd_help(self, cmdname):

View File

@ -4618,10 +4618,14 @@ def get_binary_file(apiurl, prj, repo, arch,
progress_obj = None
if progress_meter:
from .meter import TextMeter
progress_obj = TextMeter()
if TextMeter:
progress_obj = TextMeter()
target_filename = target_filename or filename
if progress_meter and not progress_obj:
print('Downloading %s' % target_filename)
where = package or '_repository'
u = makeurl(apiurl, ['build', prj, repo, arch, where, filename])
download(u, target_filename, progress_obj, target_mtime)

View File

@ -25,6 +25,8 @@ import re
from .meter import TextMeter
if not TextMeter:
print('Please install the progressbar module')
class Fetcher:
def __init__(self, cachedir='/tmp', api_host_options={}, urllist=[],

View File

@ -28,18 +28,9 @@ class PBTextMeter(object):
def end(self):
self.bar.finish()
class NoPBTextMeter(object):
def start(self, *args, **kwargs):
print('Please install the progressbar module...')
def update(self, *args, **kwargs):
pass
def end(self, *args, **kwargs):
pass
if have_pb_module:
TextMeter = PBTextMeter
else:
TextMeter = NoPBTextMeter
TextMeter = None
# vim: sw=4 et