mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-30 19:56:14 +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:
commit
40ffe7e488
@ -167,7 +167,8 @@ class Osc(cmdln.Cmdln):
|
|||||||
self.download_progress = None
|
self.download_progress = None
|
||||||
if conf.config.get('show_download_progress', False):
|
if conf.config.get('show_download_progress', False):
|
||||||
from .meter import TextMeter
|
from .meter import TextMeter
|
||||||
self.download_progress = TextMeter()
|
if TextMeter:
|
||||||
|
self.download_progress = TextMeter()
|
||||||
|
|
||||||
|
|
||||||
def get_cmd_help(self, cmdname):
|
def get_cmd_help(self, cmdname):
|
||||||
|
@ -4618,10 +4618,14 @@ def get_binary_file(apiurl, prj, repo, arch,
|
|||||||
progress_obj = None
|
progress_obj = None
|
||||||
if progress_meter:
|
if progress_meter:
|
||||||
from .meter import TextMeter
|
from .meter import TextMeter
|
||||||
progress_obj = TextMeter()
|
if TextMeter:
|
||||||
|
progress_obj = TextMeter()
|
||||||
|
|
||||||
target_filename = target_filename or filename
|
target_filename = target_filename or filename
|
||||||
|
|
||||||
|
if progress_meter and not progress_obj:
|
||||||
|
print('Downloading %s' % target_filename)
|
||||||
|
|
||||||
where = package or '_repository'
|
where = package or '_repository'
|
||||||
u = makeurl(apiurl, ['build', prj, repo, arch, where, filename])
|
u = makeurl(apiurl, ['build', prj, repo, arch, where, filename])
|
||||||
download(u, target_filename, progress_obj, target_mtime)
|
download(u, target_filename, progress_obj, target_mtime)
|
||||||
|
@ -25,6 +25,8 @@ import re
|
|||||||
|
|
||||||
from .meter import TextMeter
|
from .meter import TextMeter
|
||||||
|
|
||||||
|
if not TextMeter:
|
||||||
|
print('Please install the progressbar module')
|
||||||
|
|
||||||
class Fetcher:
|
class Fetcher:
|
||||||
def __init__(self, cachedir='/tmp', api_host_options={}, urllist=[],
|
def __init__(self, cachedir='/tmp', api_host_options={}, urllist=[],
|
||||||
|
11
osc/meter.py
11
osc/meter.py
@ -28,18 +28,9 @@ class PBTextMeter(object):
|
|||||||
def end(self):
|
def end(self):
|
||||||
self.bar.finish()
|
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:
|
if have_pb_module:
|
||||||
TextMeter = PBTextMeter
|
TextMeter = PBTextMeter
|
||||||
else:
|
else:
|
||||||
TextMeter = NoPBTextMeter
|
TextMeter = None
|
||||||
# vim: sw=4 et
|
# vim: sw=4 et
|
||||||
|
Loading…
Reference in New Issue
Block a user