Files
2026-08-25 14:10:21 +02:00

29 lines
874 B
Python

import sys
import switch_client
from extractors.xe_page import fetch_tables
PATH = "/locator.html"
def get_locator_state(session) -> str:
"""Returns "Enable" or "Disable"."""
tables = fetch_tables(session, PATH)
return tables["Locator Configuration"]["record"]["Locate"]
def set_locator(session, enabled: bool) -> None:
tables = fetch_tables(session, PATH)
field_name = tables["Locator Configuration"]["field_names"]["Locate"]
switch_client.submit_form(session, PATH, {field_name: "Enable" if enabled else "Disable"})
if __name__ == "__main__":
if len(sys.argv) != 2 or sys.argv[1] not in ("on", "off"):
print("usage: python -m actions.locator on|off")
raise SystemExit(1)
session = switch_client.get_session()
set_locator(session, sys.argv[1] == "on")
print("Locator state now:", get_locator_state(session))