omnipython-apps 0.1.4.dev8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- apps/__init__.py +5 -0
- apps/about/__init__.py +257 -0
- apps/about/app.json +1 -0
- apps/about/credits.py +12 -0
- apps/about/facts.py +398 -0
- apps/about/fonts/OFL.txt +93 -0
- apps/about/fonts/latin1_14.bin +0 -0
- apps/about/fonts/latin1_16.bin +0 -0
- apps/about/fonts/latin1_24.bin +0 -0
- apps/about/fonts/latin1_32.bin +0 -0
- apps/about/fonts/latin1_40.bin +0 -0
- apps/backline/__init__.py +58 -0
- apps/backline/app.json +1 -0
- apps/backline/app.py +475 -0
- apps/backline/art.py +717 -0
- apps/backline/ask.py +781 -0
- apps/backline/box.py +502 -0
- apps/backline/cast.py +137 -0
- apps/backline/desk/__init__.py +329 -0
- apps/backline/desk/editor.py +331 -0
- apps/backline/desk/grid.py +154 -0
- apps/backline/desk/look.py +169 -0
- apps/backline/desk/pedals.py +102 -0
- apps/backline/desk/perform.py +157 -0
- apps/backline/desk/prompt.py +210 -0
- apps/backline/desk/strip.py +159 -0
- apps/backline/desk_main.py +226 -0
- apps/backline/engine.py +622 -0
- apps/backline/floor.py +509 -0
- apps/backline/footswitch.py +119 -0
- apps/backline/glyphs.py +82 -0
- apps/backline/kits.py +428 -0
- apps/backline/midipedal.py +362 -0
- apps/backline/page_data.py +413 -0
- apps/backline/parts.py +145 -0
- apps/backline/pedal.py +107 -0
- apps/backline/remote.py +134 -0
- apps/backline/songs/ballad_68.json +1 -0
- apps/backline/songs/bossa.json +1 -0
- apps/backline/songs/country_train.json +1 -0
- apps/backline/songs/funk.json +1 -0
- apps/backline/songs/metal.json +1 -0
- apps/backline/songs/pop.json +1 -0
- apps/backline/songs/rock.json +1 -0
- apps/backline/songs/shuffle.json +1 -0
- apps/battery/__init__.py +101 -0
- apps/battery/app.json +1 -0
- apps/bit_world/act_deck.py +683 -0
- apps/bit_world/act_game.py +762 -0
- apps/bit_world/act_pet.py +1032 -0
- apps/bit_world/app.json +1 -0
- apps/bit_world/bit_output.py +45 -0
- apps/bit_world/bit_palette.py +503 -0
- apps/bit_world/bit_sound.py +431 -0
- apps/bit_world/bit_sprites.py +632 -0
- apps/bit_world/bit_world.py +534 -0
- apps/btreceiver/__init__.py +690 -0
- apps/btreceiver/app.json +1 -0
- apps/btreceiver/chime.py +155 -0
- apps/btreceiver/demo.py +529 -0
- apps/btreceiver/screen.py +633 -0
- apps/camera/__init__.py +316 -0
- apps/camera/app.json +1 -0
- apps/card/__init__.py +113 -0
- apps/card/app.json +1 -0
- apps/cast/__init__.py +631 -0
- apps/cast/app.json +1 -0
- apps/cast/receivers.py +193 -0
- apps/chess/__init__.py +18 -0
- apps/chess/app.json +1 -0
- apps/chess/app.py +922 -0
- apps/chess/art.py +323 -0
- apps/chess/ble.py +411 -0
- apps/chess/engine.py +925 -0
- apps/chess/game.py +327 -0
- apps/chess/net.py +261 -0
- apps/clock/__init__.py +38 -0
- apps/clock/app.json +1 -0
- apps/detect/__init__.py +214 -0
- apps/detect/app.json +1 -0
- apps/fmsynth/__init__.py +41 -0
- apps/fmsynth/algorithms.py +61 -0
- apps/fmsynth/app.json +1 -0
- apps/fmsynth/app.py +355 -0
- apps/fmsynth/editor.py +206 -0
- apps/fmsynth/engine.py +257 -0
- apps/fmsynth/meters.py +262 -0
- apps/fmsynth/midi.py +375 -0
- apps/fmsynth/panel_view.py +1071 -0
- apps/fmsynth/patches/fmsynth-01.syx +0 -0
- apps/fmsynth/settings.py +138 -0
- apps/fmsynth/voice.py +398 -0
- apps/gamepad/__init__.py +685 -0
- apps/gamepad/app.json +1 -0
- apps/gamepad/pad.py +94 -0
- apps/gamepad/watch.py +352 -0
- apps/hidden/__init__.py +72 -0
- apps/hidden/app.json +1 -0
- apps/home/__init__.py +483 -0
- apps/home/app.json +1 -0
- apps/home/main.py +36 -0
- apps/homeassistant/__init__.py +213 -0
- apps/homeassistant/api.py +104 -0
- apps/homeassistant/app.json +1 -0
- apps/huey/__init__.py +287 -0
- apps/huey/acting.py +184 -0
- apps/huey/actor.py +194 -0
- apps/huey/app.json +1 -0
- apps/huey/client.py +125 -0
- apps/huey/servers.py +121 -0
- apps/huey/settings.example.json +8 -0
- apps/huey/settings.py +97 -0
- apps/huey/turn.py +504 -0
- apps/huey/voice.py +217 -0
- apps/info/__init__.py +810 -0
- apps/info/app.json +1 -0
- apps/lora/__init__.py +62 -0
- apps/lora/app.json +1 -0
- apps/manifest.py +71 -0
- apps/medialink_baby_monitor/__init__.py +222 -0
- apps/medialink_baby_monitor/app.json +1 -0
- apps/medialink_doorbell/__init__.py +251 -0
- apps/medialink_doorbell/app.json +1 -0
- apps/medialink_hands_free/__init__.py +217 -0
- apps/medialink_hands_free/app.json +1 -0
- apps/medialink_surveillance_camera/__init__.py +258 -0
- apps/medialink_surveillance_camera/app.json +1 -0
- apps/medialink_video_doorbell/__init__.py +289 -0
- apps/medialink_video_doorbell/app.json +1 -0
- apps/medialink_videophone/__init__.py +273 -0
- apps/medialink_videophone/app.json +1 -0
- apps/medialink_walkie_talkie/__init__.py +228 -0
- apps/medialink_walkie_talkie/app.json +1 -0
- apps/midicontroller/__init__.py +774 -0
- apps/midicontroller/app.json +1 -0
- apps/midicontroller/links.py +421 -0
- apps/midicontroller/surface.py +343 -0
- apps/midiengine/__init__.py +977 -0
- apps/midiengine/app.json +1 -0
- apps/midiengine/banks.py +85 -0
- apps/midiengine/midiin.py +165 -0
- apps/midiengine/player.py +392 -0
- apps/midiengine/umidiparser.py +1413 -0
- apps/mp3/__init__.py +240 -0
- apps/mp3/app.json +1 -0
- apps/perch/__init__.py +119 -0
- apps/perch/app.json +1 -0
- apps/perch/huey.py +481 -0
- apps/perch/huey_props.py +386 -0
- apps/perch/huey_shift.py +42 -0
- apps/perch/huey_views.py +296 -0
- apps/perch/scene_bench.py +680 -0
- apps/perch/scene_coast.py +479 -0
- apps/perch/scene_desk.py +492 -0
- apps/perch/stage.py +1274 -0
- apps/perch/vec.py +366 -0
- apps/repl/__init__.py +325 -0
- apps/repl/app.json +1 -0
- apps/roku/__init__.py +156 -0
- apps/roku/app.json +1 -0
- apps/rokucam/__init__.py +362 -0
- apps/rokucam/app.json +1 -0
- apps/security/__init__.py +261 -0
- apps/security/app.json +1 -0
- apps/settings/__init__.py +221 -0
- apps/settings/app.json +1 -0
- apps/shell/__init__.py +33 -0
- apps/shell/app.json +1 -0
- apps/spotify/__init__.py +669 -0
- apps/spotify/app.json +1 -0
- apps/spotify/screen.py +82 -0
- apps/steps/__init__.py +58 -0
- apps/steps/app.json +1 -0
- apps/stompbox/__init__.py +31 -0
- apps/stompbox/app.json +1 -0
- apps/stompbox/app.py +668 -0
- apps/stompbox/boards.json +20 -0
- apps/stompbox/effects.py +241 -0
- apps/stompbox/engine.py +340 -0
- apps/stompbox/footswitch.py +331 -0
- apps/stompbox/inputs.py +449 -0
- apps/stompbox/meter.py +72 -0
- apps/stompbox/outputs.py +135 -0
- apps/stompbox/pedals.txt +45 -0
- apps/stompbox/presets.py +106 -0
- apps/stompbox/styles.py +135 -0
- apps/stompbox/ui.py +817 -0
- apps/stompbox/wavfile.py +73 -0
- apps/synthstation/__init__.py +20 -0
- apps/synthstation/app.json +1 -0
- apps/synthstation/audio.py +397 -0
- apps/synthstation/catalog.py +50 -0
- apps/synthstation/meters.py +136 -0
- apps/synthstation/midi.py +380 -0
- apps/synthstation/pads.py +177 -0
- apps/synthstation/parts.py +128 -0
- apps/synthstation/station.py +1069 -0
- apps/system/__init__.py +11 -0
- apps/system/app.json +1 -0
- apps/touchcal/__init__.py +324 -0
- apps/touchcal/app.json +1 -0
- apps/touchcal/fit.py +262 -0
- apps/wake/__init__.py +268 -0
- apps/wake/app.json +1 -0
- apps/wake/feed.py +155 -0
- apps/watch/__init__.py +355 -0
- apps/watch/app.json +1 -0
- apps/watch/faces.py +35 -0
- apps/watch/wheel.py +157 -0
- apps/weather/__init__.py +278 -0
- apps/weather/app.json +1 -0
- apps/weather/icons.py +172 -0
- apps/weather/sizing.py +71 -0
- apps/weather/zippad.py +172 -0
- omnipython_apps-0.1.4.dev8.dist-info/METADATA +33 -0
- omnipython_apps-0.1.4.dev8.dist-info/RECORD +218 -0
- omnipython_apps-0.1.4.dev8.dist-info/WHEEL +5 -0
- omnipython_apps-0.1.4.dev8.dist-info/top_level.txt +1 -0
apps/__init__.py
ADDED
apps/about/__init__.py
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""About: what this board is and the software on it.
|
|
5
|
+
|
|
6
|
+
One scrolling page of cards: the board's name and chip, the firmware and
|
|
7
|
+
OmniPython versions, each installed package's version, memory and storage,
|
|
8
|
+
the network and its address, then the open-source licences and credits,
|
|
9
|
+
the firmware's own among them.
|
|
10
|
+
Info is the page for how the board is doing now; this is the page for what
|
|
11
|
+
it is. A line is left out when this platform can't say it.
|
|
12
|
+
|
|
13
|
+
`rows` returns the same facts as lists, so the REPL can print them::
|
|
14
|
+
|
|
15
|
+
>>> import apps.about
|
|
16
|
+
>>> apps.about.rows()
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import lvgl as lv
|
|
20
|
+
|
|
21
|
+
from appkit import assets, shell
|
|
22
|
+
from touchkit import net, ui
|
|
23
|
+
|
|
24
|
+
from ..info import stats
|
|
25
|
+
from . import facts
|
|
26
|
+
from .credits import SECTIONS
|
|
27
|
+
|
|
28
|
+
#: The Montserrat sizes LVGL builds, and those of the fonts in fonts/ (tools/make_fonts.py).
|
|
29
|
+
_SIZES = (14, 16, 24, 32, 40)
|
|
30
|
+
#: Milliseconds between two steps of filling in the page, so a tap or a drag is heard between them.
|
|
31
|
+
STEP_MS = 10
|
|
32
|
+
|
|
33
|
+
_HERE = __file__.replace("\\", "/").rsplit("/", 1)[0]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def rows():
|
|
37
|
+
"""The page as ``[(card title, [(name, value), ...]), ...]``, without opening it.
|
|
38
|
+
|
|
39
|
+
The licences card is not here: it is text, not rows (`facts.installed_licences`,
|
|
40
|
+
`facts.firmware_notices`, `facts.notices` and `credits.SECTIONS`).
|
|
41
|
+
"""
|
|
42
|
+
s = stats()
|
|
43
|
+
cards = [
|
|
44
|
+
("Board", facts.board_rows(s, net.hostname())),
|
|
45
|
+
("Firmware", facts.firmware_rows(s)),
|
|
46
|
+
("Packages", facts.packages()),
|
|
47
|
+
("Memory and storage", facts.memory_rows()),
|
|
48
|
+
("Network", facts.network_rows(s.get("ip"))),
|
|
49
|
+
]
|
|
50
|
+
return [(title, r) for title, r in cards if r]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _font(short, share):
|
|
54
|
+
"""The largest Montserrat this firmware has at or below *short* / *share*, or its smallest,
|
|
55
|
+
with the accented letters of Latin-1 from fonts/ in front of it.
|
|
56
|
+
|
|
57
|
+
LVGL's own Montserrat stops at ASCII. The file's font has only the letters
|
|
58
|
+
past it and hands the rest to the built-in one, so a name like Zoltán
|
|
59
|
+
Vörös draws. The caller frees it with ``lv.binfont_destroy`` once
|
|
60
|
+
nothing draws with it.
|
|
61
|
+
"""
|
|
62
|
+
limit = short // share
|
|
63
|
+
best = None
|
|
64
|
+
for size in _SIZES:
|
|
65
|
+
if getattr(lv, "font_montserrat_%d" % size, None) is not None and (best is None or size <= limit):
|
|
66
|
+
best = size
|
|
67
|
+
if best is None: # a firmware with none of these sizes: ASCII only
|
|
68
|
+
return lv.font_get_default()
|
|
69
|
+
data = assets.read("%s/fonts/latin1_%d.bin" % (_HERE, best), binary=True)
|
|
70
|
+
font = lv.binfont_create_from_buffer(data, len(data))
|
|
71
|
+
if font is None:
|
|
72
|
+
raise OSError("About couldn't load fonts/latin1_%d.bin" % best)
|
|
73
|
+
font.fallback = getattr(lv, "font_montserrat_%d" % best)
|
|
74
|
+
return font
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _card(parent, pad):
|
|
78
|
+
c = lv.obj(parent)
|
|
79
|
+
c.set_width(lv.pct(100))
|
|
80
|
+
c.set_height(lv.SIZE_CONTENT)
|
|
81
|
+
c.set_style_bg_color(ui.PANEL, 0)
|
|
82
|
+
c.set_style_text_color(ui.WHITE, 0)
|
|
83
|
+
c.set_style_border_width(0, 0)
|
|
84
|
+
c.set_style_radius(pad * 2, 0)
|
|
85
|
+
c.set_style_pad_all(pad, 0)
|
|
86
|
+
c.set_style_pad_gap(pad // 2, 0)
|
|
87
|
+
c.set_flex_flow(lv.FLEX_FLOW.COLUMN)
|
|
88
|
+
c.remove_flag(lv.obj.FLAG.SCROLLABLE)
|
|
89
|
+
c.add_flag(lv.obj.FLAG.EVENT_BUBBLE) # a drag that starts on a card scrolls the page
|
|
90
|
+
return c
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _heading(card, text):
|
|
94
|
+
return ui.label(card, text, None, ui.ACCENT)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _row(card, key, value, pad):
|
|
98
|
+
row = ui.plain(lv.obj(card))
|
|
99
|
+
row.set_width(lv.pct(100))
|
|
100
|
+
row.set_height(lv.SIZE_CONTENT)
|
|
101
|
+
row.set_flex_flow(lv.FLEX_FLOW.ROW)
|
|
102
|
+
row.set_style_pad_column(pad, 0) # a key never runs into its value
|
|
103
|
+
row.add_flag(lv.obj.FLAG.EVENT_BUBBLE)
|
|
104
|
+
k = ui.label(row, key, None, ui.MUTED)
|
|
105
|
+
k.set_width(lv.SIZE_CONTENT)
|
|
106
|
+
v = lv.label(row)
|
|
107
|
+
v.set_text(value)
|
|
108
|
+
v.set_flex_grow(1)
|
|
109
|
+
v.set_long_mode(lv.label.LONG_MODE.WRAP)
|
|
110
|
+
v.set_style_text_align(lv.TEXT_ALIGN.RIGHT, 0)
|
|
111
|
+
return k, v
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def _text(card, text, color):
|
|
115
|
+
t = ui.label(card, facts.reflow(text), None, color)
|
|
116
|
+
t.set_width(lv.pct(100))
|
|
117
|
+
t.set_long_mode(lv.label.LONG_MODE.WRAP)
|
|
118
|
+
return t
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _cards(page, pad, cards):
|
|
122
|
+
for title, items in cards:
|
|
123
|
+
if items:
|
|
124
|
+
card = _card(page, pad)
|
|
125
|
+
_heading(card, title)
|
|
126
|
+
_rows(card, items, pad)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def _rows(card, items, pad):
|
|
130
|
+
"""Add *items* to *card*, which stays hidden while it has none."""
|
|
131
|
+
for key, value in items:
|
|
132
|
+
_row(card, key, value, pad)
|
|
133
|
+
if card.get_child_count() > 1: # more than its heading
|
|
134
|
+
card.remove_flag(lv.obj.FLAG.HIDDEN)
|
|
135
|
+
else:
|
|
136
|
+
card.add_flag(lv.obj.FLAG.HIDDEN)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class _Packages:
|
|
140
|
+
"""The Packages card, kept sorted as versions found later come in.
|
|
141
|
+
|
|
142
|
+
A board can have seventy packages, so the card is two labels, the names
|
|
143
|
+
and the versions, one line each, rather than a row of three objects for
|
|
144
|
+
each: on an ESP32-S3 the rows took most of a second to make.
|
|
145
|
+
"""
|
|
146
|
+
|
|
147
|
+
def __init__(self, page, pad, known):
|
|
148
|
+
self.card = _card(page, pad)
|
|
149
|
+
_heading(self.card, "Packages")
|
|
150
|
+
self.names, self.versions = _row(self.card, "", "", pad)
|
|
151
|
+
for label in (self.names, self.versions):
|
|
152
|
+
label.set_style_text_line_space(pad // 2, 0) # spaced as the other cards' rows
|
|
153
|
+
self.found = dict(known)
|
|
154
|
+
self._show()
|
|
155
|
+
|
|
156
|
+
def add(self, name, version):
|
|
157
|
+
self.found[name] = version
|
|
158
|
+
self._show()
|
|
159
|
+
|
|
160
|
+
def _show(self):
|
|
161
|
+
found = sorted(self.found.items(), key=lambda r: r[0].lower())
|
|
162
|
+
self.names.set_text("\n".join(n for n, _ in found))
|
|
163
|
+
self.versions.set_text("\n".join(v for _, v in found))
|
|
164
|
+
if found:
|
|
165
|
+
self.card.remove_flag(lv.obj.FLAG.HIDDEN)
|
|
166
|
+
else:
|
|
167
|
+
self.card.add_flag(lv.obj.FLAG.HIDDEN)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def _steps(memory, packages, licences, known, pad):
|
|
171
|
+
"""What fills in the page after it is drawn, one short step each.
|
|
172
|
+
|
|
173
|
+
Free storage, the firmware's notices, then each folder on the board, which
|
|
174
|
+
may add a package's version and its licence, then this repository's credits.
|
|
175
|
+
"""
|
|
176
|
+
yield lambda: _rows(memory, facts.storage_rows(), pad)
|
|
177
|
+
for title, text in facts.firmware_notices():
|
|
178
|
+
yield lambda t=title, x=text: _notice(licences, t, x)
|
|
179
|
+
for root, name, is_lib in facts.folders():
|
|
180
|
+
yield lambda r=root, n=name, lib=is_lib: _folder(packages, licences, known, r, n, lib)
|
|
181
|
+
for title, text in SECTIONS:
|
|
182
|
+
yield lambda t=title, x=text: _notice(licences, t, x)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def _notice(card, title, text):
|
|
186
|
+
_text(card, title, ui.WHITE)
|
|
187
|
+
_text(card, text, ui.MUTED)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def _folder(packages, licences, known, root, name, is_lib):
|
|
191
|
+
version, notice = facts.folder_facts(root, name, is_lib, known)
|
|
192
|
+
if version:
|
|
193
|
+
known[name] = version
|
|
194
|
+
packages.add(name, version)
|
|
195
|
+
if notice:
|
|
196
|
+
_notice(licences, name, notice)
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def main(scope):
|
|
200
|
+
W, H = scope.size
|
|
201
|
+
short = min(W, H)
|
|
202
|
+
root = scope.root
|
|
203
|
+
root.set_style_bg_color(ui.BG, 0)
|
|
204
|
+
root.set_style_bg_opa(lv.OPA.COVER, 0)
|
|
205
|
+
pad = max(4, short // 40)
|
|
206
|
+
# A round screen keeps to the square inside its circle.
|
|
207
|
+
side = W * 3 // 20 if shell.is_round() else pad
|
|
208
|
+
|
|
209
|
+
page = ui.plain(lv.obj(root))
|
|
210
|
+
page.set_size(W, H)
|
|
211
|
+
font = _font(short, 20)
|
|
212
|
+
page.set_style_text_font(font, 0)
|
|
213
|
+
page.set_style_pad_hor(side, 0)
|
|
214
|
+
page.set_style_pad_ver(pad, 0)
|
|
215
|
+
page.set_style_pad_gap(pad, 0)
|
|
216
|
+
page.set_flex_flow(lv.FLEX_FLOW.COLUMN)
|
|
217
|
+
page.add_flag(lv.obj.FLAG.SCROLLABLE)
|
|
218
|
+
page.set_scroll_dir(lv.DIR.VER)
|
|
219
|
+
if font is not lv.font_get_default():
|
|
220
|
+
|
|
221
|
+
@scope.on_close
|
|
222
|
+
def free_font():
|
|
223
|
+
page.delete() # nothing may draw with the font once it's gone
|
|
224
|
+
lv.binfont_destroy(font)
|
|
225
|
+
|
|
226
|
+
# What the board can say at once goes on the first screen. Looking in each
|
|
227
|
+
# folder on the board takes a while (importing a package to read its
|
|
228
|
+
# version, opening its licence), so that comes after, a folder at a time.
|
|
229
|
+
s = stats()
|
|
230
|
+
on_board = facts.on_board()
|
|
231
|
+
known = facts.known_packages() if on_board else dict(facts.packages())
|
|
232
|
+
_cards(page, pad, (("Board", facts.board_rows(s, net.hostname())), ("Firmware", facts.firmware_rows(s))))
|
|
233
|
+
packages = _Packages(page, pad, known)
|
|
234
|
+
memory = _card(page, pad)
|
|
235
|
+
_heading(memory, "Memory and storage")
|
|
236
|
+
_rows(memory, facts.memory_rows(storage=False), pad)
|
|
237
|
+
_cards(page, pad, (("Network", facts.network_rows(s.get("ip"))),))
|
|
238
|
+
|
|
239
|
+
# The licences: each installed package's own, what the firmware was built
|
|
240
|
+
# from, each package folder's notice, then what this repository's apps carry.
|
|
241
|
+
licences = _card(page, pad)
|
|
242
|
+
_heading(licences, "Licences and credits")
|
|
243
|
+
for key, value in facts.installed_licences():
|
|
244
|
+
_row(licences, key, value, pad)
|
|
245
|
+
|
|
246
|
+
# Draw this much now, so the steps add to a page already showing rather
|
|
247
|
+
# than hold back the first screen.
|
|
248
|
+
lv.refr_now(None)
|
|
249
|
+
steps = _steps(memory, packages, licences, known, pad)
|
|
250
|
+
|
|
251
|
+
def step(timer):
|
|
252
|
+
for fill in steps:
|
|
253
|
+
fill()
|
|
254
|
+
scope.after(STEP_MS, step)
|
|
255
|
+
return
|
|
256
|
+
|
|
257
|
+
scope.after(STEP_MS, step)
|
apps/about/app.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name": "about", "title": "About", "category": "System", "icon": "badge", "color": "#5A3E6B"}
|
apps/about/credits.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""The licence and credits About shows. Generated by tools/about_credits.py; edit the sources, not this."""
|
|
5
|
+
|
|
6
|
+
SECTIONS = (
|
|
7
|
+
("PyDevices apps", "MIT License\n\nCopyright (c) 2026 Brad Barnett\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE."),
|
|
8
|
+
("About", "About draws accented letters with fonts made from another project.\n\nFonts (apps/about/fonts)\n Montserrat Medium, copyright 2011 The Montserrat Project Authors\n (https://github.com/JulietaUla/Montserrat), under the SIL Open Font\n License, Version 1.1 (apps/about/fonts/OFL.txt). The .bin files are\n bitmap fonts of the Latin-1 letters past ASCII, made with lv_font_conv\n by tools/make_fonts.py from the TTF LVGL keeps in its repository."),
|
|
9
|
+
("Chess", "engine.py is a port to Python of p4wn's engine (src/engine.js), by Douglas\nBagnall and the p4wn contributors: https://github.com/douglasbagnall/p4wn,\nat commit fcdda9f5d7ae34bbbacc4caacdc78507b6a20394.\n\np4wn is in the public domain. Its README dedicates every contribution to it\nto the public domain (CC0), and engine.js's header, kept at the top of\nengine.py, reads:\n\n /* p4wn, AKA 5k chess - by Douglas Bagnall <douglas@paradise.net.nz>\n *\n * This code is in the public domain, or as close to it as various\n * laws allow. No warranty; no restrictions.\n *\n * lives at http://p4wn.sf.net/\n */\n\nThe port keeps p4wn's board, move scoring and search, and adds a deadline,\ndeepening one ply at a time, noise for the low levels and perft counting.\nIt is released under this repository's MIT licence.\n\nThe pieces, boards and every other picture are original, drawn for this app\nas SVG in art.py."),
|
|
10
|
+
("Eye Camera", "Camera uses artwork and fonts from other projects.\n\nPictures (apps/eyecam/images)\n The 21 pictures are Espressif's, from the ESP32-P4-EYE factory demo\n (https://github.com/espressif/esp-dev-kits, examples/esp32-p4-eye/\n examples/factory_demo/main/ui/images, commit 5c06bf1). The demo's code is\n \"Apache License 2.0\" under that repository's LICENSE-APACHE, and these\n files are SquareLine Studio exports in that code. Copyright Espressif\n Systems (Shanghai) CO LTD. Changed here: each was converted from an LVGL 8\n C array to an LVGL 9 .bin file (RGB565 with an alpha plane); the pixels\n are the same. The licence text is in LICENSE-APACHE.\n\nFonts (apps/eyecam/fonts)\n KoHo Bold and SemiBold, copyright 2018 The KoHo Project Authors\n (https://github.com/cadsondemak/Koho), under the SIL Open Font License,\n Version 1.1 (apps/eyecam/fonts/OFL.txt). The .bin files are bitmap fonts\n made from the TTFs in tools/fonts with lv_font_conv.\n\nThe page layout, texts and behaviour follow the same factory demo."),
|
|
11
|
+
("FM Synth", "Code adapted from other parts of this repository (github.com/PyDevices/apps),\nall MIT:\n\n - midi.py: the `Inputs` class, with its Bluetooth MIDI input (`set_ble`\n and `ble_available`), is adapted from Synth Station's\n apps/synthstation/midi.py.\n - app.py: `App.set_ble`, which turns Bluetooth MIDI on and remembers the\n choice, is adapted from Synth Station's apps/synthstation/station.py.\n - meters.py: the level, load and underrun readings and the meter's fall\n are adapted from Synth Station's apps/synthstation/audio.py and\n apps/synthstation/meters.py.\n - algorithms.py: the table of 32 algorithms is copied from controlkit's\n examples/routing_algorithms.py.\n\nThe bank in patches/ is original, generated by tools/make_bank.py. It holds\nno factory voices."),
|
|
12
|
+
)
|
apps/about/facts.py
ADDED
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""What About shows, read from the running system and left out when a platform can't say.
|
|
5
|
+
|
|
6
|
+
Nothing here draws. Each function returns plain rows, ``(name, value)``
|
|
7
|
+
pairs, so the REPL can print them and a test can check them. A row whose
|
|
8
|
+
answer isn't known is not in the list: nothing is guessed, and nothing
|
|
9
|
+
is filled in with a dash.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import gc
|
|
13
|
+
import os
|
|
14
|
+
import sys
|
|
15
|
+
|
|
16
|
+
try:
|
|
17
|
+
import importlib.metadata as metadata
|
|
18
|
+
except ImportError: # MicroPython and CircuitPython have no package metadata
|
|
19
|
+
metadata = None
|
|
20
|
+
|
|
21
|
+
#: ``sys.platform`` of a computer: there the library folders are the computer's own, not a board's.
|
|
22
|
+
DESKTOP = ("linux", "darwin", "win32", "cygwin", "emscripten")
|
|
23
|
+
#: Files a package may carry its licence or credits in.
|
|
24
|
+
NOTICE_FILES = ("LICENSE", "LICENSE.txt", "LICENSE.md", "NOTICE", "NOTICE.txt", "COPYING")
|
|
25
|
+
#: Longest a licence file's text is shown, in characters: a full licence is pages.
|
|
26
|
+
NOTICE_MAX = 1200
|
|
27
|
+
|
|
28
|
+
_FAMILY = ("github.com/pydevices", "pydevices.com")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def size(n):
|
|
32
|
+
"""Bytes as ``"640 KB"``, ``"7.88 MB"`` or ``"1.20 GB"``."""
|
|
33
|
+
if n >= 1000000000:
|
|
34
|
+
return "%.2f GB" % (n / 1e9)
|
|
35
|
+
return "%.2f MB" % (n / 1e6) if n >= 1000000 else "%d KB" % (n // 1024)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _each_dist():
|
|
39
|
+
return metadata.distributions() if metadata is not None else ()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _is_ours(dist):
|
|
43
|
+
"""Whether a distribution comes from PyDevices: one of its project URLs says so."""
|
|
44
|
+
urls = [dist.metadata.get("Home-page") or ""] + (dist.metadata.get_all("Project-URL") or [])
|
|
45
|
+
return any(f in u.lower() for u in urls for f in _FAMILY)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _dist_name(dist):
|
|
49
|
+
return dist.metadata["Name"]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def recorded_versions():
|
|
53
|
+
"""``{name: version}`` from omip: what the firmware froze in and what omip installed.
|
|
54
|
+
|
|
55
|
+
Empty where omip isn't there, or is a copy from before it kept a record.
|
|
56
|
+
A package whose version wasn't known when it was installed is left out.
|
|
57
|
+
"""
|
|
58
|
+
try:
|
|
59
|
+
import omip
|
|
60
|
+
|
|
61
|
+
found = omip.versions()
|
|
62
|
+
except (ImportError, AttributeError):
|
|
63
|
+
return {}
|
|
64
|
+
return {name: version for name, version in found.items() if version}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def omnipython_version():
|
|
68
|
+
"""OmniPython's version, or None when this copy doesn't carry one.
|
|
69
|
+
|
|
70
|
+
omip's record says it on a board, whether the firmware froze it in or omip
|
|
71
|
+
installed it. A pip install says it in its metadata. Failing both, a copy
|
|
72
|
+
may have it stamped on its core modules, so ``boarddev`` (which every board
|
|
73
|
+
imports) tells.
|
|
74
|
+
"""
|
|
75
|
+
recorded = recorded_versions().get("omnipython")
|
|
76
|
+
if recorded:
|
|
77
|
+
return recorded
|
|
78
|
+
# Not omnipython-lvgl: that wheel carries LVGL's version, not OmniPython's.
|
|
79
|
+
for name in ("omnipython", "omnipython-desktop"):
|
|
80
|
+
if metadata is not None:
|
|
81
|
+
try:
|
|
82
|
+
return metadata.version(name)
|
|
83
|
+
except Exception:
|
|
84
|
+
pass
|
|
85
|
+
try:
|
|
86
|
+
import boarddev
|
|
87
|
+
|
|
88
|
+
return getattr(boarddev, "__version__", None)
|
|
89
|
+
except ImportError:
|
|
90
|
+
return None
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def on_board():
|
|
94
|
+
"""Whether this is a board, where the library folders hold what omip installed."""
|
|
95
|
+
return sys.platform not in DESKTOP
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _is_dir(path):
|
|
99
|
+
try:
|
|
100
|
+
return bool(os.stat(path)[0] & 0x4000)
|
|
101
|
+
except OSError:
|
|
102
|
+
return False
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _lib_dirs():
|
|
106
|
+
"""The folders on the path that a board's libraries were installed into: not the firmware's own, not the working folder."""
|
|
107
|
+
if not on_board():
|
|
108
|
+
return []
|
|
109
|
+
return [p for p in sys.path if p not in ("", ".", ".frozen") and p.startswith("/") and _is_dir(p)]
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _app_dirs():
|
|
113
|
+
"""The folder this app was installed in, which holds the other apps: omip puts apps wherever the board's Home looks."""
|
|
114
|
+
try:
|
|
115
|
+
here = __file__
|
|
116
|
+
except NameError:
|
|
117
|
+
return []
|
|
118
|
+
base = here.rsplit("/", 2)[0] if "/" in here else ""
|
|
119
|
+
return [base] if base and _is_dir(base) else []
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def _subfolders(root):
|
|
123
|
+
"""The names of the folders in *root*, from one listing of it."""
|
|
124
|
+
try:
|
|
125
|
+
if hasattr(os, "ilistdir"):
|
|
126
|
+
return [entry[0] for entry in os.ilistdir(root) if entry[1] == 0x4000]
|
|
127
|
+
return [name for name in os.listdir(root) if _is_dir("%s/%s" % (root, name))]
|
|
128
|
+
except OSError:
|
|
129
|
+
return []
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def folders():
|
|
133
|
+
"""``[(root, name, is_lib)]``: each folder About looks in on a board, sorted by name.
|
|
134
|
+
|
|
135
|
+
The package folders on the library path (*is_lib* True), then the apps
|
|
136
|
+
beside this one, each listed once. Empty on a computer. `folder_facts`
|
|
137
|
+
looks in one of them, so a page can show them one at a time.
|
|
138
|
+
"""
|
|
139
|
+
if not on_board():
|
|
140
|
+
return []
|
|
141
|
+
out = [(root, name, True) for root in _lib_dirs() for name in _subfolders(root)]
|
|
142
|
+
out += [(root, name, False) for root in _app_dirs() for name in _subfolders(root)]
|
|
143
|
+
return sorted(out, key=lambda f: (not f[2], f[1]))
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _version_of(module):
|
|
147
|
+
v = getattr(module, "__version__", None)
|
|
148
|
+
return v if isinstance(v, str) else None
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def known_packages():
|
|
152
|
+
"""``{name: version}`` for what a board can say without looking in its folders.
|
|
153
|
+
|
|
154
|
+
omip's record of what the firmware froze in and what omip installed, then
|
|
155
|
+
every module already loaded that stamps a version on itself.
|
|
156
|
+
"""
|
|
157
|
+
found = recorded_versions()
|
|
158
|
+
for name, module in list(sys.modules.items()):
|
|
159
|
+
if "." not in name and not name.startswith("_") and name not in found:
|
|
160
|
+
v = _version_of(module)
|
|
161
|
+
if v:
|
|
162
|
+
found[name] = v
|
|
163
|
+
return found
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def _import_version(name):
|
|
167
|
+
"""The version a package stamps on itself, imported and then forgotten again, or None."""
|
|
168
|
+
before = set(sys.modules)
|
|
169
|
+
try:
|
|
170
|
+
v = _version_of(__import__(name))
|
|
171
|
+
except Exception: # an import that fails (or runs out of heap) is just not listed
|
|
172
|
+
v = None
|
|
173
|
+
for key in set(sys.modules) - before:
|
|
174
|
+
del sys.modules[key]
|
|
175
|
+
gc.collect()
|
|
176
|
+
return v
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def folder_facts(root, name, is_lib, known=None):
|
|
180
|
+
"""``(version, notice)`` for one of `folders`, from one listing of it.
|
|
181
|
+
|
|
182
|
+
*version* is for a package on the library path that *known* (from
|
|
183
|
+
`known_packages`) doesn't have: the folder is imported to read it, since
|
|
184
|
+
only a folder with no record of its own gets this far. Pass no *known* to
|
|
185
|
+
skip that. *notice* is the licence or credits file the folder carries,
|
|
186
|
+
shortened to `NOTICE_MAX`. Either is None when there's none.
|
|
187
|
+
"""
|
|
188
|
+
path = "%s/%s" % (root, name)
|
|
189
|
+
try:
|
|
190
|
+
names = os.listdir(path)
|
|
191
|
+
except OSError:
|
|
192
|
+
return None, None
|
|
193
|
+
version = None
|
|
194
|
+
if (
|
|
195
|
+
is_lib
|
|
196
|
+
and known is not None
|
|
197
|
+
and name not in known
|
|
198
|
+
and name not in sys.modules
|
|
199
|
+
and not name.startswith((".", "_"))
|
|
200
|
+
and ("__init__.py" in names or "__init__.mpy" in names)
|
|
201
|
+
):
|
|
202
|
+
version = _import_version(name)
|
|
203
|
+
notice = None
|
|
204
|
+
for fname in NOTICE_FILES:
|
|
205
|
+
if fname in names:
|
|
206
|
+
text = _read("%s/%s" % (path, fname))
|
|
207
|
+
if text:
|
|
208
|
+
notice = _clip(text)
|
|
209
|
+
break
|
|
210
|
+
return version, notice
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def _board_packages():
|
|
214
|
+
"""``{name: version}`` for what a board has: `known_packages`, then each
|
|
215
|
+
package folder on the library path that they leave out."""
|
|
216
|
+
found = known_packages()
|
|
217
|
+
for root, name, is_lib in folders():
|
|
218
|
+
if is_lib:
|
|
219
|
+
version, _ = folder_facts(root, name, True, found)
|
|
220
|
+
if version:
|
|
221
|
+
found[name] = version
|
|
222
|
+
return found
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def packages():
|
|
226
|
+
"""``[(name, version), ...]`` for the PyDevices packages installed here, sorted.
|
|
227
|
+
|
|
228
|
+
On a computer these are the pip distributions that name PyDevices as their
|
|
229
|
+
home. On a board they are what omip's record lists, frozen in or installed,
|
|
230
|
+
and the packages that stamp a version on themselves.
|
|
231
|
+
"""
|
|
232
|
+
if metadata is not None and sys.implementation.name == "cpython":
|
|
233
|
+
return sorted({(_dist_name(d), d.version) for d in _each_dist() if _is_ours(d)}, key=lambda r: r[0].lower())
|
|
234
|
+
return sorted(_board_packages().items(), key=lambda r: r[0].lower())
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def _mem():
|
|
238
|
+
if not hasattr(gc, "mem_free"):
|
|
239
|
+
return None
|
|
240
|
+
free, used = gc.mem_free(), gc.mem_alloc()
|
|
241
|
+
return "%s free of %s" % (size(free), size(free + used))
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def _disk():
|
|
245
|
+
# The board's own filesystem: the root, or /flash where the root is only a place to mount others (STM32).
|
|
246
|
+
for path in ("/", "/flash"):
|
|
247
|
+
try:
|
|
248
|
+
st = os.statvfs(path)
|
|
249
|
+
except (AttributeError, OSError):
|
|
250
|
+
continue
|
|
251
|
+
block, total, free = st[1] or st[0], st[2], st[3]
|
|
252
|
+
if total:
|
|
253
|
+
return "%s free of %s" % (size(free * block), size(total * block))
|
|
254
|
+
return None
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def memory_rows(storage=True):
|
|
258
|
+
"""Free memory, and free storage unless *storage* is False: asking the
|
|
259
|
+
filesystem can take most of a second on a board, as it counts every block."""
|
|
260
|
+
rows = [("Memory", _mem())]
|
|
261
|
+
if storage:
|
|
262
|
+
rows.append(("Storage", _disk()))
|
|
263
|
+
return [r for r in rows if r[1]]
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def storage_rows():
|
|
267
|
+
"""Free storage on the board's own filesystem, the part of `memory_rows` that can be slow."""
|
|
268
|
+
return [r for r in (("Storage", _disk()),) if r[1]]
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def network_rows(ip=None):
|
|
272
|
+
"""The Wi-Fi network's name and this board's address. *ip* is the address,
|
|
273
|
+
when the caller already has it."""
|
|
274
|
+
rows = []
|
|
275
|
+
ssid = None
|
|
276
|
+
try:
|
|
277
|
+
import wifi
|
|
278
|
+
|
|
279
|
+
info = wifi.radio.ap_info
|
|
280
|
+
ssid = info.ssid if info is not None else None
|
|
281
|
+
if isinstance(ssid, bytes):
|
|
282
|
+
ssid = ssid.decode()
|
|
283
|
+
except Exception: # no radio, not joined, or a computer
|
|
284
|
+
pass
|
|
285
|
+
if ssid:
|
|
286
|
+
rows.append(("Network", ssid))
|
|
287
|
+
if ip:
|
|
288
|
+
rows.append(("Address", ip))
|
|
289
|
+
return rows
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
def board_rows(stats, name):
|
|
293
|
+
"""The board's name and what it is, from `apps.info.stats` and ``boarddev.name()``."""
|
|
294
|
+
rows = [("Name", name), ("Board", stats.get("board")), ("Chip", chip(stats))]
|
|
295
|
+
return [r for r in rows if r[1]]
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
def chip(s):
|
|
299
|
+
parts = [p for p in (s.get("cpu"), s.get("mhz") and "%d MHz" % s["mhz"]) if p]
|
|
300
|
+
return ", ".join(parts) or None
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def firmware_rows(stats):
|
|
304
|
+
"""The interpreter, its build and the day it was made, and OmniPython's version."""
|
|
305
|
+
build = getattr(sys.implementation, "_build", None)
|
|
306
|
+
rows = [("Python", stats.get("python")), ("Build", build), ("Built", stats.get("built")), ("OmniPython", omnipython_version())]
|
|
307
|
+
return [r for r in rows if r[1]]
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
def _read(path):
|
|
311
|
+
try:
|
|
312
|
+
with open(path) as f:
|
|
313
|
+
return f.read(NOTICE_MAX + 1)
|
|
314
|
+
except (OSError, UnicodeError):
|
|
315
|
+
return None
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def _clip(text):
|
|
319
|
+
text = text.strip()
|
|
320
|
+
return text if len(text) <= NOTICE_MAX else text[:NOTICE_MAX].rsplit("\n", 1)[0] + "\n..."
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
def _dist_notice(dist):
|
|
324
|
+
exp = dist.metadata.get("License-Expression") or dist.metadata.get("License") or ""
|
|
325
|
+
if not exp or len(exp) > 80 or "\n" in exp:
|
|
326
|
+
classes = [c.rsplit("::", 1)[1].strip() for c in dist.metadata.get_all("Classifier") or [] if c.startswith("License ::")]
|
|
327
|
+
exp = ", ".join(classes)
|
|
328
|
+
return exp
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def _installed_closure():
|
|
332
|
+
"""The distributions OmniPython's own depend on, found by following their requirements."""
|
|
333
|
+
by_name = {_dist_name(d).lower().replace("_", "-"): d for d in _each_dist()}
|
|
334
|
+
todo = [n for n, d in by_name.items() if _is_ours(d)]
|
|
335
|
+
seen = {}
|
|
336
|
+
while todo:
|
|
337
|
+
name = todo.pop()
|
|
338
|
+
dist = by_name.get(name)
|
|
339
|
+
if dist is None or name in seen:
|
|
340
|
+
continue
|
|
341
|
+
seen[name] = dist
|
|
342
|
+
for req in dist.requires or ():
|
|
343
|
+
if "extra ==" in req:
|
|
344
|
+
continue
|
|
345
|
+
dep = req.split(";")[0]
|
|
346
|
+
for ch in "<>=!~[( ":
|
|
347
|
+
dep = dep.split(ch)[0]
|
|
348
|
+
todo.append(dep.strip().lower().replace("_", "-"))
|
|
349
|
+
return sorted(seen.values(), key=lambda d: _dist_name(d).lower())
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
def installed_licences():
|
|
353
|
+
"""``[(name, licence)]`` for each PyDevices package installed on a computer and what it requires,
|
|
354
|
+
as their own metadata says; empty on a board, which has `notices` instead."""
|
|
355
|
+
rows = []
|
|
356
|
+
if metadata is not None and sys.implementation.name == "cpython":
|
|
357
|
+
for d in _installed_closure():
|
|
358
|
+
lic = _dist_notice(d)
|
|
359
|
+
if lic:
|
|
360
|
+
rows.append(("%s %s" % (_dist_name(d), d.version), lic))
|
|
361
|
+
return rows
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
def notices():
|
|
365
|
+
"""``[(package, text)]``: the licence or credits file each package folder on a board carries, if it has one."""
|
|
366
|
+
out = []
|
|
367
|
+
for root, name, is_lib in folders():
|
|
368
|
+
_, text = folder_facts(root, name, is_lib)
|
|
369
|
+
if text:
|
|
370
|
+
out.append((name, text))
|
|
371
|
+
return sorted(out)
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
def firmware_notices():
|
|
375
|
+
"""``[(title, text)]``: the third-party notices the firmware carries for what it was built from.
|
|
376
|
+
|
|
377
|
+
Empty on a firmware that carries none, and on a computer.
|
|
378
|
+
"""
|
|
379
|
+
try:
|
|
380
|
+
import firmware_info
|
|
381
|
+
except ImportError:
|
|
382
|
+
return []
|
|
383
|
+
return firmware_info.notices()
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
def reflow(text):
|
|
387
|
+
"""Join the lines of each paragraph that was wrapped for a terminal, so the screen wraps it to its own width.
|
|
388
|
+
|
|
389
|
+
A paragraph with an indented or bulleted line is a list: it keeps its breaks.
|
|
390
|
+
"""
|
|
391
|
+
out = []
|
|
392
|
+
for para in text.split("\n\n"):
|
|
393
|
+
lines = para.split("\n")
|
|
394
|
+
if any(l[:1] in (" ", "-", "\t") for l in lines[1:]) or any(l[:1] in (" ", "-") for l in lines[:1]):
|
|
395
|
+
out.append(para)
|
|
396
|
+
else:
|
|
397
|
+
out.append(" ".join(l.strip() for l in lines))
|
|
398
|
+
return "\n\n".join(out)
|