This commit is contained in:
2026-04-28 06:08:43 +02:00
parent 9dbd3ab0b4
commit 2de8711ab7
4 changed files with 59 additions and 5 deletions
+2 -2
View File
@@ -3,8 +3,8 @@ import ctypes
from blake3 import blake3
# Windows atributy pro cloud/placeholder soubory
_FILE_ATTRIBUTE_OFFLINE = 0x00001000
_FILE_ATTRIBUTE_RECALL_ON_OPEN = 0x00040000
_FILE_ATTRIBUTE_OFFLINE = 0x00001000
_FILE_ATTRIBUTE_RECALL_ON_OPEN = 0x00040000
_FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x00400000
_CLOUD_MASK = _FILE_ATTRIBUTE_OFFLINE | _FILE_ATTRIBUTE_RECALL_ON_OPEN | _FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS
+52 -1
View File
@@ -180,6 +180,7 @@ def main():
"modified": len(modified_paths),
"deleted": len(deleted_paths),
"unchanged": len(unchanged_paths),
"skipped": len(skipped_files),
}
finalize_run(cur, run_id, stats)
conn.commit()
@@ -213,10 +214,14 @@ def main():
print("=" * 60)
# ── 8. Generate Excel report ──
report_path = None
try:
from report import generate_report
report_dir = r"u:\Dropbox\!!!Days\Downloads Z230"
report_dir = r"z:\Dropbox\!!!Days\Downloads Z230"
for f in os.listdir(report_dir):
if f.endswith("DropboxBackupReport.xlsx"):
os.remove(os.path.join(report_dir, f))
timestamp = datetime.now().strftime("%Y-%m-%d %H_%M")
report_path = os.path.join(report_dir, f"{timestamp} DropboxBackupReport.xlsx")
print(f"\n[8] Generating report...")
@@ -224,6 +229,52 @@ def main():
except Exception as e:
print(f" WARN: Report generation failed: {e}")
# ── 9. Send email notification ──
try:
import sys
sys.path.insert(0, r"C:\Reporting\knihovny")
from EmailMessagingGraph import send_mail
ts = datetime.now().strftime("%d.%m.%Y %H:%M")
changes = stats['new'] + stats['modified'] + stats['deleted']
report_line = f"<tr><td>Report</td><td>{report_path}</td></tr>" if report_path else ""
skipped_row = ""
skipped_detail = ""
if skipped_files:
skipped_row = f"<tr style='background:#fff3cd;color:#856404;'><td><b>Preskocene</b></td><td>{len(skipped_files):,}</td></tr>"
rows = "".join(f"<tr><td>{p}</td><td>{r}</td></tr>" for p, r in skipped_files)
skipped_detail = f"""
<h3 style="color:#856404;">&#9888; Preskocene soubory ({len(skipped_files)})</h3>
<table border="0" cellpadding="4" cellspacing="0" style="border-collapse:collapse;font-size:12px;">
<tr style="background:#f0f4fa;"><td><b>Soubor</b></td><td><b>Duvod</b></td></tr>
{rows}
</table>"""
body = f"""
<html><body style="font-family:Segoe UI,Arial,sans-serif;font-size:14px;color:#222;">
<h2 style="color:#2e6da4;">&#10003; Dropbox Ordinace Backup &ndash; {ts}</h2>
<table border="0" cellpadding="6" cellspacing="0" style="border-collapse:collapse;min-width:350px;">
<tr style="background:#f0f4fa;"><td><b>Run #</b></td><td>{run_id}</td></tr>
<tr><td><b>Celkem souboru</b></td><td>{stats['total']:,}</td></tr>
<tr style="background:#f0f4fa;color:#2a7a2a;"><td><b>Nove</b></td><td>{stats['new']:,}</td></tr>
<tr style="color:#a07000;"><td><b>Zmenene</b></td><td>{stats['modified']:,}</td></tr>
<tr style="background:#f0f4fa;color:#a00000;"><td><b>Smazane</b></td><td>{stats['deleted']:,}</td></tr>
<tr><td><b>Nezmenene</b></td><td>{stats['unchanged']:,}</td></tr>
<tr style="background:#f0f4fa;"><td><b>Zmen celkem</b></td><td>{changes:,}</td></tr>
{skipped_row}
{report_line}
</table>
{skipped_detail}
<p style="color:#888;font-size:12px;margin-top:20px;">REPORTER &bull; {ts}</p>
</body></html>
"""
subject = f"Dropbox Backup #{run_id} \u2013 {ts} ({changes} zmen)"
send_mail("vladimir.buzalka@buzalka.cz", subject, body, html=True)
print(f"\n[9] Email odeslan na vladimir.buzalka@buzalka.cz")
except Exception as e:
print(f" WARN: Email failed: {e}")
if __name__ == "__main__":
main()
+2 -2
View File
@@ -77,7 +77,7 @@ def generate_report(output_path: str):
cell.alignment = Alignment(horizontal="center")
cell.border = thin_border
for row_idx, ev in enumerate(all_events, 2):
for row_idx, ev in enumerate(reversed(all_events), 2):
run_id, started, event_type, rel_path, file_name, directory, old_size, new_size = ev
size_change = ""
@@ -115,7 +115,7 @@ def generate_report(output_path: str):
if __name__ == "__main__":
REPORT_DIR = r"u:\Dropbox\!!!Days\Downloads Z230"
REPORT_DIR = r"z:\Dropbox\!!!Days\Downloads Z230"
timestamp = dt.now().strftime("%Y-%m-%d %H_%M")
default_name = f"{timestamp} DropboxBackupReport.xlsx"
output = sys.argv[1] if len(sys.argv) > 1 else os.path.join(REPORT_DIR, default_name)
+3
View File
@@ -0,0 +1,3 @@
@echo off
cd /d C:\Reporting\DropboxBackup
C:\Reporting\Python\python.exe main.py