Skip to content

Commit

Permalink
Add start time messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jun 7, 2023
1 parent d8778fb commit 1bc0884
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scan_to_paperless/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""Process the scanned documents."""

import argparse
import datetime.datetime
import glob
import json
import logging
Expand Down Expand Up @@ -1787,6 +1788,8 @@ def main() -> None:
sys.exit()

print("Welcome to scanned images document to paperless.")
print(f"Started at: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M')}")

print_waiting = True
status = scan_to_paperless.status.Status()
status.update()
Expand Down
5 changes: 5 additions & 0 deletions scan_to_paperless/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def __init__(self, no_write: bool = False) -> None:
self._file = os.path.join(os.environ.get("SCAN_SOURCE_FOLDER", "status.html"))
self._status: Dict[str, _Folder] = {}
self._global_status = "Starting..."
self._start_time = datetime.datetime.utcnow().replace(microsecond=0)

def set_global_status(self, status: str) -> None:
"""Set the global status."""
Expand Down Expand Up @@ -66,6 +67,7 @@ def write(self) -> None:
if self.no_write:
return

print(f"Write status to {self._file}")
with open(self._file, "w", encoding="utf-8") as status_file:
status_file.write(
f"""<!doctype html>
Expand Down Expand Up @@ -100,6 +102,9 @@ def write(self) -> None:
<body>
<h1>Scan to Paperless status</h1>
<p>{self._global_status}</p>
<p>Started at: <script>
window.document.write(new Date('{self._start_time.isoformat()}Z').toLocaleString());
</script></p>
<p>Generated at: <script>
window.document.write(new Date('{datetime.datetime.utcnow().replace(microsecond=0).isoformat()}Z').toLocaleString());
</script></p>
Expand Down

0 comments on commit 1bc0884

Please # to comment.