automatically install missing modules referenced in ~/.weboob/backends
This commit is contained in:
parent
5083103d1a
commit
b3c797978a
4 changed files with 10 additions and 16 deletions
|
|
@ -24,7 +24,6 @@ import re
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
|
||||||
from weboob.capabilities.account import ICapAccount
|
from weboob.capabilities.account import ICapAccount
|
||||||
from weboob.core.repositories import IProgress
|
|
||||||
from weboob.core.modules import ModuleLoadError
|
from weboob.core.modules import ModuleLoadError
|
||||||
from weboob.tools.application.repl import ReplApplication
|
from weboob.tools.application.repl import ReplApplication
|
||||||
from weboob.tools.ordereddict import OrderedDict
|
from weboob.tools.ordereddict import OrderedDict
|
||||||
|
|
@ -263,11 +262,7 @@ class WeboobCfg(ReplApplication):
|
||||||
|
|
||||||
Update weboob.
|
Update weboob.
|
||||||
"""
|
"""
|
||||||
class Progress(IProgress):
|
self.weboob.update()
|
||||||
def progress(self, percent, message):
|
|
||||||
print '=== [%3.0f%%] %s' % (percent*100, message)
|
|
||||||
|
|
||||||
self.weboob.update(Progress())
|
|
||||||
|
|
||||||
def do_install(self, line):
|
def do_install(self, line):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -130,14 +130,14 @@ class Weboob(object):
|
||||||
if caps is not None and not minfo.has_caps(caps):
|
if caps is not None and not minfo.has_caps(caps):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if not minfo.is_installed():
|
||||||
|
self.repositories.install(minfo)
|
||||||
|
|
||||||
module = None
|
module = None
|
||||||
try:
|
try:
|
||||||
module = self.modules_loader.get_or_load_module(module_name)
|
module = self.modules_loader.get_or_load_module(module_name)
|
||||||
except ModuleLoadError, e:
|
except ModuleLoadError, e:
|
||||||
self.logger.error(e)
|
self.logger.error(e)
|
||||||
if module is None:
|
|
||||||
self.logger.warning(u'Backend "%s" is referenced in %s but was not found. '
|
|
||||||
'Hint: try to use "weboob-config update"' % (module_name, self.backends_config.confpath))
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if instance_name in self.backend_instances:
|
if instance_name in self.backend_instances:
|
||||||
|
|
|
||||||
|
|
@ -280,13 +280,16 @@ class Versions(object):
|
||||||
|
|
||||||
class IProgress:
|
class IProgress:
|
||||||
def progress(self, percent, message):
|
def progress(self, percent, message):
|
||||||
pass
|
print '=== [%3.0f%%] %s' % (percent*100, message)
|
||||||
|
|
||||||
class ModuleInstallError(Exception):
|
class ModuleInstallError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
DEFAULT_SOURCES_LIST = \
|
DEFAULT_SOURCES_LIST = \
|
||||||
"""# List of Weboob repositories
|
"""# List of Weboob repositories
|
||||||
|
#
|
||||||
|
# The entries below override the entries above (with
|
||||||
|
# backends of the same name).
|
||||||
|
|
||||||
http://updates.weboob.org/%(version)s/main/
|
http://updates.weboob.org/%(version)s/main/
|
||||||
# To enable NSFW backends, uncomment the following line:
|
# To enable NSFW backends, uncomment the following line:
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import locale
|
||||||
from weboob.capabilities.account import ICapAccount, Account, AccountRegisterError
|
from weboob.capabilities.account import ICapAccount, Account, AccountRegisterError
|
||||||
from weboob.core.backendscfg import BackendAlreadyExists
|
from weboob.core.backendscfg import BackendAlreadyExists
|
||||||
from weboob.core.modules import ModuleLoadError
|
from weboob.core.modules import ModuleLoadError
|
||||||
from weboob.core.repositories import IProgress, ModuleInstallError
|
from weboob.core.repositories import ModuleInstallError
|
||||||
from weboob.tools.browser import BrowserUnavailable, BrowserIncorrectPassword
|
from weboob.tools.browser import BrowserUnavailable, BrowserIncorrectPassword
|
||||||
from weboob.tools.value import Value, ValueBool, ValueFloat, ValueInt
|
from weboob.tools.value import Value, ValueBool, ValueFloat, ValueInt
|
||||||
from weboob.tools.misc import to_unicode
|
from weboob.tools.misc import to_unicode
|
||||||
|
|
@ -250,12 +250,8 @@ class ConsoleApplication(BaseApplication):
|
||||||
return backend_config
|
return backend_config
|
||||||
|
|
||||||
def install_module(self, name):
|
def install_module(self, name):
|
||||||
class Progress(IProgress):
|
|
||||||
def progress(self, percent, message):
|
|
||||||
print '=== %s' % message
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.weboob.repositories.install(name, Progress())
|
self.weboob.repositories.install(name)
|
||||||
except ModuleInstallError, e:
|
except ModuleInstallError, e:
|
||||||
print >>sys.stderr, 'Unable to install module "%s": %s' % (name, e)
|
print >>sys.stderr, 'Unable to install module "%s": %s' % (name, e)
|
||||||
return 1
|
return 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue