Companion keeper: after a restart the panel opens the Companion that ran last if it is not running

- only in the watchdog's first 10 minutes, never another version, never during an upgrade
- SC verified end to end; laptop SSH to the SC Macs; configs synced

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 14:26:18 -04:00
co-authored by Claude Opus 5.5
parent 268ac21715
commit 5db1d93732
3 changed files with 95 additions and 0 deletions
+7
View File
@@ -292,6 +292,9 @@ def upgrade_companion(base, say=print, source=None):
import urllib.request
root = os.path.expanduser("~/Library/Application Support/companion")
app = "/Applications/Companion 5.0.7.app"
# The watchdog's CompanionKeeper must not reopen the old Companion in the middle of this.
with open(os.path.join(PARENT, "companion-upgrading"), "w") as f:
f.write(str(time.time()))
if not os.path.exists(app) and source: # standalone: the .dmg (or .zip) downloaded from bitfocus.io
install_companion_from(source, app, say)
if not os.path.exists(app):
@@ -323,6 +326,10 @@ def upgrade_companion(base, say=print, source=None):
try:
discover.companion_get({"companion": {}}, "/api/connections", 2)
say("Companion 5.0.7 is running. In System Settings > General > Login Items, replace the old Companion with 5.0.7.")
try:
os.remove(os.path.join(PARENT, "companion-upgrading"))
except OSError:
pass
return True
except OSError:
time.sleep(1)