From 7a1af96a197929989fb4c7d74588aed764069af3 Mon Sep 17 00:00:00 2001 From: hubobel Date: Tue, 16 Jun 2026 17:06:34 +0200 Subject: [PATCH] Nextcloud sync --- categorize_transactions.py | 58 +++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/categorize_transactions.py b/categorize_transactions.py index b3046bf..8ad1ca9 100644 --- a/categorize_transactions.py +++ b/categorize_transactions.py @@ -7,6 +7,9 @@ import json import csv import sys from openpyxl import Workbook, load_workbook +import subprocess +from shutil import which, copy2 +import platform # -------------------------------------------------- # Kalenderwoche bestimmen @@ -357,4 +360,57 @@ print() print(f"CSV : {csv_file}") print(f"JSON : {json_file}") print(f"Summary : {summary_file}") -print(f"Excel : {excel_file}") \ No newline at end of file +print(f"Excel : {excel_file}") + +# -------------------------------------------------- +# Synchronisation +# -------------------------------------------------- + +if which("rclone"): + + try: + + subprocess.run( + [ + "rclone", + "copy", + str(excel_file), + "nextcloud:Finanzen" + ], + check=True + ) + + print("Excel nach Nextcloud synchronisiert.") + + except Exception as e: + + print(f"rclone Fehler: {e}") + +elif platform.system() == "Windows": + + try: + + target = ( + Path.home() + / "Nextcloud" + / "Finanzen" + / excel_file.name + ) + + copy2(excel_file, target) + + print( + f"Excel nach {target} kopiert." + ) + + except Exception as e: + + print( + f"Nextcloud-Kopie fehlgeschlagen: {e}" + ) + +else: + + print( + "Keine Synchronisationsmethode gefunden." + ) \ No newline at end of file