Wait for card insertion and returns a card service.
163854
def waitforcard(self):
        """"""
        AbstractCardRequest.waitforcard(self)
        cardfound = False

        # for non infinite timeout, a timer will signal
        # the end of the time-out by setting the evt event
        evt = threading.Event()
        if INFINITE == self.timeout:
            timertimeout = 1
        else:
            timertimeout = self.timeout
        timer = threading.Timer(
            timertimeout, signalEvent, [evt, INFINITE == self.timeout])

        # create a dictionary entry for new readers
        readerstates = {}
        readernames = self.getReaderNames()
        for reader in readernames:
            if not reader in readerstates:
                readerstates[reader] = (reader, SCARD_STATE_UNAWARE)

        # remove dictionary entry for readers that disappeared
        for oldreader in list(readerstates.keys()):
            if oldreader not in readernames:
                del readerstates[oldreader]

        # call SCardGetStatusChange only if we have some readers
        if {} != readerstates:
            hresult, newstates = SCardGetStatusChange(
                self.hcontext, 0, list(readerstates.values()))
        else:
            hresult = 0
            newstates = []

        # we can expect normally time-outs or reader
        # disappearing just before the call
        # otherwise, raise execption on error
        if 0 != hresult and \
            SCARD_E_TIMEOUT != hresult and \
            SCARD_E_UNKNOWN_READER != hresult:
                raise CardRequestException(
                    'Failed to SCardGetStatusChange ' + \
                    SCardGetErrorMessage(hresult))

        # in case of timeout or reader disappearing,
        # the content of the states is useless
        # in which case we clear the changed bit
        if SCARD_E_TIMEOUT == hresult or SCARD_E_UNKNOWN_READER == hresult:
            for state in newstates:
                state[1] = state[1] & (0xFFFFFFFF ^ SCARD_STATE_CHANGED)

        # update readerstate
        for state in newstates:
            readername, eventstate, atr = state
            readerstates[readername] = (readername, eventstate)

        # if a new card is not requested, just return the first available
        if not self.newcardonly:
            for state in newstates:
                readername, eventstate, atr = state
                if eventstate & SCARD_STATE_PRESENT:
                    reader = PCSCReader(readername)
                    if self.cardType.matches(atr, reader):
                        if self.cardServiceClass.supports('dummy'):
                            cardfound = True
                            return self.cardServiceClass(
                                    reader.createConnection())

        timerstarted = False
        while not evt.isSet() and not cardfound:

            if not timerstarted:
                timerstarted = True
                timer.start()

            time.sleep(self.pollinginterval)

            # create a dictionary entry for new readers
            readernames = self.getReaderNames()
            for reader in readernames:
                if not reader in readerstates:
                    readerstates[reader] = (reader, SCARD_STATE_UNAWARE)

            # remove dictionary entry for readers that disappeared
            for oldreader in list(readerstates.keys()):
                if oldreader not in readernames:
                    del readerstates[oldreader]

            # wait for card insertion
            if {} != readerstates:
                hresult, newstates = SCardGetStatusChange(
                    self.hcontext, 0, list(readerstates.values()))
            else:
                hresult = SCARD_E_TIMEOUT
                newstates = []

            # time-out
            if SCARD_E_TIMEOUT == hresult:
                if evt.isSet():
                    raise CardRequestTimeoutException()

            # reader vanished before or during the call
            elif SCARD_E_UNKNOWN_READER == hresult:
                pass

            # some error happened
            elif 0 != hresult:
                timer.cancel()
                raise CardRequestException(
                    'Failed to get status change ' + \
                    SCardGetErrorMessage(hresult))

            # something changed!
            else:

                # check if we have to return a match, i.e.
                # if no new card in inserted and there is a card found
                # or if a new card is requested, and there is a change+present
                for state in newstates:
                    readername, eventstate, atr = state
                    r, oldstate = readerstates[readername]

                    # the status can change on a card already inserted, e.g.
                    # unpowered, in use, ...
                    # if a new card is requested, clear the state changed bit
                    # if the card was already inserted and is still inserted
                    if self.newcardonly:
                        if oldstate & SCARD_STATE_PRESENT and \
                            eventstate & \
                                (SCARD_STATE_CHANGED | SCARD_STATE_PRESENT):
                            eventstate = eventstate & \
                                (0xFFFFFFFF ^ SCARD_STATE_CHANGED)

                    if (self.newcardonly and \
                            eventstate & SCARD_STATE_PRESENT and \
                            eventstate & SCARD_STATE_CHANGED) or \
                        (not self.newcardonly and \
                         eventstate & SCARD_STATE_PRESENT):
                        reader = PCSCReader(readername)
                        if self.cardType.matches(atr, reader):
                            if self.cardServiceClass.supports('dummy'):
                                cardfound = True
                                timer.cancel()
                                return self.cardServiceClass(
                                        reader.createConnection())

                    # update state dictionary
                    readerstates[readername] = (readername, eventstate)

            if evt.isSet():
                raise CardRequestTimeoutException()
212421
def wait(self):
        '''
        
        '''
        @param_to_property(action=["exists", "gone"])
        def _wait(action, timeout=3000):
            if timeout / 1000 + 5 > int(os.environ.get("JSONRPC_TIMEOUT", 90)):
                http_timeout = timeout / 1000 + 5
            else:
                http_timeout = int(os.environ.get("JSONRPC_TIMEOUT", 90))
            method = self.device.server.jsonrpc_wrap(
                timeout=http_timeout
            ).waitUntilGone if action == "gone" else self.device.server.jsonrpc_wrap(timeout=http_timeout).waitForExists
            return method(self.selector, timeout)
        return _wait
23869
def to_request
        card = {
          number_token:       self.number_token,
          cardholder_name:    self.cardholder_name,
          security_code:      self.security_code,
          brand:              self.brand,
          expiration_month:   self.expiration_month,
          expiration_year:    self.expiration_year
        }

      return card
    end
1088893
def GetATR(self, reader):
        """"""
        atr = "no card inserted"
        try:
            if not type(reader) is str:
                connection = reader.createConnection()
                connection.connect()
                atr = toHexString(connection.getATR())
                connection.disconnect()
        except NoCardException:
            pass
        except CardConnectionException:
            pass
        return atr
88796
def wait_on_receipt(self):
        
        with self.receipt_condition:
            while not self.received:
                self.receipt_condition.wait()
        self.received = False
417993
def ActivateCard(self, card):
        """"""
        if not hasattr(card, 'connection'):
            card.connection = card.createConnection()
            if None != self.parent.apdutracerpanel:
                card.connection.addObserver(self.parent.apdutracerpanel)
            card.connection.connect()
        self.dialogpanel.OnActivateCard(card)
142400
private byte[] waitForResponse(final IndividualAddress from, final int minAsduLen, final int maxAsduLen,
		final long timeout) throws KNXInvalidResponseException, KNXTimeoutException, InterruptedException
	{
		return waitForResponse(from, minAsduLen, maxAsduLen, timeout, Optional.empty());
	}
489664
def card(self):
        
        body, more, is_markdown = self._entry_content
        return TrueCallableProxy(
            self._get_card,
            body or more) if is_markdown else CallableProxy(None)
1138845
def getATR(reader):
    """"""
    connection = reader.createConnection()
    atr = ""
    try:
        connection.connect()
        atr = smartcard.util.toHexString(connection.getATR())
        connection.disconnect()
    except smartcard.Exceptions.NoCardException:
        atr = "no card inserted"
    return atr
188102
function (params, state, cb) {
                  state = state || {};

                  if (Card.getCardData) {
                    Card.getCardData(params, state, function (err, viewModel, clientLocals) {
                      cb(err, params, state, viewModel, clientLocals);
                    });
                  }
                  else {
                    cb(null, params, state, null, null);
                  }
                }
252791
async def _wait(self):
        '''
        
        '''
        for buid in self.otherbldgbuids:
            nodeevnt = self.allbldgbuids.get(buid)
            if nodeevnt is None:
                continue
            await nodeevnt[1].wait()
945271
def get(cls, card_id, custom_headers=None):
        

        if custom_headers is None:
            custom_headers = {}

        api_client = client.ApiClient(cls._get_api_context())
        endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(),
                                                     card_id)
        response_raw = api_client.get(endpoint_url, {}, custom_headers)

        return BunqResponseCard.cast_from_bunq_response(
            cls._from_json(response_raw, cls._OBJECT_TYPE_GET)
        )
128223
function get(uuid, callback) {
  if(!util.isFunction(callback)) {
    throw new Error('callback must be a function');
  }

  var order_url = this.coinjar.merchant.orders_endpoint + '/',
    resource = this.coinjar.merchant.api_endpoint +
      '/v1/orders/' +
      uuid +
      '.json';

  request.get(resource)
    .auth(this.coinjar.merchant.uuid, this.coinjar.merchant.secret)
    .end(function (response) {
      if(isResponseError(response, callback)) { return; }
      // build the payment page url
      response.body.order.payment_page_url = order_url + response.body.order.uuid;
      return callback(null, response.body.order);
    });
}
1100852
function wait(ms = 0) {
  return function(val) {
    return new Promise(resolve => setTimeout(_ => resolve(val), ms));
  };
}
1220043
def wait_for_unit(service_name, timeout=480):
    """"""
    wait_for_machine(num_machines=1)
    start_time = time.time()
    while True:
        state = unit_info(service_name, 'agent-state')
        if 'error' in state or state == 'started':
            break
        if time.time() - start_time >= timeout:
            raise RuntimeError('timeout waiting for service to start')
        time.sleep(SLEEP_AMOUNT)
    if state != 'started':
        raise RuntimeError('unit did not start, agent-state: ' + state)
916163
def retrieve(cls, *args, **kwargs):
        """"""
        return super(Card, cls).retrieve(*args, **kwargs)
1312088
def post(self, request, **kwargs):
		
		serializer = CreateSubscriptionSerializer(data=request.data)

		if serializer.is_valid():
			try:
				customer, _created = Customer.get_or_create(
					subscriber=subscriber_request_callback(self.request)
				)
				customer.add_card(serializer.data["stripe_token"])
				charge_immediately = serializer.data.get("charge_immediately")
				if charge_immediately is None:
					charge_immediately = True

				customer.subscribe(serializer.data["plan"], charge_immediately)
				return Response(serializer.data, status=status.HTTP_201_CREATED)
			except Exception:
				# TODO: Better error messages
				return Response(
					"Something went wrong processing the payment.", status=status.HTTP_400_BAD_REQUEST
				)

		return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)