Move server modules into server/ package

data_model, log_config, network, storage_helpers, we_connect are now
under server/. collect.py stays in the project root and imports via
the server package.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 20:16:46 +02:00
co-authored by Claude Sonnet 4.6
parent f0e0c9c6ae
commit 7774f4842e
7 changed files with 3 additions and 5 deletions
+36
View File
@@ -0,0 +1,36 @@
import logging
import sys
try:
from weconnect import weconnect
except ImportError:
print("weconnect is not installed. Run: pip install weconnect", file=sys.stderr)
sys.exit(1)
log = logging.getLogger(__name__)
def connect(username: str, password: str):
wc = weconnect.WeConnect(
username=username,
password=password,
updateAfterLogin=False,
loginOnInit=True,
)
wc.login()
wc.update()
return wc
def select_vehicle(wc, vin: str | None):
"""Return (vehicle, error_message). error_message is None on success."""
vehicles = list(wc.vehicles.values())
if not vehicles:
return None, "No vehicles found in this WeConnect account"
if vin:
vehicle = next((v for v in vehicles if v.vin.value == vin), None)
if not vehicle:
available = [v.vin.value for v in vehicles]
return None, f"VIN {vin} not found. Available: {available}"
return vehicle, None
return vehicles[0], None