mirror of
https://github.com/spoopyghosty0/frameport.git
synced 2026-10-06 12:00:40 +02:00
Agent v48: incomplete deployment records (no base/appid) no longer break every connection with KeyError: 'base' (GitHub #40); the app logs unexpected connect errors with their traceback
This commit is contained in:
1 parent
1462d3d471
commit
2f740bbb41
3 files changed
+29
-2
No files matched your search
@@ -35,7 +35,7 @@ import sys
|
||||
import time
|
||||
import zlib
|
||||
|
||||
AGENT_VERSION = 47
|
||||
AGENT_VERSION = 48
|
||||
HOME = os.path.expanduser("~")
|
||||
STEAM = os.path.join(HOME, ".local/share/Steam")
|
||||
ANCHORS = os.path.join(HOME, "Applications/quest-frame")
|
||||
@@ -1163,9 +1163,14 @@ def cmd_shortcut_status(args):
|
||||
def deployment(pkg):
|
||||
path = os.path.join(ANCHORS, pkg, "deployment.json")
|
||||
try:
|
||||
return json.load(open(path))
|
||||
dep = json.load(open(path))
|
||||
except (OSError, ValueError):
|
||||
return None
|
||||
if not isinstance(dep, dict):
|
||||
return None
|
||||
dep.setdefault("base", os.path.dirname(path))
|
||||
dep.setdefault("title", pkg)
|
||||
return dep
|
||||
|
||||
|
||||
def cmd_list_installed(args):
|
||||
@@ -1175,6 +1180,12 @@ def cmd_list_installed(args):
|
||||
dep = json.load(open(dep_path))
|
||||
except (OSError, ValueError):
|
||||
continue
|
||||
# incomplete records (an interrupted install, another tool's files in this folder) are skipped or completed
|
||||
# instead of failing every connection with a KeyError (GitHub #40)
|
||||
if not isinstance(dep, dict) or not dep.get("package") or not dep.get("appid"):
|
||||
continue
|
||||
dep.setdefault("base", os.path.dirname(dep_path))
|
||||
dep.setdefault("title", dep["package"])
|
||||
dep.setdefault("kind", "quest")
|
||||
dep["anchor"] = os.path.dirname(dep_path) # its artwork/ feeds the Steam grid (shortcuts)
|
||||
if dep["kind"] == "linux":
|
||||
|
||||
@@ -1746,6 +1746,8 @@ class FramePortApp:
|
||||
self.frame_info = None
|
||||
# reachable, but it doesn't let FramePort in: the Frame page points at the first-time setup
|
||||
self._not_paired = isinstance(exc, FrameNotPaired)
|
||||
if not isinstance(exc, (FrameNotPaired, OSError)): # unexpected: keep the traceback for reports
|
||||
applog.log.exception("connect to %s failed", target.label)
|
||||
if not quiet:
|
||||
self.toast(tr("Couldn't connect: {exc}").format(exc=explain(exc)), error=True)
|
||||
if self.route[0] in ("frame", "library", "game", "welcome"):
|
||||
|
||||
@@ -1220,3 +1220,17 @@ def test_power_schedules_systemctl_in_a_user_timer(monkeypatch, tmp_path):
|
||||
assert a.cmd_power({"action": "sleep", "force": True})["action"] == "sleep"
|
||||
with pytest.raises(a.AgentError):
|
||||
a.cmd_power({"action": "format"})
|
||||
|
||||
|
||||
def test_incomplete_deployment_records_dont_break_listing(monkeypatch, tmp_path):
|
||||
"""GitHub #40: a deployment.json without "base" made every connection fail with KeyError: 'base'."""
|
||||
a = load_agent(monkeypatch, tmp_path)
|
||||
good = tmp_path / "Applications/quest-frame/com.x.ok"
|
||||
good.mkdir(parents=True)
|
||||
(good / "deployment.json").write_text(json.dumps({"package": "com.x.ok", "appid": 5})) # no base / title
|
||||
junk = tmp_path / "Applications/quest-frame/other"
|
||||
junk.mkdir(parents=True)
|
||||
(junk / "deployment.json").write_text(json.dumps({"name": "something else"}))
|
||||
games = a.cmd_list_installed({})["games"]
|
||||
assert [g["package"] for g in games] == ["com.x.ok"] and games[0]["base"] == str(good)
|
||||
assert a.deployment("com.x.ok")["base"] == str(good)
|
||||
Reference in new issue
Block a user