def __init__( self, table_name, required_insert_names, return_col_names=[], optional_insert_names=[], default_insert_values={}, *args, **kwargs ): """ ~Params table_name (str): name of the table to insert to required_insert_names (list): list of names (str) of the table columns which must be included on every requested insert return_col_names (list): list of names (str) of columns whose values should be returned on completion of the insert optional_insert_names (list): list of names (str) of columns which the user may specify on an insert request, but which may be omitted default_insert_values (dict): dictionary of {column_names: values} to serve as defaults when inserting, any values provided explicitly on the insert request will override these values ~Params """ Endpoint.__init__(self, *args, **kwargs) self._table_name = table_name self._return_names = return_col_names self._required_insert_names = required_insert_names self._optional_insert_names = optional_insert_names self._default_insert_dict = default_insert_values
def __init__(self, conditional_insert_field, spectrum_field, sensor_name_mean, sensor_name_std, do_upsert=False, *args, **kwargs): ''' do_upsert (bool): indicates if conflicting inserts should then update conditional_insert_field (string): name of an input kwarg field on inserts to cast to bool and determine if a log should be inserted default is true if the field is missing spectrum_field (string): name of an input kwarg field on inserts which contains an iterable of values for which moments will be calculated sensor_name_mean (string): name of the sensor to log with the mean of the spectrum sensor_name_std (string): name of the sensor to log with the STD of the spectrum ''' if not 'sqlalchemy' in globals(): raise ImportError( 'SQLAlchemy not found, required for SQLTable class') self.conditional_insert_field = conditional_insert_field self.spectrum_field = spectrum_field self.sensor_name_mean = sensor_name_mean self.sensor_name_std = sensor_name_std Endpoint.__init__(self, *args, **kwargs) SQLTable.__init__(self, *args, **kwargs) self.do_upsert = do_upsert
def __init__(self, table_name, schema=None, required_insert_names=[], return_col_names=[], optional_insert_names=[], default_insert_values={}, *args, **kwargs): ''' table_name (str): name of the table within the database schema (str): name of the schema where the table is located required_insert_names (list): list of names (str||dict) of the table columns which must be included on every requested insert (if dict: keys are 'column' and 'payload_key', if string it is assumed that both are that value) return_col_names (list): list of names (str) of columns whose values should be returned on completion of the insert optional_insert_names (list): list of names (str||dict) of columns which the user may specify on an insert request, but which may be omitted (if dict: keys are 'column' and 'payload_key', if string it is assumed that both are that value) default_insert_values (dict): dictionary of {column_names: values} to serve as defaults when inserting, any values provided explicitly on the insert request will override these values ''' if not 'sqlalchemy' in globals(): raise ImportError( 'SQLAlchemy not found, required for SQLTable class') Endpoint.__init__(self, *args, **kwargs) self.table = None self.table_name = table_name self.schema = schema self._return_names = return_col_names self._column_map = {} self._required_insert_names = self._ensure_col_key_map( required_insert_names) self._optional_insert_names = self._ensure_col_key_map( optional_insert_names) self._default_insert_dict = default_insert_values
def __init__(self,broker=None,sleep_time = 10,*args, **kwargs): Endpoint.__init__(self,**kwargs) # setting the interface self.connection_to_alert = dripline.core.Service(broker=broker, exchange='alerts',keys='status_message.p8_alerts.dripline') #sending a welcome message self.this_channel = 'p8_alerts' self.username = self.name self.sleep_time = sleep_time
def __init__(self, do_upsert=False, ignore_keys=[], *args, **kwargs): ''' do_upsert (bool): indicates if conflicting inserts should then update ignore_keys (list of strings): list of names of payload keys which should not be mapped to columns on an insert, even if present ''' if not 'sqlalchemy' in globals(): raise ImportError( 'SQLAlchemy not found, required for SQLTable class') self.ignore_keys = ignore_keys Endpoint.__init__(self, *args, **kwargs) SQLTable.__init__(self, *args, **kwargs) self.do_upsert = do_upsert
def __init__(self, targets=[], **kwargs): ''' targets (list): list of dictionaries which must provide a value for 'target', other optional fields: default_set: always set endpoint to this value payload_field (str): return payload field to get (value_cal, value_raw, or values) units (str): display units for 'calibrated' return value formatter (str): special formatting for 'calibrated' return string tolerance: check tolerance no_check (bool): disable set_and_check; necessary for set-only endpoints! get_target (str): endpoint to get for check (default is 'target') target_value: alternate value to check against ''' Endpoint.__init__(self, **kwargs) self._targets = [] for a_target in targets: these_details = {} ## SET options if 'default_set' in a_target: these_details.update({'default_set':a_target['default_set']}) ## GET options if 'payload_field' in a_target: these_details.update({'payload_field':a_target['payload_field']}) else: these_details.update({'payload_field':'value_cal'}) if 'units' in a_target and 'formatter' in a_target: raise exceptions.DriplineValueError('may not specify both "units" and "formatter"') if 'formatter' in a_target: these_details['formatter'] = a_target['formatter'] elif 'units' in a_target: these_details['formatter'] = '{} -> {} [{}]'.format(a_target['target'], '{}', a_target['units']) else: these_details['formatter'] = '{} -> {}'.format(a_target['target'], '{}') ## CHECK options if 'tolerance' in a_target: these_details.update({'tolerance':a_target['tolerance']}) else: these_details.update({'tolerance': 1.}) if 'no_check' in a_target: these_details.update({'no_check':a_target['no_check']}) else: these_details.update({'no_check':False}) if 'get_target' in a_target: these_details.update({'get_name':a_target['get_target']}) else: these_details.update({'get_name':a_target['target']}) if 'target_value' in a_target: these_details.update({'target_value':a_target['target_value']}) self._targets.append([a_target['target'], these_details])
def __init__(self, file_name="/tmp/step_atten.txt", **kwargs): self.file_name=file_name Endpoint.__init__(self, **kwargs)