Files
revng-revng/python/revng/internal/daemon/util.py
Alessandro Di Federico fd216ef374 daemon: improve logging
2025-10-28 11:43:22 +01:00

28 lines
598 B
Python

#
# This file is distributed under the MIT License. See LICENSE.md for details.
#
import json
import os
import sys
from base64 import b64encode
from typing import Dict, Optional
def log(message: str):
sys.stderr.write(message + "\n")
sys.stderr.flush()
def project_workdir() -> Optional[str]:
return os.environ.get("REVNG_DATA_DIR")
def produce_serializer(input_: Dict[str, str | bytes]) -> str:
return json.dumps(
{
key: (value if isinstance(value, str) else b64encode(value).decode("utf-8"))
for key, value in input_.items()
}
)