mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-04-06 07:47:53 +10:00
cleanup archivebox tests
This commit is contained in:
@@ -70,9 +70,16 @@ def parse_line(line: str) -> Optional[Dict[str, Any]]:
|
||||
if line.startswith('http://') or line.startswith('https://') or line.startswith('file://'):
|
||||
return {'type': TYPE_SNAPSHOT, 'url': line}
|
||||
|
||||
# Could be a snapshot ID (UUID)
|
||||
# Could be a snapshot ID (UUID with dashes or compact 32-char hex)
|
||||
if len(line) == 36 and line.count('-') == 4:
|
||||
return {'type': TYPE_SNAPSHOT, 'id': line}
|
||||
if len(line) == 32:
|
||||
try:
|
||||
int(line, 16)
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
return {'type': TYPE_SNAPSHOT, 'id': line}
|
||||
|
||||
# Unknown format, skip
|
||||
return None
|
||||
|
||||
@@ -607,7 +607,7 @@ def log_worker_event(
|
||||
|
||||
# Build final message
|
||||
error_str = f' {type(error).__name__}: {error}' if error else ''
|
||||
from archivebox.misc.logging import CONSOLE
|
||||
from archivebox.misc.logging import CONSOLE, STDERR
|
||||
from rich.text import Text
|
||||
|
||||
# Create a Rich Text object for proper formatting
|
||||
@@ -632,7 +632,11 @@ def log_worker_event(
|
||||
if metadata_str:
|
||||
text.append(f' | {metadata_str}')
|
||||
|
||||
CONSOLE.print(text, soft_wrap=True)
|
||||
# Stdout is reserved for JSONL records whenever commands are piped together.
|
||||
# Route worker/DB progress to stderr in non-TTY contexts so pipelines like
|
||||
# `archivebox snapshot list | archivebox run` keep stdout machine-readable.
|
||||
output_console = CONSOLE if sys.stdout.isatty() else STDERR
|
||||
output_console.print(text, soft_wrap=True)
|
||||
|
||||
|
||||
@enforce_types
|
||||
|
||||
Reference in New Issue
Block a user