Skip to content

Commit 6c34489

Browse files
authored
Merge pull request #213 from mathoudebine/feature/187-user-friendly-message-for-missing-dependencies
Add message when modules are missing, instead of default stacktrace
2 parents 9b76750 + c17f3fd commit 6c34489

File tree

2 files changed

+49
-23
lines changed

2 files changed

+49
-23
lines changed

configure.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,35 @@
1919

2020
# This file is the system monitor configuration GUI
2121

22+
2223
import os
2324
import subprocess
2425
import sys
25-
import tkinter.ttk as ttk
26-
from tkinter import *
27-
28-
import psutil
29-
import ruamel.yaml
30-
import sv_ttk
31-
from PIL import Image, ImageTk
32-
from serial.tools.list_ports import comports
26+
27+
MIN_PYTHON = (3, 7)
28+
if sys.version_info < MIN_PYTHON:
29+
print("[ERROR] Python %s.%s or later is required." % MIN_PYTHON)
30+
try:
31+
sys.exit(0)
32+
except:
33+
os._exit(0)
34+
35+
try:
36+
import tkinter.ttk as ttk
37+
from tkinter import *
38+
39+
import psutil
40+
import ruamel.yaml
41+
import sv_ttk
42+
from PIL import Image, ImageTk
43+
from serial.tools.list_ports import comports
44+
except:
45+
print(
46+
"[ERROR] Python dependencies not installed. Please follow start guide: https://github.com/mathoudebine/turing-smart-screen-python/wiki/System-monitor-:-how-to-start")
47+
try:
48+
sys.exit(0)
49+
except:
50+
os._exit(0)
3351

3452
# Maps between config.yaml values and GUI description
3553
revision_map = {'A': "Turing / rev. A", 'B': "XuanFang / rev. B / flagship", 'SIMU': "Simulated screen"}

main.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,31 @@
3434
except:
3535
os._exit(0)
3636

37-
import atexit
38-
import locale
39-
import platform
40-
import signal
41-
import subprocess
42-
import time
43-
from PIL import Image
44-
45-
if platform.system() == 'Windows':
46-
import win32api
47-
import win32con
48-
import win32gui
49-
5037
try:
51-
import pystray
38+
import atexit
39+
import locale
40+
import platform
41+
import signal
42+
import subprocess
43+
import time
44+
from PIL import Image
45+
46+
if platform.system() == 'Windows':
47+
import win32api
48+
import win32con
49+
import win32gui
50+
51+
try:
52+
import pystray
53+
except:
54+
pass
5255
except:
53-
pass
56+
print(
57+
"[ERROR] Python dependencies not installed. Please follow start guide: https://github.com/mathoudebine/turing-smart-screen-python/wiki/System-monitor-:-how-to-start")
58+
try:
59+
sys.exit(0)
60+
except:
61+
os._exit(0)
5462

5563
from library.log import logger
5664
import library.scheduler as scheduler

0 commit comments

Comments
 (0)