def add_endpoint(self, endpoint): Provider.add_endpoint(self, endpoint) if isinstance(endpoint, SQLTable): logger.debug("Adding endpoint {} to the table".format(endpoint.table_name)) endpoint.table = sqlalchemy.Table(endpoint.table_name, self.meta, autoload=True, schema=endpoint.schema) if isinstance(endpoint, SQLSnapshot): self._endpoint_name_set.update(endpoint.target_items)
def __init__(self, repeat_target, broker, timeout=10, **kwargs): Provider.__init__(self, **kwargs) self._timeout = timeout self._repeat_target = repeat_target self._broker_info = broker
def __init__(self, database_name, database_server, metadata_target="", **kwargs): """ database_name (str): name of the database to connect to database_server (str): network resolvable hostname of database server metadata_target (str): target to send metadata to """ Provider.__init__(self, **kwargs) self._connect_to_db(database_server, database_name) self._metadata_target = metadata_target self._endpoint_name_set = set()
def __init__(self, modbus_host=None, modbus_port=502, **kwargs): ''' ''' Provider.__init__(self, **kwargs) if modbus_host is None: raise ValueError( "modbus_host is a required configuration parameter for <modbus_provider>" ) self.modbus_client = pyModbusTCP.client.ModbusClient(host=modbus_host, port=modbus_port, auto_open=True)
def __init__(self, database_name, database_server, tables, *args, **kwargs): """ ~Params database_name (str): name of the database to connect to database_server (str): network resolvable hostname of database server tables (list): list of names (str) of tables in the database ~Params """ if isinstance(tables, types.StringType): tables = [tables] Provider.__init__(self, *args, **kwargs) self.tables = {} self.connect_to_db(database_server, database_name, tables)
def __init__(self, port = '', command_terminator='', response_terminator='', serial_kwargs=None, **kwargs): Provider.__init__(self, **kwargs) self.alock = threading.Lock() self.port = port self.command_terminator = command_terminator self.response_terminator = response_terminator self.serial_kwargs = serial_kwargs if self.serial_kwargs is None: self.serial_kwargs = { 'timeout' : 1 } self._reconnect()
def __init__(self, socket_timeout=1.0, socket_info=("localhost",1234), response_terminator=None, bare_response_terminator=None, command_terminator=None, reply_echo_cmd=False, cmd_at_reconnect=None, **kwargs ): ''' socket_timeout (float): time in seconds for the socket to timeout socket_info (tuple): (<network_address_as_str>, <port_as_int>) response_terminator (str||None): string to strip from responses, this MUST exist for get method to function properly! bare_response_terminator (str||None): abbreviated string to strip from responses containing only prompt : only used to handle non-standard glenlivet behavior command_terminator (str||None): string to append to commands reply_echo_cmd (bool): set to True if command+command_terminator or just command are present in reply cmd_at_reconnect (str, list||None): (list of) command(s) to send to the instrument following (re)connection to the instrument : still must ask for a reply! ''' Provider.__init__(self, **kwargs) self.alock = threading.Lock() self.socket_timeout = float(socket_timeout) self.socket_info = socket_info self.socket = socket.socket() if response_terminator is None or response_terminator == "": raise ValueError("Invalid response terminator!") self.response_terminator = response_terminator self.bare_response_terminator = bare_response_terminator self.command_terminator = command_terminator self.reply_echo_cmd = reply_echo_cmd if isinstance(cmd_at_reconnect, types.StringType): cmd_at_reconnect = [cmd_at_reconnect] self.cmd_at_reconnect = cmd_at_reconnect if type(self.socket_info) is str: import re re_str = "\([\"'](\S+)[\"'], ?(\d+)\)" (ip,port) = re.findall(re_str,self.socket_info)[0] self.socket_info = (ip,int(port)) logger.debug('socket info is {}'.format(self.socket_info)) self.reconnect()
def __init__(self, port='/dev/ttyUSB2', baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, **kwargs ): ''' > Connection-related options: socket_timeout (float): time in seconds for the socket to timeout socket_info (tuple): (<network_address_as_str>, <port_as_int>) cmd_at_reconnect (list||None): list of command(s) to send to the instrument following (re)connection to the instrument, still must return a reply! : if impossible, set as None to skip reconnect_test (str): expected return value from final reconnect command > Query-related options: command_terminator (str): string to append to commands response_terminator (str||None): string to strip from responses, this MUST exist for get method to function properly! bare_response_terminator (str||None): abbreviated string to strip from responses containing only prompt : only used to handle non-standard lockin behavior reply_echo_cmd (bool): set to True if command+command_terminator or just command are present in reply ''' Provider.__init__(self, **kwargs) self.alock = threading.Lock() self.serial = serial.Serial( port='/dev/ttyUSB2', baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS ) self.port = port self.baudrate = baudrate self.parity = parity self.bytesize = bytesize self.serial.isOpen() the_command='gain(4)=12\r\n' self.serial.write(the_command.encode())
def __init__(self, name, **kwargs): Provider.__init__(self, name=name, **kwargs)
def __init__(self, **kwargs): Provider.__init__(self, **kwargs)
def __init__(self, name, addr, **kwargs): Provider.__init__(self, name=name, **kwargs) self.addr = addr self.status = 0 self.provider = None self._cmd_term = '\n'