mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 04:47:14 +02:00
fixed hostname not split (+) in python (#609)
* fixed hostname not split (+) in python * also for rx_hostname
This commit is contained in:
@ -14,7 +14,7 @@ streamingInterface = slsDetectorDefs.streamingInterface
|
||||
defs = slsDetectorDefs
|
||||
|
||||
from .utils import element_if_equal, all_equal, get_set_bits, list_to_bitmask
|
||||
from .utils import Geometry, to_geo, element, reduce_time, is_iterable
|
||||
from .utils import Geometry, to_geo, element, reduce_time, is_iterable, hostname_list
|
||||
from _slsdet import xy
|
||||
from . import utils as ut
|
||||
from .proxy import JsonProxy, SlowAdcProxy, ClkDivProxy, MaxPhaseProxy, ClkFreqProxy, PatLoopProxy, PatNLoopProxy, PatWaitProxy, PatWaitTimeProxy
|
||||
@ -162,12 +162,8 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@hostname.setter
|
||||
def hostname(self, hostnames):
|
||||
if isinstance(hostnames, str):
|
||||
hostnames = [hostnames]
|
||||
if isinstance(hostnames, list):
|
||||
self.setHostname(hostnames)
|
||||
else:
|
||||
raise ValueError("hostname needs to be string or list of strings")
|
||||
args = hostname_list(hostnames)
|
||||
self.setHostname(args)
|
||||
|
||||
|
||||
@property
|
||||
@ -784,7 +780,8 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@rx_hostname.setter
|
||||
def rx_hostname(self, hostname):
|
||||
self.setRxHostname(hostname)
|
||||
args = hostname_list(hostname)
|
||||
self.setRxHostname(args)
|
||||
|
||||
@property
|
||||
@element
|
||||
|
@ -260,4 +260,21 @@ def merge_args(*args):
|
||||
return (ret,)
|
||||
|
||||
else:
|
||||
raise ValueError("Multiple dictionaries passes cannot merge args")
|
||||
raise ValueError("Multiple dictionaries passes cannot merge args")
|
||||
|
||||
|
||||
def hostname_list(args):
|
||||
"""
|
||||
Generates a list from a hostname string
|
||||
* Lists are passed through
|
||||
* as are tuples (conversion in pybind11 to vector)
|
||||
* if + is found it splits the string
|
||||
"""
|
||||
if isinstance(args, (list, tuple)):
|
||||
return args
|
||||
elif(isinstance(args, str)):
|
||||
hosts = args.split('+')
|
||||
hosts = [it for it in hosts if len(it)]
|
||||
return hosts
|
||||
else:
|
||||
raise ValueError("hostname needs to be string or list of strings")
|
||||
|
Reference in New Issue
Block a user