Commit 2366edf5 authored by Laurent Bachelier's avatar Laurent Bachelier 🐧 Committed by Vincent A

repositories: Better display of errors

Especially with local_run
parent 510d402a
......@@ -43,13 +43,14 @@ with open(os.path.join(wd, 'sources.list'), 'w') as f:
# Hide output unless there is an error
p = subprocess.Popen(
[sys.executable, os.path.join(project, 'scripts', 'weboob-config'), 'update'],
[sys.executable, os.path.join(project, 'scripts', 'weboob-config'), 'update', '-d'],
env=env,
stdout=subprocess.PIPE)
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
s = p.communicate()
if p.returncode != 0:
print(s[0])
sys.exit(p.returncode)
if p.returncode > 1:
sys.exit(p.returncode)
if os.path.exists(script):
spath = script
......
......@@ -320,3 +320,8 @@ class WeboobCfg(ReplApplication):
Update weboob.
"""
self.weboob.update(ConsoleProgress(self))
if self.weboob.repositories.errors:
print('Errors building modules: %s' % ', '.join(self.weboob.repositories.errors.keys()), file=self.stderr)
if not self.options.debug:
print('Use --debug to get more information.', file=self.stderr)
return 1
......@@ -132,6 +132,7 @@ class Repository(object):
self.key_update = 0
self.obsolete = False
self.logger = getLogger('repository')
self.errors = {}
self.modules = {}
......@@ -275,6 +276,7 @@ class Repository(object):
"""
self.logger.debug('Rebuild index')
self.modules.clear()
self.errors.clear()
if os.path.isdir(os.path.join(path, self.KEYDIR)):
self.signed = True
......@@ -296,8 +298,10 @@ class Repository(object):
if fp:
fp.close()
except Exception as e:
print('Unable to build module %s: [%s] %s' % (name, type(e).__name__, e), file=sys.stderr)
self.logger.debug(get_backtrace(e))
self.logger.warning('Unable to build module %s: [%s] %s' % (name, type(e).__name__, e))
bt = get_backtrace(e)
self.logger.debug(bt)
self.errors[name] = bt
else:
m = ModuleInfo(module.name)
m.version = self.get_tree_mtime(module_path)
......@@ -745,6 +749,17 @@ class Repositories(object):
"""
return ''.join([l if l.isalnum() else '_' for l in url])
def __iter__(self):
for repository in self.repositories:
yield repository
@property
def errors(self):
errors = {}
for repository in self:
errors.update(repository.errors)
return errors
class InvalidSignature(Exception):
def __init__(self, filename):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment