spreadsheetupdater.py: only check for password when needing WSHEADERS

This commit is contained in:
appleb_m committed 2026-04-22 16:57:32 +02:00
1 parent 6db8f281e6
commit 2fc25cc7f5
1 file changed
+12 -16
+12 -16
View File
@@ -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