openloops.whenthen_job#

Handing the periodic jobs to whenthen: register a job, take over from the launchd agent.

whenthen is the fleet’s scheduler (one clock, run records, whenthen status). Each job this package used to install as a launchd agent (the digest sync, the reminder tick, the pile nudge, the board receiver, the board refresh) can instead be a whenthen job; this module is the one place that knows how. It is used when python -m whenthen --help works under the interpreter openloops runs in, and never required: without it the installers behave as before.

A job’s name is its launchd label with the dots turned into dashes (openloops.remind-tick -> openloops-remind-tick), so the label still names it.

Functions

job_name(label)

The whenthen job for a launchd label.

every_flag(seconds)

An interval as whenthen's --every value.

whenthen(*args)

python -m whenthen <args> under this interpreter: (exit code, parsed JSON or text).

available()

Whether whenthen can be run under this interpreter (never a hard dependency).

register(*, label, intent_file, intent_key)

Add the job for label and stop its launchd agent (take_over).

status(label)

The whenthen job's state for label; None when whenthen or the job is absent.

remove(label)

Remove the whenthen job for label if there is one.

openloops.whenthen_job.available()[source]#

Whether whenthen can be run under this interpreter (never a hard dependency).

Return type:

bool

openloops.whenthen_job.every_flag(seconds)[source]#

An interval as whenthen’s --every value.

>>> every_flag(900), every_flag(21600), every_flag(60)
('15m', '6h', '1m')
Return type:

str

openloops.whenthen_job.job_name(label)[source]#

The whenthen job for a launchd label.

>>> job_name("openloops.remind-tick")
'openloops-remind-tick'
Return type:

str

openloops.whenthen_job.register(*, label, intent_file, intent_key, params=None, interval, env=None, cwd=None, env_file=None, timeout='30m', delay=None, source, quote='', take_over, restore, dry_run=False, run_once=False)[source]#

Add the job for label and stop its launchd agent (take_over).

Order: vocabulary entry, dry run, take_over, add. A failed add calls restore (the old agent installed again) and raises. Returns scheduler, job, echo, interval and, with run_once, first_run (its status).

Return type:

dict[str, str]

openloops.whenthen_job.remove(label)[source]#

Remove the whenthen job for label if there is one. True when one was removed.

Return type:

bool

openloops.whenthen_job.status(label)[source]#

The whenthen job’s state for label; None when whenthen or the job is absent.

Return type:

dict[str, object] | None

openloops.whenthen_job.whenthen(*args)[source]#

python -m whenthen <args> under this interpreter: (exit code, parsed JSON or text).

Return type:

tuple[int, object]