Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
esp-init
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Robin Schubert
esp-init
Commits
59369755
Verified
Commit
59369755
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Move impotrs into methods for even more namespace tidyness
parent
6e9a2360
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
boot.py
+13
-7
13 additions, 7 deletions
boot.py
with
13 additions
and
7 deletions
boot.py
+
13
−
7
View file @
59369755
...
@@ -14,12 +14,6 @@
...
@@ -14,12 +14,6 @@
"""
µnit - Configurable initialisation system for MicroPython/ESP
"""
"""
µ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
# Set of configuration schemas provided by µnit itself
# First level: category -> (human-readable name, dict of settings)
# First level: category -> (human-readable name, dict of settings)
# Second level: setting key -> (human-readable name, type, choices, default)
# Second level: setting key -> (human-readable name, type, choices, default)
...
@@ -60,6 +54,8 @@ class _MynitConfig:
...
@@ -60,6 +54,8 @@ class _MynitConfig:
self
.
_load
()
self
.
_load
()
def
_make_dir
(
self
):
def
_make_dir
(
self
):
import
os
try
:
try
:
os
.
stat
(
self
.
_dir
)
os
.
stat
(
self
.
_dir
)
except
OSError
:
except
OSError
:
...
@@ -68,6 +64,8 @@ class _MynitConfig:
...
@@ -68,6 +64,8 @@ class _MynitConfig:
def
_load
(
self
):
def
_load
(
self
):
"""
Load cached data from data directory.
"""
"""
Load cached data from data directory.
"""
import
json
# Create data directory if it doesn't exist yet
# Create data directory if it doesn't exist yet
self
.
_make_dir
()
self
.
_make_dir
()
...
@@ -90,6 +88,8 @@ class _MynitConfig:
...
@@ -90,6 +88,8 @@ class _MynitConfig:
self
.
_config
=
{}
self
.
_config
=
{}
def
_save
(
self
):
def
_save
(
self
):
import
json
"""
Save cached data to data directory.
"""
"""
Save cached data to data directory.
"""
# Create data directory if it doesn't exist yet
# Create data directory if it doesn't exist yet
self
.
_make_dir
()
self
.
_make_dir
()
...
@@ -161,6 +161,8 @@ class _MynitBoot:
...
@@ -161,6 +161,8 @@ class _MynitBoot:
print
(
"
Boot finished
"
)
print
(
"
Boot finished
"
)
def
setup_wifi
(
self
):
def
setup_wifi
(
self
):
import
network
# Setup wifi
# Setup wifi
if
self
.
_config
[
"
wifi
"
][
"
essid
"
]:
if
self
.
_config
[
"
wifi
"
][
"
essid
"
]:
if
self
.
_config
[
"
wifi
"
][
"
mode
"
]
==
"
sta
"
:
if
self
.
_config
[
"
wifi
"
][
"
mode
"
]
==
"
sta
"
:
...
@@ -198,6 +200,8 @@ class _MynitBoot:
...
@@ -198,6 +200,8 @@ class _MynitBoot:
print
(
"
Wifi configured as %s
"
%
(
nic
.
ifconfig
(),))
print
(
"
Wifi configured as %s
"
%
(
nic
.
ifconfig
(),))
def
setup_webrepl
(
self
):
def
setup_webrepl
(
self
):
import
webrepl
# Start webrepl if enabled
# Start webrepl if enabled
if
self
.
_config
[
"
webrepl
"
][
"
enabled
"
]:
if
self
.
_config
[
"
webrepl
"
][
"
enabled
"
]:
print
(
"
Starting web REPL on port %d
"
%
self
.
_config
[
"
webrepl
"
][
"
port
"
])
print
(
"
Starting web REPL on port %d
"
%
self
.
_config
[
"
webrepl
"
][
"
port
"
])
...
@@ -219,4 +223,6 @@ if __name__ == "__main__":
...
@@ -219,4 +223,6 @@ if __name__ == "__main__":
del
_MYNIT_SCHEMAS
,
_MynitBoot
,
_MynitConfig
del
_MYNIT_SCHEMAS
,
_MynitBoot
,
_MynitConfig
# Forcibly clean up before handing overto main.py
# Forcibly clean up before handing overto main.py
gc
.
collect
()
# fmt: off
import
gc
;
gc
.
collect
();
del
gc
# fmt: on
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment