forked from kenzuya/unshackle
feat(serve): relay approval messages to jobs and proxy remote downloads
A REST job shows a wait_for_approval message as its notice field. search, list-titles and list-tracks fail at once on a login that needs the user. A remote client downloads through the --proxy it sends.
This commit is contained in:
@@ -16,7 +16,7 @@ from typing import Any, Callable, Dict
|
||||
from uuid import uuid4
|
||||
|
||||
from unshackle.core.api.input_bridge import AUTH_INPUT_TIMEOUT
|
||||
from unshackle.core.console import set_prompt_handler
|
||||
from unshackle.core.console import set_notice_handler, set_prompt_handler
|
||||
|
||||
from .download_manager import perform_download
|
||||
|
||||
@@ -64,7 +64,7 @@ def relay_prompts(progress_callback: Callable[[Dict[str, Any]], None]) -> None:
|
||||
The parent writes each answer as one JSON string per line, so an answer can hold a newline. The reader
|
||||
uses unbuffered stdin: a daemon thread blocked in ``sys.stdin.buffer`` aborts the interpreter at shutdown.
|
||||
Prompts go out one at a time, and a prompt discards answers that arrived before it, such as a late
|
||||
answer to a prompt that timed out.
|
||||
answer to a prompt that timed out. A show_notice() message goes out as ``notice`` progress and needs no answer.
|
||||
"""
|
||||
answers: queue.Queue[str] = queue.Queue()
|
||||
one_prompt = threading.Lock()
|
||||
@@ -92,6 +92,7 @@ def relay_prompts(progress_callback: Callable[[Dict[str, Any]], None]) -> None:
|
||||
progress_callback({"input_prompt": None})
|
||||
|
||||
set_prompt_handler(ask)
|
||||
set_notice_handler(lambda message: progress_callback({"notice": message}))
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
|
||||
Reference in New Issue
Block a user