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