Public Access
Clean repo docs and remove legacy Vercel sync files
This commit is contained in:
1 parent
3ea1c3f889
commit
aa90078ce2
13 files changed
+191
-385
No files matched your search
@@ -1,8 +0,0 @@
|
||||
@echo off
|
||||
|
||||
cd /d "C:\Users\Silicon Solder\Documents\Codex\vyta-sync"
|
||||
|
||||
"C:\Users\Silicon Solder\Documents\Codex\vyta-sync\.venv\Scripts\python.exe" ^
|
||||
"C:\Users\Silicon Solder\Documents\Codex\vyta-sync\sync.py"
|
||||
|
||||
exit /b %errorlevel%
|
||||
+1
-31
@@ -21,10 +21,6 @@ NORMALIZER = os.path.join(
|
||||
"normalizer.py",
|
||||
)
|
||||
|
||||
UPLOADER = os.path.join(
|
||||
BASE_DIR,
|
||||
"upload_to_blob.py",
|
||||
)
|
||||
|
||||
LOG_DIR = os.path.join(
|
||||
BASE_DIR,
|
||||
@@ -179,24 +175,6 @@ def run_script(
|
||||
)
|
||||
|
||||
|
||||
def should_upload_to_blob():
|
||||
value = os.environ.get(
|
||||
"VYTA_UPLOAD_TO_BLOB",
|
||||
"0",
|
||||
)
|
||||
|
||||
return (
|
||||
value
|
||||
.strip()
|
||||
.lower()
|
||||
in (
|
||||
"1",
|
||||
"true",
|
||||
"yes",
|
||||
"on",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
def notify_vyta():
|
||||
@@ -312,15 +290,6 @@ def main():
|
||||
NORMALIZER
|
||||
)
|
||||
|
||||
if should_upload_to_blob():
|
||||
run_script(
|
||||
UPLOADER
|
||||
)
|
||||
else:
|
||||
log(
|
||||
"Hoppar över Vercel Blob-upload"
|
||||
)
|
||||
|
||||
notify_vyta()
|
||||
|
||||
completed_at = utc_now()
|
||||
@@ -377,3 +346,4 @@ def main():
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
import json
|
||||
import os
|
||||
from datetime import date
|
||||
from getpass import getpass
|
||||
|
||||
from garminconnect import Garmin
|
||||
|
||||
|
||||
TOKENSTORE = os.path.join(os.path.dirname(__file__), ".garmin_tokens")
|
||||
|
||||
|
||||
def dump(title, data):
|
||||
print()
|
||||
print("=" * 70)
|
||||
print(title)
|
||||
print("=" * 70)
|
||||
print(json.dumps(data, indent=2, ensure_ascii=False, default=str))
|
||||
|
||||
|
||||
def main():
|
||||
email = input("Garmin email: ").strip()
|
||||
password = getpass("Garmin password: ")
|
||||
|
||||
garmin = Garmin(
|
||||
email=email,
|
||||
password=password,
|
||||
)
|
||||
|
||||
os.makedirs(TOKENSTORE, exist_ok=True)
|
||||
|
||||
print("\nLoggar in mot Garmin Connect...")
|
||||
|
||||
result = garmin.login(TOKENSTORE)
|
||||
|
||||
print("Inloggning OK.")
|
||||
print("Display name:", garmin.display_name)
|
||||
|
||||
today = date.today().isoformat()
|
||||
|
||||
print(f"\nHämtar Garmin-data för {today}...")
|
||||
|
||||
calls = [
|
||||
("Daily stats", lambda: garmin.get_stats(today)),
|
||||
("Heart rate", lambda: garmin.get_heart_rates(today)),
|
||||
("Sleep", lambda: garmin.get_sleep_data(today)),
|
||||
("HRV", lambda: garmin.get_hrv_data(today)),
|
||||
("Stress", lambda: garmin.get_stress_data(today)),
|
||||
("Body Battery", lambda: garmin.get_body_battery(today)),
|
||||
("Respiration", lambda: garmin.get_respiration_data(today)),
|
||||
("SpO2", lambda: garmin.get_spo2_data(today)),
|
||||
("Training readiness", lambda: garmin.get_training_readiness(today)),
|
||||
("Training status", lambda: garmin.get_training_status(today)),
|
||||
("Activities", lambda: garmin.get_activities(0, 10)),
|
||||
("Devices", lambda: garmin.get_devices()),
|
||||
]
|
||||
|
||||
for title, fn in calls:
|
||||
try:
|
||||
data = fn()
|
||||
dump(title, data)
|
||||
except Exception as e:
|
||||
print()
|
||||
print("=" * 70)
|
||||
print(title)
|
||||
print("=" * 70)
|
||||
print(f"ERROR: {type(e).__name__}: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,166 +0,0 @@
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# CONFIG
|
||||
# ------------------------------------------------------------
|
||||
|
||||
SCRIPT_DIR = Path(__file__).resolve().parent
|
||||
|
||||
VYTA_PROJECT = Path(
|
||||
r"C:\Users\Silicon Solder\Documents\Codex\vyta"
|
||||
)
|
||||
|
||||
DATA_FILE = (
|
||||
VYTA_PROJECT
|
||||
/ "private-data"
|
||||
/ "vyta-data.json"
|
||||
)
|
||||
|
||||
BLOB_PATH = "vyta/vyta-data.json"
|
||||
|
||||
|
||||
# Läs vyta-sync\.env
|
||||
load_dotenv(SCRIPT_DIR / ".env")
|
||||
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# HELPERS
|
||||
# ------------------------------------------------------------
|
||||
|
||||
def find_vercel_cli() -> str:
|
||||
"""
|
||||
Hitta Vercel CLI.
|
||||
|
||||
På Windows ligger global npm CLI normalt som vercel.cmd.
|
||||
"""
|
||||
|
||||
candidates = [
|
||||
"vercel.cmd",
|
||||
"vercel",
|
||||
]
|
||||
|
||||
for candidate in candidates:
|
||||
executable = shutil.which(candidate)
|
||||
|
||||
if executable:
|
||||
return executable
|
||||
|
||||
# Vanlig npm global-bin på Windows
|
||||
appdata = os.environ.get("APPDATA")
|
||||
|
||||
if appdata:
|
||||
fallback = Path(appdata) / "npm" / "vercel.cmd"
|
||||
|
||||
if fallback.exists():
|
||||
return str(fallback)
|
||||
|
||||
raise FileNotFoundError(
|
||||
"Kunde inte hitta Vercel CLI. "
|
||||
"Kontrollera att 'vercel --version' fungerar i PowerShell."
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
print("=" * 60)
|
||||
print("VYTA → VERCEL PRIVATE BLOB")
|
||||
print("=" * 60)
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Kontrollera datafil
|
||||
# --------------------------------------------------------
|
||||
|
||||
if not DATA_FILE.exists():
|
||||
print()
|
||||
print("ERROR: Vyta-datafilen saknas:")
|
||||
print(DATA_FILE)
|
||||
sys.exit(1)
|
||||
|
||||
print()
|
||||
print(f"Datafil: {DATA_FILE}")
|
||||
print(f"Storlek: {DATA_FILE.stat().st_size:,} bytes")
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Blob-token
|
||||
# --------------------------------------------------------
|
||||
|
||||
token = os.environ.get(
|
||||
"BLOB_READ_WRITE_TOKEN"
|
||||
)
|
||||
|
||||
if not token:
|
||||
print()
|
||||
print(
|
||||
"ERROR: BLOB_READ_WRITE_TOKEN saknas i vyta-sync\\.env"
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
print("Blob-token: OK")
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Vercel CLI
|
||||
# --------------------------------------------------------
|
||||
|
||||
try:
|
||||
vercel_cli = find_vercel_cli()
|
||||
except FileNotFoundError as exc:
|
||||
print()
|
||||
print(f"ERROR: {exc}")
|
||||
sys.exit(1)
|
||||
|
||||
print(f"Vercel CLI: {vercel_cli}")
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Upload
|
||||
# --------------------------------------------------------
|
||||
|
||||
command = [
|
||||
vercel_cli,
|
||||
"blob",
|
||||
"put",
|
||||
str(DATA_FILE),
|
||||
"--pathname",
|
||||
BLOB_PATH,
|
||||
"--access",
|
||||
"private",
|
||||
"--allow-overwrite",
|
||||
"--content-type",
|
||||
"application/json",
|
||||
"--rw-token",
|
||||
token,
|
||||
]
|
||||
|
||||
print()
|
||||
print(
|
||||
f"Laddar upp till Private Blob: {BLOB_PATH}"
|
||||
)
|
||||
print()
|
||||
|
||||
result = subprocess.run(
|
||||
command,
|
||||
cwd=str(VYTA_PROJECT),
|
||||
text=True,
|
||||
)
|
||||
|
||||
if result.returncode != 0:
|
||||
print()
|
||||
print(
|
||||
f"ERROR: Blob-upload misslyckades "
|
||||
f"(exit code {result.returncode})"
|
||||
)
|
||||
sys.exit(result.returncode)
|
||||
|
||||
print()
|
||||
print("=" * 60)
|
||||
print("VYTA BLOB-UPLOAD KLAR")
|
||||
print("=" * 60)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user