Files
propresenter-auto-notes/tools/test_restart_link.py
T

47 lines
1.5 KiB
Python
Raw Normal View History

2026-10-13 15:58:03 -04:00
"""One-off check on the ProPresenter Mac: link a message into a playlist via a restart.
Usage (on the ProP Mac):
/usr/bin/python3 test_restart_link.py <message-notes.pyz> "<notes title>" YYYY-MM-DD "<presentation name>"
Refuses to run if anything is on screen. Prints whether the link is in ProPresenter's
playlist file after ProPresenter is running again (and still there 60 s later).
"""
import datetime
import os
import sys
import time
sys.path.insert(0, sys.argv[1])
import app # noqa: E402
import playlist # noqa: E402
import ppctl # noqa: E402
title, day, name = sys.argv[2], sys.argv[3], sys.argv[4]
date = datetime.date(*map(int, day.split("-")))
library = app.find_library()
pro = os.path.join(library, name + ".pro")
assert os.path.isfile(pro), pro
why = ppctl.busy_reason(app.API)
if why:
print("NOT RUN: %s" % why)
sys.exit(1)
def linked():
_, doc = playlist.load(playlist.playlist_file(library))
d, pl = playlist.find_service(doc, title)
if pl is None:
return "no playlist"
h, k = playlist.message_slot(pl)
it = playlist.items_of(pl)[k] if k is not None else None
return playlist.linked_path(it) if it is not None else "no slot"
print("before:", repr(linked()))
t0 = time.time()
print(ppctl.restart_with(lambda: app.link_playlist(library, title, date, name, pro), app.API, print))
print("ProPresenter back after %.0fs, running: %s" % (time.time() - t0, ppctl.app_path(ppctl.pid()) if ppctl.pid() else None))
print("after:", repr(linked()))
time.sleep(60)
print("after 60s:", repr(linked()))