Compare commits

..

2 Commits

Author SHA1 Message Date
shokollm
796e1fe454 fix(kugetsu-index): call kugetsu_add_notification from bash instead of os.system()
os.system() spawns a new subprocess that cannot access bash functions.
Now calling kugetsu_add_notification directly from bash after Python updates JSON.

Fixes #167
2026-04-06 00:33:35 +00:00
84c59a3b64 Merge pull request 'fix(kugetsu): queue daemon improvements - locking, error handling, cmd_delegate enqueue' (#164) from fix/issue-156-queue-fixes into main 2026-04-06 02:06:36 +02:00

View File

@@ -202,9 +202,10 @@ update_queue_item_state() {
return 1 return 1
fi fi
local issue_ref=$(python3 -c "import json; print(json.load(open('$item_file')).get('issue_ref', ''))" 2>/dev/null || echo "")
python3 << PYEOF python3 << PYEOF
import json import json
import os
from datetime import datetime from datetime import datetime
item_file = "$item_file" item_file = "$item_file"
@@ -215,8 +216,6 @@ pid = "$pid"
with open(item_file, 'r') as f: with open(item_file, 'r') as f:
item = json.load(f) item = json.load(f)
issue_ref = item.get('issue_ref', '')
item['state'] = new_state item['state'] = new_state
if new_state == "notified": if new_state == "notified":
@@ -227,14 +226,18 @@ if new_state == "notified":
item['pid'] = int(pid) if pid.isdigit() else None item['pid'] = int(pid) if pid.isdigit() else None
elif new_state == "completed": elif new_state == "completed":
item['completed_at'] = datetime.now().isoformat() + "Z" item['completed_at'] = datetime.now().isoformat() + "Z"
os.system(f"kugetsu_add_notification 'task_completed' 'Task completed: {issue_ref}' '{issue_ref}'")
elif new_state == "error": elif new_state == "error":
item['error'] = datetime.now().isoformat() + "Z" item['error'] = datetime.now().isoformat() + "Z"
os.system(f"kugetsu_add_notification 'task_error' 'Task error: {issue_ref}' '{issue_ref}'")
with open(item_file, 'w') as f: with open(item_file, 'w') as f:
json.dump(item, f, indent=2) json.dump(item, f, indent=2)
print(f"Updated $queue_id to state: $new_state") print(f"Updated $queue_id to state: $new_state")
PYEOF PYEOF
if [ "$new_state" = "completed" ]; then
kugetsu_add_notification "task_completed" "Task completed: $issue_ref" "$issue_ref"
elif [ "$new_state" = "error" ]; then
kugetsu_add_notification "task_error" "Task error: $issue_ref" "$issue_ref"
fi
} }