Cross Check the reply against the input vsiid,mac for get query.
333491
def crosscheck_query_vsiid_mac(self, reply, vsiid, mac):
        
        vsiid_reply = reply.partition("uuid")[2].split()[0][4:]
        if vsiid != vsiid_reply:
            fail_reason = vdp_const.vsi_mismatch_failure_reason % (
                vsiid, vsiid_reply)
            LOG.error("%s", fail_reason)
            return False, fail_reason
        mac_reply = reply.partition("filter")[2].split('-')[1]
        if mac != mac_reply:
            fail_reason = vdp_const.mac_mismatch_failure_reason % (
                mac, mac_reply)
            LOG.error("%s", fail_reason)
            return False, fail_reason
        return True, None
1005244
def inline_query(self):
        """"""
        if isinstance(self.button, types.KeyboardButtonSwitchInline):
            return self.button.query
157240
private HttpResponse getResponse(StringBuilder q, String _id) throws URISyntaxException, IOException,
            ClientProtocolException
    {
        URI uri = new URI(CouchDBConstants.PROTOCOL, null, httpHost.getHostName(), httpHost.getPort(), _id,
                q.toString(), null);
        HttpGet get = new HttpGet(uri);
        get.addHeader("Accept", "application/json");
        return httpClient.execute(httpHost, get, CouchDBUtils.getContext(httpHost));
    }
928625
def check(line, queries):
    
    line = line.strip()
    spLine = line.replace('.', ' ').split()
    matches = set(spLine).intersection(queries)
    if len(matches) > 0:
        return matches, line.split('\t')
    return matches, False
489837
function getPostQuery(body) {
  if (!body) return {};

  let result = {};
  let commentReg = /^\[(\w+)\]\:([\s|\S]+)/;
  body.split('\r\n').every((item) => {
    let itemMatch = item.match(commentReg);
    if (itemMatch && itemMatch.length == 3) {
      let queryKey = itemMatch[1],
        queryVal = itemMatch[2];
      result[queryKey] = queryVal && queryVal.trim();
      return true;
    } else {
      return false;
    }
  })

  return result;
}
134689
def respond_to?(m)
      return true if super
      return true if has_key?(key)
      return true if has_key?(key.to_s)
      has_key?(key.to_sym)
    end
135511
def get_vlan_from_associate_reply(self, reply, vsiid, mac):
        
        try:
            verify_flag, fail_reason = self.crosscheck_reply_vsiid_mac(
                reply, vsiid, mac)
            if not verify_flag:
                return constants.INVALID_VLAN, fail_reason
            mode_str = reply.partition("mode = ")[2].split()[0]
            if mode_str != "assoc":
                fail_reason = self.get_vdp_failure_reason(reply)
                return constants.INVALID_VLAN, fail_reason
        except Exception:
            fail_reason = vdp_const.mode_failure_reason % (reply)
            LOG.error("%s", fail_reason)
            return constants.INVALID_VLAN, fail_reason
        check_filter, fail_reason = self.check_filter_validity(
            reply, "filter = ")
        if not check_filter:
            return constants.INVALID_VLAN, fail_reason
        try:
            vlan_val = reply.partition("filter = ")[2].split('-')[0]
            vlan = int(vlan_val)
        except ValueError:
            fail_reason = vdp_const.format_failure_reason % (reply)
            LOG.error("%s", fail_reason)
            return constants.INVALID_VLAN, fail_reason
        return vlan, None
47384
def check_exists(required, input)
      required.inject(true) do |result, key|
        input[key] && result
      end
    end
893532
def _check_response(response, items, default, indexed, stream, insensitive, fuzzy):
    ''''''
    # Set selection
    selection = None
    # if indexed, check for index
    if indexed:
        if response.isdigit():
            index_response = int(response)
            if index_response < len(items):
                selection = items[index_response]
    # if not matched by an index, match by text
    if selection is None:
        # insensivitize, if necessary
        original_items = items[:]
        original_response = response
        if insensitive:
            response = response.lower()
            items = [i.lower() for i in items]
        # Check for text matches
        if fuzzy:
            matches = _get_fuzzy_matches(response, items)
        # if insensitive, lowercase the comparison
        else:
            matches = [i for i in items if i.startswith(response)]
        # re-sensivitize if necessary
        if insensitive:
            matches = [
                i for i in original_items
                if i.lower() in matches
            ]
            response = original_response
        num_matches = len(matches)
        # Empty response, no default
        if response == '' and default is None:
            stream.write("[!] an empty response is not valid.\n")
        elif response == '':
            selection = default
        # Bad response
        elif num_matches == 0:
            stream.write("[!] \"{response}\" does not match any of the valid choices.\n".format(
                response=response
            ))
        # One match
        elif num_matches == 1:
            selection = matches[0]
        # Multiple matches
        else:
            # look for an exact match
            selection = _exact_match(response, matches, insensitive, fuzzy)
            # Multiple matches left
            if selection is None:
                stream.write("[!] \"{response}\" matches multiple choices:\n".format(
                    response=response
                ))
                for match in matches:
                    stream.write("[!]   {}\n".format(match))
                stream.write("[!] Please specify your choice further.\n")
    return selection
1281032
def ask(message, options):
    """"""
    while 1:
        if os.environ.get('PIP_NO_INPUT'):
            raise Exception('No input was expected ($PIP_NO_INPUT set); question: %s' % message)
        response = raw_input(message)
        response = response.strip().lower()
        if response not in options:
            print('Your response (%r) was not one of the expected responses: %s' % (
                response, ', '.join(options)))
        else:
            return response
1070479
def pull_reply(self, param=None, must=[APIKEY]):
        '''
        '''
        param = {} if param is None else param
        r = self.verify_param(param, must)
        if not r.is_succ():
            return r
        h = CommonResultHandler(lambda rsp: {VERSION_V1:rsp[SMS_REPLY] if SMS_REPLY in rsp else None, VERSION_V2:rsp}[self.version()])
        return self.path('pull_reply.json').post(param, h, r)
857809
private boolean checkVmIsOnline() {

		String zoneName = OpenstackIaasHandler.findZoneName( this.novaApi, this.targetProperties );
		Server server = this.novaApi.getServerApiForZone( zoneName ).get(this.machineId);
		return Status.ACTIVE.equals(server.getStatus());
	}
672350
def _do_query(self, query, iph, eth, in_port, msg):
        """"""
        datapath = msg.datapath
        dpid = datapath.id
        ofproto = datapath.ofproto
        parser = datapath.ofproto_parser

        # learn the querier.
        self._to_querier[dpid] = {
            'port': in_port,
            'ip': iph.src,
            'mac': eth.src
        }

        # set the timeout time.
        timeout = igmp.QUERY_RESPONSE_INTERVAL
        if query.maxresp:
            timeout = query.maxresp / 10

        self._to_hosts.setdefault(dpid, {})
        if query.address == '0.0.0.0':
            # general query. reset all reply status.
            for group in self._to_hosts[dpid].values():
                group['replied'] = False
                group['leave'] = None
        else:
            # specific query. reset the reply status of the specific
            # group.
            group = self._to_hosts[dpid].get(query.address)
            if group:
                group['replied'] = False
                group['leave'] = None

        actions = [parser.OFPActionOutput(ofproto.OFPP_FLOOD)]
        self._do_packet_out(
            datapath, msg.data, in_port, actions)

        # wait for REPORT messages.
        hub.spawn(self._do_timeout_for_query, timeout, datapath)
69107
def ask_yesno(query, default=None):
    """"""
    if default is None:
        default_q = ' [y/n]'
    elif default is True:
        default_q = ' [Y/n]'
    elif default is False:
        default_q = ' [y/N]'
    if sys.version_info[0] == 3:
        inp = raw_input("{query}{default_q} ".format(
            query=query, default_q=default_q)).strip()
    else:
        inp = raw_input("{query}{default_q} ".format(
            query=query, default_q=default_q).encode('utf-8')).strip()
    if inp:
        return inp.lower().startswith('y')
    elif default is not None:
        return default
    else:
        # Loop if no answer and no default.
        return ask_yesno(query, default)
346137
def ask(question, escape=True):
    ""
    answer = raw_input(question)
    if escape:
        answer.replace('"', '\\"')
    return answer.decode('utf')
747962
def get_by_id(self, reply_id):
        '''
        
        '''
        reply = MReply.get_by_uid(reply_id)
        logger.info('get_reply: {0}'.format(reply_id))

        self.render('misc/reply/show_reply.html',
                    reply=reply,
                    username=reply.user_name,
                    date=reply.date,
                    vote=reply.vote,
                    uid=reply.uid,
                    userinfo=self.userinfo,
                    kwd={})
1272356
function(input) {
    // Deny RETURN unless the command might work
    if (this.requisition.status !== Status.VALID) {
      return Promise.resolve(false);
    }

    this.terminal.history.add(input);
    this.terminal.unsetChoice().catch(util.errorHandler);

    this.terminal._previousValue = this.terminal.inputElement.value;
    this.terminal.inputElement.value = '';

    return this.requisition.exec().then(function() {
      this.textChanged();
      return true;
    }.bind(this));
  }