ZeroPhone / ZPUI

Official ZeroPhone UI framework, based on pyLCI
http://zpui.rtfd.org/
Apache License 2.0
78 stars 19 forks source link

More friendly messages when imports fail on app load #173

Open CRImier opened 5 years ago

CRImier commented 5 years ago

Some imports in certain ZPUI apps are not in the emulator requirements (tricky to install, or not that necessary for core functionality). To be exact:

Traceback (most recent call last):
File "/home/pi/ZPUI/libs/matrix_client/matrix_client/client.py", line 21, in <module>
from .crypto.olm_device import OlmDevice
File "/home/pi/ZPUI/libs/matrix_client/matrix_client/crypto/olm_device.py", line 5, in <module>
import olm
ImportError: No module named olm

(this one is non-critical, it only prevents encryption from working in Matrix)

2. File "/home/pi/ZPUI/apps/app_manager.py", line 152, in load_all_apps
    app = self.load_app(module_path)
  File "/home/pi/ZPUI/apps/app_manager.py", line 204, in load_app
    app = importlib.import_module(app_path + '.main', package='apps')
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/pi/ZPUI/apps/network_apps/ssh/main.py", line 10, in <module>
    from libs import systemctl
  File "/home/pi/ZPUI/libs/systemctl.py", line 2, in <module>
    from pydbus import SystemBus
  File "/home/pi/venv/local/lib/python2.7/site-packages/pydbus/__init__.py", line 1, in <module>
    from .bus import SystemBus, SessionBus, connect
  File "/home/pi/venv/local/lib/python2.7/site-packages/pydbus/bus.py", line 1, in <module>
    from gi.repository import Gio
ImportError: No module named gi.repository

(this one is critical as it prevents the systemctl app from working)

We need to silence those messages so that the logs are more readable when launching the emulator. Also, feel free to silence any additional ones. You can probably use the same technique that the nmap app does, printing a warning in logs and then showing a warning to the user when they try to enter the app

Thoughts: