diff --git a/src/aare/daq/spreadsheetupdater.py b/src/aare/daq/spreadsheetupdater.py index d0176b6e..27bd715e 100644 --- a/src/aare/daq/spreadsheetupdater.py +++ b/src/aare/daq/spreadsheetupdater.py @@ -4,26 +4,17 @@ import websocket import time from aareDB.models import PuckWithTellPosition from aare.common.models import SampleShortInfoList, SampleShortInfo, DewarAddress -from config import BeamlineConfig -from aare.common.beamline import MXBeamline, mx_beamline +from aare.common.beamline import mx_beamline +from aare.daq.config import BeamlineConfig beamline = mx_beamline() -SLOT_IDENTIFIER = beamline.value.upper() -#WS_URL = f"wss://mx-db-01.psi.ch/dispatcher/protected_router/tell_runner/ws/samples-spreadsheet/{SLOT_IDENTIFIER}" -WS_URL = f"wss://mx-aaredb-dmz-01.psi.ch/dispatcher/protected_router/tell_runner/ws/samples-spreadsheet/{SLOT_IDENTIFIER}" - - -# Ensure the environment variable for the shared password is set -password = os.getenv("AAREDB_SHARED_PASSWORD") -if not password: - raise ValueError("The AAREDB_SHARED_PASSWORD environment variable is not set.") -WS_HEADERS = [f"X-Shared-Password: {password}"] - - config = BeamlineConfig(bl=beamline) -# Cache the current spreadsheet for change detection -current_spreadsheet = None +def get_ws_headers() -> list[str]: + password = os.getenv("AAREDB_SHARED_PASSWORD") + if not password: + raise ValueError("The AAREDB_SHARED_PASSWORD environment variable is not set.") + return [f"X-Shared-Password: {password}"] def set_spreadsheet_in_redis(spreadsheet): """ @@ -134,6 +125,11 @@ def main(): """ Main function to initiate WebSocket connection. """ + SLOT_IDENTIFIER = beamline.value.upper() + # WS_URL = f"wss://mx-db-01.psi.ch/dispatcher/protected_router/tell_runner/ws/samples-spreadsheet/{SLOT_IDENTIFIER}" + WS_URL = f"wss://mx-aaredb-dmz-01.psi.ch/dispatcher/protected_router/tell_runner/ws/samples-spreadsheet/{SLOT_IDENTIFIER}" + WS_HEADERS = get_ws_headers() + while True: try: import ssl