diff --git a/boot.py b/boot.py index 36899638b867c81d94c57bced70459b027543df4..744e544ab487352fa52527da584c0f0478298b82 100644 --- a/boot.py +++ b/boot.py @@ -14,12 +14,6 @@ """µnit - Configurable initialisation system for MicroPython/ESP""" -import gc -import json -import network -import os -import webrepl - # Set of configuration schemas provided by µnit itself # First level: category -> (human-readable name, dict of settings) # Second level: setting key -> (human-readable name, type, choices, default) @@ -60,6 +54,8 @@ class _MynitConfig: self._load() def _make_dir(self): + import os + try: os.stat(self._dir) except OSError: @@ -68,6 +64,8 @@ class _MynitConfig: def _load(self): """Load cached data from data directory.""" + import json + # Create data directory if it doesn't exist yet self._make_dir() @@ -90,6 +88,8 @@ class _MynitConfig: self._config = {} def _save(self): + import json + """Save cached data to data directory.""" # Create data directory if it doesn't exist yet self._make_dir() @@ -161,6 +161,8 @@ class _MynitBoot: print("Boot finished") def setup_wifi(self): + import network + # Setup wifi if self._config["wifi"]["essid"]: if self._config["wifi"]["mode"] == "sta": @@ -198,6 +200,8 @@ class _MynitBoot: print("Wifi configured as %s" % (nic.ifconfig(),)) def setup_webrepl(self): + import webrepl + # Start webrepl if enabled if self._config["webrepl"]["enabled"]: print("Starting web REPL on port %d" % self._config["webrepl"]["port"]) @@ -219,4 +223,6 @@ if __name__ == "__main__": del _MYNIT_SCHEMAS, _MynitBoot, _MynitConfig # Forcibly clean up before handing overto main.py - gc.collect() + # fmt: off + import gc; gc.collect(); del gc + # fmt: on