Return entries without specified protocol (single log)
10012
def filter_data(self, data, values=None, args=None):
        """"""
        if args:
            if not args.rprotocol:
                return data
        if not values: values = args.rprotocol
        newdata = {}
        if 'parser' in data.keys():
            newdata['parser'] = data['parser']
            newdata['source_path'] = data['source_path']
            newdata['source_file'] = data['source_file']
            newdata['source_file_mtime'] = data['source_file_mtime']
            newdata['source_file_year'] = data['source_file_year']
        newdata['entries'] = []

        for entry in data['entries']:
            if 'protocol' in entry.keys():
                if entry['protocol'] not in values:
                    newdata['entries'].append(entry)
            else:
                newdata['entries'].append(entry)

        return newdata
1046919
async def async_get_event_log(self, index: int) -> Optional[EventLogResponse]:
        

        response = await self._protocol.async_execute(
            GetEventLogCommand(index))
        if isinstance(response, EventLogResponse):
            return response
        return None
1103636
def _prune_entries(self, num):
        ""
        while num > 0:
            self.access_log_lock.acquire()
            p = self.access_log.pop()
            self.access_log_lock.release()

            if not p.is_valid:
                continue # Invalidated entry, skip

            dict.pop(self, p.key, None)
            self.access_lookup.pop(p.key, None)
            num -= 1
317107
def nonpadding(self):
    """"""
    if self.sequence_id is None:
      return None
    if self.sequence_id == 1:
      return 1
    else:
      return mtf.cast(
          mtf.not_equal(self.sequence_id, 0), self.activation_dtype)
614809
def get_logs(self, unique_id, logs, directory, pattern=constants.FILTER_NAME_ALLOW_NONE):
    """"""
    self.fetch_logs(unique_id, logs, directory, pattern)
917696
def filter_unbound_ports(query):
    """"""
    # hack for pep8 E711: comparison to None should be
    # 'if cond is not None'
    none = None
    port_model = models_v2.Port
    binding_level_model = ml2_models.PortBindingLevel
    query = (query
             .join_if_necessary(port_model)
             .join_if_necessary(binding_level_model)
             .filter(
                 binding_level_model.host != '',
                 port_model.device_id != none,
                 port_model.network_id != none))
    return query
820150
private synchronized void ungetLogService() {
        doWarnIfClosed = doDebug();
        if (log != null) {
            bc.ungetService(logSR);
            logSR = null;
            log = null;
        }
    }
561214
def unpack(cls, msg, client, server, request_id):
        
        flags, = _UNPACK_INT(msg[:4])
        namespace, pos = _get_c_string(msg, 4)
        num_to_return, = _UNPACK_INT(msg[pos:pos + 4])
        pos += 4
        cursor_id, = _UNPACK_LONG(msg[pos:pos + 8])
        return OpGetMore(namespace=namespace, flags=flags, _client=client,
                         num_to_return=num_to_return, cursor_id=cursor_id,
                         request_id=request_id, _server=server)
811269
def common_log(environ, response, response_time=None):
    

    logger = logging.getLogger()

    if response_time:
        formatter = ApacheFormatter(with_response_time=True)
        try:
            log_entry = formatter(response.status_code, environ,
                                  len(response.content), rt_us=response_time)
        except TypeError:
            # Upstream introduced a very annoying breaking change on the rt_ms/rt_us kwarg.
            log_entry = formatter(response.status_code, environ,
                                  len(response.content), rt_ms=response_time)
    else:
        formatter = ApacheFormatter(with_response_time=False)
        log_entry = formatter(response.status_code, environ,
                              len(response.content))

    logger.info(log_entry)

    return log_entry
328787
def normalized_log_entries(raw_entries):
    ''''''
    entry_start = r'([0-9:, \-]+) - .* - (\w+) - (.*)$'
    entry = None
    # process start/end here - avoid parsing log entries twice
    for line in raw_entries:
        m = re.match(entry_start, line)
        if m:
            # this is the start of a new entry
            # spit out the one previously built up (if any)
            if entry is not None:
                yield entry
            (log_time, log_level, log_text) = m.groups()
            # convert time
            log_timestamp = _timestamp_from_string(log_time)
            # join level and first line of message
            msg = '[{}] {}'.format(log_level, log_text)
            entry = {
                'timestamp': log_timestamp,
                'message': msg,
            }
        else:
            # additional line(s) for entry (i.e. stack trace)
            entry['message'] = entry['message'] + line
    if entry is not None:
        # return the final entry
        yield entry
1297445
def Logs(c_type=None, grep_list=None):
    
    def get_logs(logs, log_entries):
        try:
            for log in logs:
                if str(container.name) in log_entries:
                    log_entries[str(container.name)].append(log)
                else:
                    log_entries[str(container.name)] = [log]
        except Exception as e:  # pragma: no cover
            logger.error('Unable to get logs for ' +
                         str(container.name) +
                         ' because: ' + str(e))
        return log_entries

    status = (True, None)
    log_entries = {}
    d_client = docker.from_env()
    containers = d_client.containers.list(all=True,
                                          filters={'label': 'vent'})
    logger.debug('containers found: ' + str(containers))
    comp_c = containers
    if c_type:
        try:
            comp_c = [c for c in containers
                      if (c_type
                          in c.attrs['Config']['Labels']['vent.groups'])]
        except Exception as e:  # pragma: no cover
            logger.error('Unable to limit containers by: ' +
                         str(c_type) + ' because: ' +
                         str(e))

    if grep_list:
        for expression in grep_list:
            for container in comp_c:
                try:
                    # 'logs' stores each line containing the expression
                    logs = [log for log in container.logs().split('\n')
                            if expression in log]
                    log_entries = get_logs(logs, log_entries)
                except Exception as e:  # pragma: no cover
                    logger.info('Unable to get logs for ' +
                                str(container) +
                                ' because: ' + str(e))
    else:
        for container in comp_c:
            try:
                logs = container.logs().split('\n')
                log_entries = get_logs(logs, log_entries)
            except Exception as e:  # pragma: no cover
                logger.info('Unabled to get logs for ' +
                            str(container) +
                            ' because: ' + str(e))

    status = (True, log_entries)
    return status
122923
def filter(self, record):
        """"""
        fmt = LogManager.spec.context_format
        if fmt:
            data = self.context.to_dict()
            if data:
                record.context = fmt % ",".join("%s=%s" % (key, val) for key, val in sorted(data.items()) if key and val)
            else:
                record.context = ""
        return True
582900
def get_protocol(self, protocol):
        
        result = self.get_protocols(protocol)
        if len(result) > 0:
            return result[0]
        return None
283728
def _remove_keys_from_dict_with_nonunique_values(self, d, log_fh=None, log_outprefix=None):
        ''''''
        value_counts = collections.Counter(d.values())
        new_d = {}
        writing_log_file = None not in [log_fh, log_outprefix]

        for key in d:
            if value_counts[d[key]] == 1:
                new_d[key] = d[key]
            elif writing_log_file:
                print(log_outprefix, 'Reject because non-unique:', d[key], sep='\t', file=log_fh)

        return new_d
1222125
def log_definition
      return unless @log.debug?
      @log.debug  "Filter: #{self}"
      Filter.single_write_accessors.keys.each do |name, gmail_name|
        val = send(:"get_#{name}")
        @log.debug "  #{name}: #{val}" if val
      end
      self
    end
567441
def _get_all_filtered_channels(self, topics_without_signature):
        
        mpe_address     = self.get_mpe_address()
        event_signature = self.ident.w3.sha3(text="ChannelOpen(uint256,uint256,address,address,address,bytes32,uint256,uint256)").hex()
        topics = [event_signature] + topics_without_signature
        logs = self.ident.w3.eth.getLogs({"fromBlock" : self.args.from_block, "address"   : mpe_address, "topics"    : topics})
        abi           = get_contract_def("MultiPartyEscrow")
        event_abi     = abi_get_element_by_name(abi, "ChannelOpen")
        channels_ids  = [get_event_data(event_abi, l)["args"]["channelId"] for l in logs]
        return channels_ids
1146899
def get_unspents(address, blockchain_client=BlockchainInfoClient()):
    
    if not isinstance(blockchain_client, BlockchainInfoClient):
        raise Exception('A BlockchainInfoClient object is required')

    url = BLOCKCHAIN_API_BASE_URL + "/unspent?format=json&active=" + address

    auth = blockchain_client.auth
    if auth and len(auth) == 2 and isinstance(auth[0], str):
        url = url + "&api_code=" + auth[0]

    r = requests.get(url, auth=auth)
    try:
        unspents = r.json()["unspent_outputs"]
    except ValueError, e:
        raise Exception('Invalid response from blockchain.info.')
    
    return format_unspents(unspents)