magmascript 4.0.1__tar.gz → 4.1.0__tar.gz
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.
- {magmascript-4.0.1 → magmascript-4.1.0}/PKG-INFO +2 -2
- {magmascript-4.0.1 → magmascript-4.1.0}/README.md +1 -1
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/cli.py +1 -1
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/pi/client.py +3 -2
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/pi/tools.py +8 -1
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript.egg-info/PKG-INFO +2 -2
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript.egg-info/SOURCES.txt +1 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/pyproject.toml +1 -1
- magmascript-4.1.0/tests/test_pi.py +77 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/LICENSE +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/codegen/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/codegen/c.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/core/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/core/cache.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/core/command_registry.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/core/commands.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/core/config.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/core/exceptions.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/core/github.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/core/output.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/core/registry.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/core/rpc.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/core/runner.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/archive/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/archive/client.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/gh/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/gh/client.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/gh/tools.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/lastfm/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/lastfm/client.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/mac/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/mac/client.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/mac/tools.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/mb/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/mb/client.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/mc1/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/mc1/client.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/mc1/tools.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/mcp/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/mcp/client.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/mcp/tools.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/media/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/media/client.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/media/providers/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/media/providers/archive.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/media/providers/met_museum.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/media/providers/openverse.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/media/providers/pexels.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/media/providers/pixabay.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/media/providers/smithsonian.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/media/tools.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/pi/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/rights/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/rights/client.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/rights/tools.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/scores/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/scores/client.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/scores/tools.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/search/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/domains/search/client.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/ast_nodes.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/astheno/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/astheno/arena.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/astheno/dump.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/astheno/floorplan.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/astheno/numeric.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/builtins.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/domain_bridge.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/environment.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/hypnagogia.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/interpreter.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/lexer.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/parser.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/pretty.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/pygments_mgs.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/tokens.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/util.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/lang/visitor.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/repl.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript/scaffold/__init__.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript.egg-info/dependency_links.txt +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript.egg-info/entry_points.txt +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript.egg-info/requires.txt +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/magmascript.egg-info/top_level.txt +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/setup.cfg +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/tests/test_astheno.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/tests/test_cache.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/tests/test_classes.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/tests/test_cli.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/tests/test_cli_regressions.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/tests/test_commands.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/tests/test_domain_bridge.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/tests/test_import.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/tests/test_lang.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/tests/test_mac.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/tests/test_mc1.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/tests/test_mcp_client.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/tests/test_rpc.py +0 -0
- {magmascript-4.0.1 → magmascript-4.1.0}/tests/test_try_catch.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: magmascript
|
|
3
|
-
Version: 4.0
|
|
3
|
+
Version: 4.1.0
|
|
4
4
|
Summary: Scripting toolkit with domain-first subcommands
|
|
5
5
|
Author: Jake McCoy
|
|
6
6
|
License-Expression: MIT
|
|
@@ -465,7 +465,7 @@ magmascript mcp mb-recording <mbid> # get recording details
|
|
|
465
465
|
magmascript pi status # all service statuses
|
|
466
466
|
magmascript pi logs arcade-chat # service logs
|
|
467
467
|
magmascript pi restart arcade-chat # restart service
|
|
468
|
-
magmascript pi info # uptime, memory, temp
|
|
468
|
+
magmascript pi info # uptime, memory, temp, disk
|
|
469
469
|
magmascript pi deploy arcade/chat-server.py # deploy files
|
|
470
470
|
magmascript pi backup musicbrainz # backup + commit to GitHub
|
|
471
471
|
magmascript pi traffic # nginx traffic analysis
|
|
@@ -430,7 +430,7 @@ magmascript mcp mb-recording <mbid> # get recording details
|
|
|
430
430
|
magmascript pi status # all service statuses
|
|
431
431
|
magmascript pi logs arcade-chat # service logs
|
|
432
432
|
magmascript pi restart arcade-chat # restart service
|
|
433
|
-
magmascript pi info # uptime, memory, temp
|
|
433
|
+
magmascript pi info # uptime, memory, temp, disk
|
|
434
434
|
magmascript pi deploy arcade/chat-server.py # deploy files
|
|
435
435
|
magmascript pi backup musicbrainz # backup + commit to GitHub
|
|
436
436
|
magmascript pi traffic # nginx traffic analysis
|
|
@@ -338,7 +338,7 @@ Pi Actions:
|
|
|
338
338
|
logs-today Get today's logs
|
|
339
339
|
restart <service> Restart a service
|
|
340
340
|
restart-all Restart all arcade services
|
|
341
|
-
info System info (uptime, memory, temp)
|
|
341
|
+
info System info (uptime, memory, temp, disk)
|
|
342
342
|
traffic [lines] Nginx access log analysis
|
|
343
343
|
deploy <path> [service] Deploy to Pi via rsync
|
|
344
344
|
reboot Reboot the Pi
|
|
@@ -100,7 +100,7 @@ class PIClient:
|
|
|
100
100
|
# ------------------------------------------------------------------
|
|
101
101
|
|
|
102
102
|
def info(self) -> PiSystemInfo:
|
|
103
|
-
"""Get Pi system info (uptime, hostname, memory, temp, load).
|
|
103
|
+
"""Get Pi system info (uptime, hostname, memory, temp, load, disk).
|
|
104
104
|
|
|
105
105
|
Raises SSHError on connection failure.
|
|
106
106
|
"""
|
|
@@ -109,7 +109,8 @@ class PIClient:
|
|
|
109
109
|
'echo "HOSTNAME:$(hostname)" && '
|
|
110
110
|
'echo "MEMORY:$(free -h | awk \'/^Mem:/ {print $3"/"$2}\')" && '
|
|
111
111
|
'echo "TEMP:$(vcgencmd measure_temp 2>/dev/null | cut -d= -f2 | cut -d\'"\' -f1 || echo N/A)" && '
|
|
112
|
-
'echo "LOAD:$(cat /proc/loadavg | awk \'{print $1", "$2", "$3}\')"'
|
|
112
|
+
'echo "LOAD:$(cat /proc/loadavg | awk \'{print $1", "$2", "$3}\')" && '
|
|
113
|
+
'echo "DISK:$(df -h / | awk \'NR==2 {print $4" free of "$2" ("$5" used)"}\')"'
|
|
113
114
|
)
|
|
114
115
|
return parse_system_info(stdout)
|
|
115
116
|
|
|
@@ -25,6 +25,9 @@ class PiSystemInfo:
|
|
|
25
25
|
memory: str
|
|
26
26
|
cpu_temp: str
|
|
27
27
|
cpu_load: str
|
|
28
|
+
# Free space on the root filesystem: "3.7G free of 15G (73% used)". Last
|
|
29
|
+
# and defaulted, so a PiSystemInfo built without it still constructs.
|
|
30
|
+
disk: str = ""
|
|
28
31
|
|
|
29
32
|
|
|
30
33
|
@dataclass
|
|
@@ -77,8 +80,10 @@ def parse_system_info(text: str) -> PiSystemInfo:
|
|
|
77
80
|
MEMORY:2.1Gi/3.7Gi
|
|
78
81
|
TEMP:45.0
|
|
79
82
|
LOAD: 0.50, 0.60, 0.70
|
|
83
|
+
DISK:3.7G free of 15G (73% used)
|
|
80
84
|
"""
|
|
81
|
-
info = {"uptime": "", "hostname": "", "memory": "", "cpu_temp": "", "cpu_load": ""
|
|
85
|
+
info = {"uptime": "", "hostname": "", "memory": "", "cpu_temp": "", "cpu_load": "",
|
|
86
|
+
"disk": ""}
|
|
82
87
|
for line in text.splitlines():
|
|
83
88
|
line = line.strip()
|
|
84
89
|
if ":" in line:
|
|
@@ -95,4 +100,6 @@ def parse_system_info(text: str) -> PiSystemInfo:
|
|
|
95
100
|
info["cpu_temp"] = val
|
|
96
101
|
elif key == "load":
|
|
97
102
|
info["cpu_load"] = val
|
|
103
|
+
elif key == "disk":
|
|
104
|
+
info["disk"] = val
|
|
98
105
|
return PiSystemInfo(**info)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: magmascript
|
|
3
|
-
Version: 4.0
|
|
3
|
+
Version: 4.1.0
|
|
4
4
|
Summary: Scripting toolkit with domain-first subcommands
|
|
5
5
|
Author: Jake McCoy
|
|
6
6
|
License-Expression: MIT
|
|
@@ -465,7 +465,7 @@ magmascript mcp mb-recording <mbid> # get recording details
|
|
|
465
465
|
magmascript pi status # all service statuses
|
|
466
466
|
magmascript pi logs arcade-chat # service logs
|
|
467
467
|
magmascript pi restart arcade-chat # restart service
|
|
468
|
-
magmascript pi info # uptime, memory, temp
|
|
468
|
+
magmascript pi info # uptime, memory, temp, disk
|
|
469
469
|
magmascript pi deploy arcade/chat-server.py # deploy files
|
|
470
470
|
magmascript pi backup musicbrainz # backup + commit to GitHub
|
|
471
471
|
magmascript pi traffic # nginx traffic analysis
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""Tests for the Pi domain.
|
|
2
|
+
|
|
3
|
+
Parsers without a network, mirroring test_mac.py and test_mc1.py, plus the
|
|
4
|
+
DISK line of the real info command run through a local shell, because that
|
|
5
|
+
line is awk quoted inside a Python string and the parser test cannot see a
|
|
6
|
+
quoting slip in it.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import os
|
|
12
|
+
import shutil
|
|
13
|
+
import subprocess
|
|
14
|
+
|
|
15
|
+
import pytest
|
|
16
|
+
|
|
17
|
+
from magmascript.domains.pi.client import PIClient
|
|
18
|
+
from magmascript.domains.pi.tools import PiSystemInfo, parse_system_info
|
|
19
|
+
|
|
20
|
+
SAMPLE_INFO = """UPTIME:up 5 days, 3 hours
|
|
21
|
+
HOSTNAME:magmacrunch-server
|
|
22
|
+
MEMORY:2.1Gi/3.7Gi
|
|
23
|
+
TEMP:45.0
|
|
24
|
+
LOAD:0.50, 0.60, 0.70
|
|
25
|
+
DISK:3.7G free of 15G (73% used)"""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class TestParseSystemInfo:
|
|
29
|
+
def test_maps_every_field(self):
|
|
30
|
+
assert parse_system_info(SAMPLE_INFO) == PiSystemInfo(
|
|
31
|
+
uptime="up 5 days, 3 hours",
|
|
32
|
+
hostname="magmacrunch-server",
|
|
33
|
+
memory="2.1Gi/3.7Gi",
|
|
34
|
+
cpu_temp="45.0",
|
|
35
|
+
cpu_load="0.50, 0.60, 0.70",
|
|
36
|
+
disk="3.7G free of 15G (73% used)",
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
def test_disk_missing_defaults_empty(self):
|
|
40
|
+
# Output from before DISK was collected still parses.
|
|
41
|
+
info = parse_system_info("UPTIME:up 1 day\nTEMP:40.0")
|
|
42
|
+
assert info.disk == ""
|
|
43
|
+
assert info.cpu_temp == "40.0"
|
|
44
|
+
|
|
45
|
+
def test_built_without_disk(self):
|
|
46
|
+
info = PiSystemInfo(uptime="", hostname="", memory="", cpu_temp="", cpu_load="")
|
|
47
|
+
assert info.disk == ""
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class _Capture:
|
|
51
|
+
def __init__(self):
|
|
52
|
+
self.cmd = ""
|
|
53
|
+
|
|
54
|
+
def run(self, cmd, **_kw):
|
|
55
|
+
self.cmd = cmd
|
|
56
|
+
return ""
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _info_command() -> str:
|
|
60
|
+
client = PIClient.__new__(PIClient)
|
|
61
|
+
client._runner = _Capture()
|
|
62
|
+
client.info()
|
|
63
|
+
return client._runner.cmd
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test_info_command_collects_disk():
|
|
67
|
+
assert 'echo "DISK:' in _info_command()
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@pytest.mark.skipif(os.name == "nt" or not shutil.which("df"),
|
|
71
|
+
reason="needs a POSIX df")
|
|
72
|
+
def test_disk_line_runs_and_parses():
|
|
73
|
+
disk = [p for p in _info_command().split(" && ") if p.startswith('echo "DISK:')]
|
|
74
|
+
assert len(disk) == 1
|
|
75
|
+
out = subprocess.run(["sh", "-c", disk[0]], capture_output=True, text=True,
|
|
76
|
+
check=True).stdout
|
|
77
|
+
assert " free of " in parse_system_info(out).disk
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|