Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions scripts/set_instrument_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def set_env() -> None:
epics_ca_addr_list = "EPICS_CA_ADDR_LIST"
""" If we're not in an EPICS terminal, add the address list to the set of
environment keys """
if epics_ca_addr_list not in os.environ.keys():
if epics_ca_addr_list not in os.environ:
os.environ[epics_ca_addr_list] = "127.255.255.255 130.246.51.255"
print(epics_ca_addr_list + " = " + str(os.environ.get(epics_ca_addr_list)))

Expand Down Expand Up @@ -86,7 +86,7 @@ def inst_dictionary(
if pv_prefix is not None:
pv_prefix_to_use = pv_prefix
else:
pv_prefix_to_use = "IN:{0}:".format(instrument_name)
pv_prefix_to_use = f"IN:{instrument_name}:"

if groups is None:
groups_to_use = []
Expand Down Expand Up @@ -115,11 +115,11 @@ def set_instlist(instruments_list: list[Instrument], pv_address: str) -> None:
result = dehex_and_decompress(bytes(result_compr, encoding="utf8")).decode("utf-8")

if result != new_value:
print("Warning! Entered value does not match new value for {0}".format(pv_address))
print(f"Warning! Entered value does not match new value for {pv_address}")
print("Entered value: " + new_value)
print("Actual value: " + result)
else:
print("Success! Updated value for {0}".format(pv_address))
print(f"Success! Updated value for {pv_address}")


MUONS = "MUONS"
Expand Down Expand Up @@ -207,14 +207,6 @@ def set_instlist(instruments_list: list[Instrument], pv_address: str) -> None:
inst_dictionary("SOFTMAT", groups=[SUPPORT], is_scheduled=False, target_station=MISC),
inst_dictionary("SURF", groups=[REFLECTOMETRY], target_station=TS1),
inst_dictionary("NIMROD", groups=[DISORDERED], target_station=TS2),
inst_dictionary(
"DETMON",
groups=[SUPPORT],
hostname_prefix="NDA",
is_scheduled=False,
pv_prefix="TE:NDADETF1:",
target_station=MISC,
),
inst_dictionary("EMU", groups=[MUONS], target_station=MUON_TARGET),
inst_dictionary("INTER", groups=[REFLECTOMETRY], target_station=TS2),
inst_dictionary("POLREF", groups=[REFLECTOMETRY], target_station=TS2),
Expand Down Expand Up @@ -282,5 +274,5 @@ def set_instlist(instruments_list: list[Instrument], pv_address: str) -> None:
inst_list = [x for x in instruments_list if g in x["groups"]]
try:
set_instlist(inst_list, pv_address)
except Exception:
except Exception: # ruff:ignore[BLE001]
print(f"Failed to set {pv_address}")
Loading