Skip to content

Commit e36ae58

Browse files
committed
Improve error message
1 parent 6432392 commit e36ae58

File tree

2 files changed

+19
-25
lines changed

2 files changed

+19
-25
lines changed

configure.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,22 @@
3232
sys.exit(0)
3333
except:
3434
os._exit(0)
35-
IMPORT_ERRORS = ''
35+
3636
try:
3737
import tkinter.ttk as ttk
3838
from tkinter import *
3939
from PIL import ImageTk
40-
except Exception as e:
41-
IMPORT_ERRORS += e.msg
42-
IMPORT_ERRORS += "\n"
43-
44-
try:
4540
import psutil
4641
import ruamel.yaml
4742
import sv_ttk
4843
from PIL import Image
4944
from serial.tools.list_ports import comports
5045
from tktooltip import ToolTip
5146
except Exception as e:
52-
IMPORT_ERRORS += e.msg
53-
IMPORT_ERRORS += "\n"
54-
55-
if IMPORT_ERRORS:
56-
IMPORT_ERRORS += "\n"
57-
IMPORT_ERRORS += "Please follow start guide: https://github.com/mathoudebine/turing-smart-screen-python/wiki/System-monitor-:-how-to-start"
58-
IMPORT_ERRORS += "\n"
59-
IMPORT_ERRORS += "Or the troubleshooting page troubleshooting page: https://github.com/mathoudebine/turing-smart-screen-python/wiki/Troubleshooting#all-os-tkinter-dependency-not-installed"
60-
print(IMPORT_ERRORS)
47+
print("""Import error: %s
48+
Please follow start guide to install required packages: https://github.com/mathoudebine/turing-smart-screen-python/wiki/System-monitor-:-how-to-start
49+
Or the troubleshooting page: https://github.com/mathoudebine/turing-smart-screen-python/wiki/Troubleshooting#all-os-tkinter-dependency-not-installed""" % str(
50+
e))
6151
try:
6252
sys.exit(0)
6353
except:

main.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,25 @@
4848
import win32con
4949
import win32gui
5050

51-
try:
52-
import pystray
53-
except:
54-
pass
55-
except:
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")
51+
from library.log import logger
52+
import library.scheduler as scheduler
53+
from library.display import display
54+
55+
except Exception as e:
56+
print("""Import error: %s
57+
Please follow start guide to install required packages: https://github.com/mathoudebine/turing-smart-screen-python/wiki/System-monitor-:-how-to-start
58+
Or the troubleshooting page: https://github.com/mathoudebine/turing-smart-screen-python/wiki/Troubleshooting#all-os-tkinter-dependency-not-installed""" % str(
59+
e))
5860
try:
5961
sys.exit(0)
6062
except:
6163
os._exit(0)
6264

63-
from library.log import logger
64-
import library.scheduler as scheduler
65-
from library.display import display
65+
try:
66+
import pystray
67+
except:
68+
# If pystray cannot be loaded do not stop the program, just ignore it. The tray icon will not be displayed.
69+
pass
6670

6771
if __name__ == "__main__":
6872

0 commit comments

Comments
 (0)