diff --git a/scan_to_paperless/process.py b/scan_to_paperless/process.py index 0b12cf57..972ac9c9 100755 --- a/scan_to_paperless/process.py +++ b/scan_to_paperless/process.py @@ -1795,6 +1795,7 @@ def main() -> None: for config_file_name in glob.glob( os.path.join(os.environ.get("SCAN_SOURCE_FOLDER", "/source"), "*/config.yaml") ): + status.set_global_status(f"Processing '{os.path.basename(os.path.dirname(config_file_name))}'...") dirty, print_waiting = _process(config_file_name, status, dirty, print_waiting) if not dirty: process_code() @@ -1803,7 +1804,7 @@ def main() -> None: if not dirty: if print_waiting: print_waiting = False - print("Waiting...") + status.set_global_status("Waiting...") time.sleep(30) diff --git a/scan_to_paperless/status.py b/scan_to_paperless/status.py index d0c1b390..96c6905b 100644 --- a/scan_to_paperless/status.py +++ b/scan_to_paperless/status.py @@ -1,5 +1,6 @@ """Manage the status file of the progress.""" +import datetime import glob import os.path from typing import Dict, NamedTuple @@ -19,6 +20,13 @@ def __init__(self, no_write: bool = False) -> None: self.no_write = no_write self._file = os.path.join(os.environ.get("SCAN_SOURCE_FOLDER", "status.html")) self._status: Dict[str, _Folder] = {} + self._global_status = "Starting..." + + def set_global_status(self, status: str) -> None: + """Set the global status.""" + + self._global_status = status + self.update() def set_status(self, name: str, status: str, details: str = "") -> None: """Set the status of a folder.""" @@ -60,7 +68,7 @@ def write(self) -> None: with open(self._file, "w", encoding="utf-8") as status_file: status_file.write( - """ + f""" @@ -90,6 +98,12 @@ def write(self) -> None: /> +

Scan to Paperless status

+

{self._global_status}

+

Generated at:

+

Jobs