forked from pimoroni/enviroplus-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-install.py
executable file
·109 lines (89 loc) · 2.36 KB
/
check-install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
f"Sorry! This program requires Python >= 3.6 😅. Run with \"python3 check-install.py\""
CONFIG_FILE = "/boot/config.txt"
print("""Checking Enviro+ install, please wait...""")
errors = 0
check_apt = False
try:
import apt
check_apt = True
except ImportErorr:
print("⚠️ Could not import \"apt\". Unable to verify system dependencies.")
apt_deps = {
"python3",
"python3-pip",
"python3-numpy",
"python3-smbus",
"python3-pil",
"python3-cffi",
"python3-spidev",
"python3-rpi.gpio",
"libportaudio2"
}
deps = {
"bme280": None,
"pms5003": None,
"ltr559": None,
"ST7735": None,
"ads1015": "0.0.7",
"fonts": None,
"font_roboto": None,
"astral": None,
"pytz": None,
"sounddevice": None,
"paho.mqtt": None
}
config = {
"dtparam=i2c_arm=on",
"dtparam=spi=on",
"dtoverlay=adau7002-simple",
"dtoverlay=pi3-miniuart-bt",
"enable_uart=1"
}
if check_apt:
print("\nSystem dependencies...")
print(" Retrieving cache...")
cache = apt.Cache()
for dep in apt_deps:
installed = False
print(f" Checking for {dep}".ljust(35), end="")
try:
installed = cache[dep].is_installed
except KeyError:
pass
if installed:
print("✅")
else:
print("⚠️ Missing!")
errors += 1
print("\nPython dependencies...")
for dep, version in deps.items():
print(f" Checking for {dep}".ljust(35), end="")
try:
__import__(dep)
print("✅")
except ImportError:
print("⚠️ Missing!")
errors += 1
print("\nSystem config...")
config_txt = open(CONFIG_FILE, "r").read().split("\n")
def check_config(line):
global errors
print(f" Checking for {line} in {CONFIG_FILE}: ", end="")
for cline in config_txt:
if cline.startswith(line):
print("✅")
return
print("⚠️ Missing!")
errors += 1
for line in config:
check_config(line)
if errors > 0:
print("\n⚠️ Config errors were found! Something might be awry.")
else:
print("\n✅ Looks good from here!")
print("\nHave you?")
print(" • Rebooted after installing")
print(" • Made sure to run examples with \"python3\"")
print(" • Checked for any errors when running \"sudo ./install.sh\"")