11import json
22import zlib
33from ast import literal_eval
4- from typing import Any
54from socket import gethostname
5+ from typing import Any
6+
7+ from epics import caget , caput
68
79from ibex_install_utils .file_utils import FileUtils
810
9- import epicscorelibs .path .pyepics
10- from epics import caget , caput
1111
1212def crc8 (value : str ) -> str :
1313 """
@@ -44,6 +44,7 @@ def crc8(value: str) -> str:
4444
4545 return "{0:02X}" .format (crc )
4646
47+
4748def dehex_and_decompress (value : bytes | str ) -> str :
4849 """
4950 Dehex and decompress a string and return it
@@ -65,6 +66,7 @@ def dehex_decompress_and_dejson(value: str | bytes) -> Any: # No known type
6566 """
6667 return json .loads (dehex_and_decompress (value ))
6768
69+
6870def _get_pv_prefix (instrument : str , is_instrument : bool ) -> str :
6971 """
7072 Create the pv prefix based on instrument name and whether it is an
@@ -89,13 +91,11 @@ def _get_pv_prefix(instrument: str, is_instrument: bool) -> str:
8991 pv_prefix_prefix = "IN"
9092 else :
9193 pv_prefix_prefix = "TE"
92- return "{prefix}:{instrument}:" .format (
93- prefix = pv_prefix_prefix , instrument = instrument_name
94- )
94+ return "{prefix}:{instrument}:" .format (prefix = pv_prefix_prefix , instrument = instrument_name )
9595
9696
9797def get_machine_details_from_identifier (
98- machine_identifier : str | None = None
98+ machine_identifier : str | None = None ,
9999) -> tuple [str , str , str ]:
100100 """
101101 Gets the details of a machine by looking it up in the instrument list first.
@@ -125,26 +125,26 @@ def get_machine_details_from_identifier(
125125 # that's been passed to this function if it is not found instrument_details will be None
126126 instrument_details = None
127127 try :
128- instrument_list = dehex_decompress_and_dejson (caget ("CS:INSTLIST" ).tobytes ().decode ().rstrip ('\x00 ' ))
128+ instrument_list = dehex_decompress_and_dejson (
129+ caget ("CS:INSTLIST" ).tobytes ().decode ().rstrip ("\x00 " )
130+ )
129131 instrument_details = next (
130132 (inst for inst in instrument_list if inst ["pvPrefix" ] == machine_identifier ), None
131133 )
132134 except AttributeError :
133- print (
134- "Error getting instlist, \n Continuing execution..."
135- )
135+ print ("Error getting instlist, \n Continuing execution..." )
136136
137137 if instrument_details is not None :
138138 instrument = instrument_details ["name" ]
139139 else :
140140 instrument = machine_identifier .upper ()
141141 for p in (
142- [instrument_pv_prefix , test_machine_pv_prefix ]
143- + instrument_machine_prefixes
144- + test_machine_prefixes
142+ [instrument_pv_prefix , test_machine_pv_prefix ]
143+ + instrument_machine_prefixes
144+ + test_machine_prefixes
145145 ):
146146 if machine_identifier .startswith (p ):
147- instrument = machine_identifier .upper ()[len (p ):].rstrip (":" )
147+ instrument = machine_identifier .upper ()[len (p ) :].rstrip (":" )
148148 break
149149
150150 if instrument_details is not None :
0 commit comments