Fixed so that hash adding for local approval should happen sooner if device is moved out of OTP early. Also minor fixes with timestamping of hash additon to use local time instead of epoch, and str matching for local approval allow list finding
This commit is contained in:
+48
-1
@@ -219,6 +219,53 @@ def recurring_job(
|
||||
})
|
||||
save_jobs(jobs)
|
||||
|
||||
|
||||
def find_and_prioritize_jobs_by_pid(pid_substring: str, new_delay_seconds: float = 1.0):
|
||||
"""
|
||||
Find all jobs whose ID contains the given PID substring and reschedule them to run sooner.
|
||||
"""
|
||||
jobs = load_jobs()
|
||||
matched_jobs = [job for job in jobs if pid_substring in job.get("id", "")]
|
||||
|
||||
if not matched_jobs:
|
||||
print(f"[INFO] No jobs found containing PID substring '{pid_substring}'.")
|
||||
return
|
||||
|
||||
print(f"[INFO] Found {len(matched_jobs)} job(s) containing '{pid_substring}':")
|
||||
|
||||
for job in matched_jobs:
|
||||
job_id = job["id"]
|
||||
print(f" - Prioritizing job: {job_id}")
|
||||
|
||||
# Clear existing job from scheduler
|
||||
schedule.clear(job_id)
|
||||
|
||||
# Reschedule based on job type
|
||||
if job["type"] == "once":
|
||||
run_once_job(
|
||||
job_id,
|
||||
job["function"],
|
||||
time.time() + new_delay_seconds,
|
||||
job.get("args"),
|
||||
job.get("kwargs"),
|
||||
replace=True,
|
||||
persist=True
|
||||
)
|
||||
elif job["type"] == "recurring":
|
||||
recurring_job(
|
||||
job_id,
|
||||
job["function"],
|
||||
job["interval"],
|
||||
job["unit"],
|
||||
job.get("args"),
|
||||
job.get("kwargs"),
|
||||
replace=True,
|
||||
persist=True
|
||||
)
|
||||
else:
|
||||
print(f"[WARN] Unknown job type for job '{job_id}'")
|
||||
|
||||
|
||||
# -------------------------------
|
||||
# Reload Saved Jobs
|
||||
# -------------------------------
|
||||
@@ -248,7 +295,7 @@ def reload_jobs():
|
||||
def start_scheduler():
|
||||
"""
|
||||
Start the scheduler loop (blocking).
|
||||
Call this once in your main program to begin.
|
||||
Call this once in main to begin.
|
||||
"""
|
||||
try:
|
||||
while True:
|
||||
|
||||
Reference in New Issue
Block a user