Insert data into `wm_strokes_to_symbol`.

    Parameters
    ----------
    raw_data_id : int
    user_id : int
    strokes: list of int
321145
def insert_symbol_mapping(raw_data_id, symbol_id, user_id, strokes):
    
    mysql = utils.get_mysql_cfg()
    connection = pymysql.connect(host=mysql['host'],
                                 user=mysql['user'],
                                 passwd=mysql['passwd'],
                                 db=mysql['db'],
                                 charset='utf8mb4',
                                 cursorclass=pymysql.cursors.DictCursor)
    cursor = connection.cursor()
    sql = ("INSERT INTO `wm_partial_answer` "
           "(`recording_id`, `symbol_id`, `strokes`, `user_id`, "
           "`is_accepted`) "
           "VALUES (%s, %s, %s, %s, 1);")
    data = (raw_data_id,
            symbol_id,
            ",".join([str(stroke) for stroke in strokes]),
            user_id)
    cursor.execute(sql, data)
    connection.commit()
1294389
def png_data_uri(self, **kw):
        
        return writers.as_png_data_uri(self.matrix, self._version, **kw)
415817
def PILTowx(pimg):
    ''''''
    from MAVProxy.modules.lib.wx_loader import wx
    wimg = wx.EmptyImage(pimg.size[0], pimg.size[1])
    try:
        wimg.SetData(pimg.convert('RGB').tobytes())
    except NotImplementedError:
        # old, removed method:
        wimg.SetData(pimg.convert('RGB').tostring())
    return wimg
852778
def save_user_template(self, user, fingers=[]):
        
        if not isinstance(user, User):
            users = self.get_users()
            tusers = list(filter(lambda x: x.uid==user, users))
            if len(tusers) == 1:
                user = tusers[0]
            else:
                tusers = list(filter(lambda x: x.user_id==str(user), users))
                if len(tusers) == 1:
                    user = tusers[0]
                else:
                    raise ZKErrorResponse("Can't find user")
        if isinstance(fingers, Finger):
            fingers = [fingers]
        fpack = b""
        table = b""
        fnum = 0x10
        tstart = 0
        for finger in fingers:
            tfp = finger.repack_only()
            table += pack("<bHbI", 2, user.uid, fnum + finger.fid, tstart)
            tstart += len(tfp)
            fpack += tfp
        if self.user_packet_size == 28:
            upack = user.repack29()
        else:
            upack = user.repack73()
        head = pack("III", len(upack), len(table), len(fpack))
        packet = head + upack + table + fpack
        self._send_with_buffer(packet)
        command = 110
        command_string = pack('<IHH', 12,0,8)
        cmd_response = self.__send_command(command, command_string)
        if not cmd_response.get('status'):
            raise ZKErrorResponse("Can't save utemp")
        self.refresh_data()
162188
def _insert_uow(self, process_name, timeperiod, start_timeperiod, end_timeperiod, start_id, end_id):
        
        uow = UnitOfWork()
        uow.process_name = process_name
        uow.timeperiod = timeperiod
        uow.start_id = str(start_id)
        uow.end_id = str(end_id)
        uow.start_timeperiod = start_timeperiod
        uow.end_timeperiod = end_timeperiod
        uow.created_at = datetime.utcnow()
        uow.submitted_at = datetime.utcnow()
        uow.source = context.process_context[process_name].source
        uow.sink = context.process_context[process_name].sink
        uow.state = unit_of_work.STATE_REQUESTED
        uow.unit_of_work_type = unit_of_work.TYPE_MANAGED
        uow.number_of_retries = 0
        uow.arguments = context.process_context[process_name].arguments
        uow.db_id = self.uow_dao.insert(uow)

        msg = 'Created: UOW {0} for {1}@{2}.'.format(uow.db_id, process_name, start_timeperiod)
        self._log_message(INFO, process_name, start_timeperiod, msg)
        return uow
1287123
def save_data(trigger_id, data):
    
    status = True
    # consumer - the service which uses the data
    default_provider.load_services()
    service = TriggerService.objects.get(id=trigger_id)

    service_consumer = default_provider.get_service(str(service.consumer.name.name))
    kwargs = {'user': service.user}

    if len(data) > 0:
        getattr(service_consumer, '__init__')(service.consumer.token, **kwargs)
        status = getattr(service_consumer, 'save_data')(service.id, **data)

    return status
556207
def insert(self, packet, **kwargs):
        ''' 

        '''
        values = [ ]
        pd     = packet._defn

        for defn in pd.fields:
            val = getattr(packet.raw, defn.name)

            if val is None and defn.name in pd.history:
                val = getattr(packet.history, defn.name)
            
            values.append(val)

        qmark = ['?'] * len(values)
        sql   = 'INSERT INTO %s VALUES (%s)' % (pd.name, ', '.join(qmark))


        self._conn.execute(sql, values)
216726
def change_uid(bridge_id, new_uwnetid, no_custom_fields=True):
    
    url = author_id_url(bridge_id)
    if not no_custom_fields:
        url += ("?%s" % CUSTOM_FIELD)
    resp = patch_resource(url, '{"user":{"uid":"%s@uw.edu"}}' % new_uwnetid)
    return _process_json_resp_data(resp,
                                   no_custom_fields=no_custom_fields)
674358
def _insert_data(self, name, value, timestamp, interval, config, **kwargs):
    ''''''
    kwargs = {
      'name'        : name,
      'interval'    : interval,
      'insert_time' : time.time(),
      'i_time'      : config['i_calc'].to_bucket(timestamp),
      'value'       : value
    }
    if not config['coarse']:
      kwargs['r_time'] = config['r_calc'].to_bucket(timestamp)
    stmt = self._table.insert().values(**kwargs)
    conn = self._client.connect()
    result = conn.execute(stmt)
1124984
async def on_raw_353(self, message):
        
        target, visibility, channel, names = message.params
        if not self.in_channel(channel):
            return

        # Set channel visibility.
        if visibility == protocol.PUBLIC_CHANNEL_SIGIL:
            self.channels[channel]['public'] = True
        elif visibility in (protocol.PRIVATE_CHANNEL_SIGIL, protocol.SECRET_CHANNEL_SIGIL):
            self.channels[channel]['public'] = False

        # Update channel user list.
        for entry in names.split():
            statuses = []
            # Make entry safe for _parse_user().
            safe_entry = entry.lstrip(''.join(self._nickname_prefixes.keys()))
            # Parse entry and update database.
            nick, metadata = self._parse_user(safe_entry)
            self._sync_user(nick, metadata)

            # Get prefixes.
            prefixes = set(entry.replace(safe_entry, ''))

            # Check, record and strip status prefixes.
            for prefix, status in self._nickname_prefixes.items():
                # Add to list of statuses by user.
                if prefix in prefixes:
                    statuses.append(status)

            # Add user to user list.
            self.channels[channel]['users'].add(nick)
            # And to channel modes..
            for status in statuses:
                if status not in self.channels[channel]['modes']:
                    self.channels[channel]['modes'][status] = []
                self.channels[channel]['modes'][status].append(nick)
986092
def _insert(self, name, value, timestamp, intervals, **kwargs):
    '''
    
    '''
    if self._value_type in QUOTE_TYPES and not QUOTE_MATCH.match(value):
      value = "'%s'"%(value)

    for interval,config in self._intervals.items():
      timestamps = self._normalize_timestamps(timestamp, intervals, config)
      for tstamp in timestamps:
        self._insert_data(name, value, tstamp, interval, config, **kwargs)
137298
def filter_and_save(raw, symbol_ids, destination_path):
    
    logging.info('Start filtering...')
    new_hw_ds = []
    for el in raw['handwriting_datasets']:
        if el['formula_id'] in symbol_ids:
            el['formula_id'] = symbol_ids[el['formula_id']]
            el['handwriting'].formula_id = symbol_ids[el['formula_id']]
            new_hw_ds.append(el)
    raw['handwriting_datasets'] = new_hw_ds

    # pickle
    logging.info('Start dumping %i recordings...', len(new_hw_ds))
    pickle.dump(raw, open(destination_path, "wb"), 2)
61249
def process_raw(self, raw: str) -> None:
        
        raw_dict = dict(group.split('=') for group in raw.splitlines())

        raw_users = {
            user: {
                group: user in REGEX_STRING.findall(raw_dict[group])
                for group in [ADMIN, OPERATOR, VIEWER, PTZ]
            }
            for user in REGEX_STRING.findall(raw_dict['users'])
        }

        super().process_raw(raw_users)
52244
def add_raw_data(self, data, attrs):
        
        self.assert_writeable()
        if "Raw" not in self.handle:
            self.handle.create_group("Raw")
        if "Signal" in self.handle['Raw']:
            msg = "Fast5 file already has raw data for read '{}' in: {}"
            raise KeyError(msg.format(self.read_id, self.filename))
        self.handle['Raw'].create_dataset('Signal', data=data, compression='gzip', shuffle=True, dtype='i2')
        self._add_attributes("Raw", attrs, clear=True)
777158
def set_raw_data(self, raw_data):
        
        #pre-parsed data should exist
        assert(self.__hid_object.is_opened())
        #valid length
        if len(raw_data) != self.__raw_report_size:
            raise HIDError( "Report size has to be %d elements (bytes)" \
                % self.__raw_report_size )
        # copy to internal storage
        self.__alloc_raw_data(raw_data)

        if not self.__usage_data_list: # create HIDP_DATA buffer
            max_items = hid_dll.HidP_MaxDataListLength(self.__report_kind,
                self.__hid_object.ptr_preparsed_data)
            data_list_type = winapi.HIDP_DATA * max_items
            self.__usage_data_list = data_list_type()
        #reference HIDP_DATA buffer
        data_list = self.__usage_data_list
        data_len = c_ulong(len(data_list))

        #reset old values
        for item in self.values():
            if item.is_value_array():
                item.value = [0, ]*len(item)
            else:
                item.value = 0
        #ready, parse raw data
        HidStatus( hid_dll.HidP_GetData(self.__report_kind,
            byref(data_list), byref(data_len),
            self.__hid_object.ptr_preparsed_data,
            byref(self.__raw_data), len(self.__raw_data)) )

        #set values on internal report item objects
        for idx in range(data_len.value):
            value_item = data_list[idx]
            report_item = self.__idx_items.get(value_item.data_index)
            if not report_item:
                # This is not expected to happen
                continue
            if report_item.is_value():
                report_item.value = value_item.value.raw_value
            elif report_item.is_button():
                report_item.value = value_item.value.on
            else:
                pass # HID API should give us either, at least one of 'em
        #get values of array items
        for item in self.__value_array_items:
            #ask hid API to parse
            HidStatus( hid_dll.HidP_GetUsageValueArray(self.__report_kind,
                item.page_id,
                0, #link collection
                item.usage_id, #short usage
                byref(item.value_array), #output data (c_ubyte storage)
                len(item.value_array), self.__hid_object.ptr_preparsed_data,
                byref(self.__raw_data), len(self.__raw_data)) )
1076093
def _get_data_from_rawfile(path_to_data, raw_data_id):
    """"""
    loaded = pickle.load(open(path_to_data, "rb"))
    raw_datasets = loaded['handwriting_datasets']
    for raw_dataset in raw_datasets:
        if raw_dataset['handwriting'].raw_data_id == raw_data_id:
            return raw_dataset['handwriting']
    return None
941128
def AddEventData(self, event_data):
    
    self._RaiseIfNotWritable()

    event_data = self._PrepareAttributeContainer(event_data)

    identifier = event_data.GetIdentifier()
    lookup_key = identifier.CopyToString()
    self._event_data[lookup_key] = event_data