24
def import_exit(package, version):
25
"""Show a nice explanation of which dependency to install and quit."""
27
print u"¡Falta instalar una dependencia!"
28
print u"Necesitás tener instalado el paquete %r" % (package,)
29
print u"(de la versión %s en adelante funciona seguro)" % (version,)
26
ERROR! Problema al importar %(module)r
28
Probablemente falte instalar una dependencia. Se necesita tener instalado
29
el paquete %(package)r versión %(version)s o superior.
32
class NiceImporter(object):
33
"""Show nicely successful and errored imports."""
34
def __init__(self, module, package, version):
36
self.package = package
37
self.version = version
42
def _get_version(self):
43
"""Get the version of a module."""
44
mod = sys.modules[self.module]
45
for attr in ('version', '__version__', 'ver'):
46
v = getattr(mod, attr, None)
49
return "<desconocida>"
51
def __exit__(self, exc_type, exc_value, traceback):
53
version = self._get_version()
54
print "Modulo %r importado ok, version %r" % (self.module, version)
56
print IMPORT_MSG % dict(module=self.module, package=self.package,
33
60
# test some packages! gtk and twisted are controlled in main.py, as they
34
61
# import order is critical because of the reactor
35
62
# pylint: disable=W0611
64
with NiceImporter('xdg', 'python-xdg', '0.15'):
40
import_exit('python-xdg', '0.15')
66
with NiceImporter('mechanize', 'python-mechanize', '0.1.11'):
44
import_exit('python-mechanize', '0.1.11')
46
71
from encuentro.main import MainUI as EncuentroUI