本文整理汇总了Python中smartcard.CardRequest.CardRequest类的典型用法代码示例。如果您正苦于以下问题:Python CardRequest类的具体用法?Python CardRequest怎么用?Python CardRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CardRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
known_ids = {}
cardtype = AnyCardType()
#times out every 0.5 seconds
cardrequest = CardRequest( timeout=0.5, cardType=cardtype )
while True:
try:
# try to connect to a card, if the process
# times out, continue
cardservice = cardrequest.waitforcard()
cardservice.connection.connect()
# compare ATRs
if ATR == cardservice.connection.getATR():
response, sw1, sw2 = \
cardservice.connection.transmit( APDU )
tagid = toHexString(response).replace(' ','')
if tagid in known_ids:
print "found uid"
print tagid
else:
known_ids[tagid] = True
print "new uid"
print tagid
# do appropriate things
post_to_server(tagid)
play_sound()
except:
continue
开发者ID:tcclevela,项目名称:Squirrel2.0,代码行数:28,代码来源:squirrel_card_reader.py
示例2: __init__
def __init__(self):
cardtype = AnyCardType()
self.resetCmd = [0x0, 0xA4, 0x4, 0x0, 0x8, 0xA0, 0x0, 0x0, 0x0, 0x54, 0x48, 0x0, 0x1]
self.resetCmd1 = [0x0, 0xC0, 0x0, 0x0, 0xA]
self.citizenCmd = [0x80, 0xB0, 0x0, 0x4, 0x2, 0x0, 0xD]
self.citizenResponse = [0x0, 0xC0, 0x0, 0x0, 0xD]
try:
# request card insertion
cardrequest = CardRequest(timeout=5, cardType=cardtype)
self.cardservice = cardrequest.waitforcard()
# attach the console tracer
# observer = ConsoleCardConnectionObserver()
# self.cardservice.connection.addObserver(observer)
# connect to the card and perform a few transmits
self.cardservice.connection.connect()
except CardRequestTimeoutException:
print 'time-out: no card inserted during last 5s'
except:
import sys
print sys.exc_info()[1]
开发者ID:wingkopu,项目名称:Project,代码行数:25,代码来源:readthaiid.py
示例3: testcase_CardRequestNewCardInReaderNotPresentInfiniteTimeOut
def testcase_CardRequestNewCardInReaderNotPresentInfiniteTimeOut(self):
"""Test smartcard.CardRequest for any new card in a specific
reader not present without time-out."""
print 'please remove a smart card reader'
_readerz = readers()
while True:
readerz = readers()
if len(_readerz) > len(readerz):
break
time.sleep(.1)
for reader in readerz:
_readerz.remove(reader)
cardtype = AnyCardType()
cardrequest = CardRequest(
timeout=None,
readers=[_readerz[0]],
cardType=cardtype,
newcardonly=True)
print 'Re-insert reader ', _readerz[0], 'with a card inside'
cardservice = cardrequest.waitforcard()
cardservice.connection.connect()
print toHexString(
cardservice.connection.getATR()), \
'in', cardservice.connection.getReader()
cardservice.connection.disconnect()
开发者ID:317070,项目名称:drapri,代码行数:28,代码来源:testcase_manualCardRequest.py
示例4: getATR
def getATR(self):
cardtype = AnyCardType()
cardrequest = CardRequest(timeout=1, cardType=cardtype)
cardservice = cardrequest.waitforcard()
cardservice.connection.connect()
return toHexString(cardservice.connection.getATR())
开发者ID:tgie,项目名称:epassportviewer,代码行数:7,代码来源:fingerPrint.py
示例5: __init__
def __init__(self, threadindex):
'''Connect to a card with an ExclusiveTransmitCardConnection.'''
threading.Thread.__init__(self)
self.threadindex = threadindex
# request any card type
cardtype = AnyCardType()
cardrequest = CardRequest(timeout=5, cardType=cardtype)
cardservice = cardrequest.waitforcard()
# attach our decorator
cardservice.connection = ExclusiveTransmitCardConnection(cardservice.connection)
# uncomment to attach the console tracer
#observer=ConsoleCardConnectionObserver()
#cardservice.connection.addObserver(observer)
# connect to the card
cardservice.connection.connect()
self.cardservice = cardservice
# this event will signal the end of the thread
self.evtStop = threading.Event()
# this timer will set the event stop event in 30s
timer = threading.Timer(30, signalEvent, [self.evtStop])
timer.start()
self.countTransmitted = 0
开发者ID:12019,项目名称:pyscard,代码行数:30,代码来源:testcase_ExclusiveCardConnection.py
示例6: getATR
def getATR(self):
cardtype = AnyCardType()
cardrequest = CardRequest(timeout=1, cardType=cardtype)
cardservice = cardrequest.waitforcard()
cardservice.connection.connect()
atr = toHexString(cardservice.connection.getATR())
self.writeToLog("ATR: {0}".format(atr))
开发者ID:akpotter,项目名称:epassportviewer,代码行数:8,代码来源:custom.py
示例7: removeAllCards
def removeAllCards(self):
print 'please remove all inserted smart cards'
cardrequest = CardRequest()
while True:
cards = cardrequest.waitforcardevent()
if 0 == len(cards):
break
time.sleep(.3)
print 'ok'
开发者ID:317070,项目名称:drapri,代码行数:9,代码来源:testcase_manualCardRequest.py
示例8: __init__
def __init__(self):
cardtype = AnyCardType()
cardrequest = CardRequest(timeout=10, cardType=cardtype)
self.card = cardrequest.waitforcard()
self.card.connection.connect()
self.ins_db = []
self.ins_db_update(INS_DB)
self.log = []
self.auto_get_response = True
开发者ID:PhoenixBaymax,项目名称:emv-framework,代码行数:10,代码来源:iso7816.py
示例9: __init__
def __init__(self, add_a_byte, pinmin, pinmax, fixed):
cardtype = AnyCardType()
cardrequest = CardRequest(timeout=10, cardType=cardtype)
cardservice = cardrequest.waitforcard()
self.connection = cardservice.connection
self.verify_ioctl = -1
self.modify_ioctl = -1
self.another_byte = add_a_byte
self.pinmin = pinmin
self.pinmax = pinmax
self.fixed = fixed
开发者ID:ggkitsas,项目名称:gnuk,代码行数:11,代码来源:pinpadtest.py
示例10: testcase_CardRequestAnyCardTypeInSelectedReader
def testcase_CardRequestAnyCardTypeInSelectedReader(self):
"""Test smartcard.AnyCardType."""
for reader in expectedReaders:
atr = expectedATRinReader[reader]
if [] != atr:
ct = AnyCardType()
cr = CardRequest(timeout=10.6, readers=[reader], cardType=ct)
cs = cr.waitforcard()
cs.connection.connect()
self.assertEquals(atr, cs.connection.getATR())
self.assertEquals(cs.connection.getReader(), expectedReaderForATR[toHexString(atr)])
开发者ID:12019,项目名称:pyscard,代码行数:12,代码来源:testcase_CardRequest.py
示例11: testcase_CardRequestATRCardType
def testcase_CardRequestATRCardType(self):
"""Test smartcard.AnyCardType."""
for atr in expectedATRs:
if [] != atr:
ct = ATRCardType(atr)
cr = CardRequest(timeout=10, cardType=ct)
cs = cr.waitforcard()
cs.connection.connect()
self.assertEquals(atr, cs.connection.getATR())
self.assertEquals(cs.connection.getReader(), expectedReaderForATR[toHexString(atr)])
cs.connection.disconnect()
开发者ID:12019,项目名称:pyscard,代码行数:12,代码来源:testcase_CardRequest.py
示例12: run
def run():
global cardservice
try:
cardtype = AnyCardType()
cardreq = CardRequest(timeout=30,cardType=cardtype)
cardservice = cardreq.waitforcard()
cardservice.connection.setErrorCheckingChain(errorchain)
cardservice.connection.connect()
print "ATR = ", toHexString(cardservice.connection.getATR())
except SWException, e:
print str(e)
return False
开发者ID:12019,项目名称:pintar-os-framework,代码行数:12,代码来源:reader.py
示例13: receiveCard
def receiveCard():
cardtype = AnyCardType()
cardrequest = CardRequest(timeout = 120, cardType = cardtype)
while (1):
try:
cardservice = cardrequest.waitforcard()
except CardRequestTimeoutException:
continue
return cardservice.connection
开发者ID:PhoenixBaymax,项目名称:EMVConsole,代码行数:13,代码来源:connect.py
示例14: testcase_CardRequestAnyCardTypeAnyReaderPassThru
def testcase_CardRequestAnyCardTypeAnyReaderPassThru(self):
"""Test smartcard.AnyCardType."""
for reader in expectedReaders:
atr = expectedATRinReader[reader]
if [] != atr:
ct = AnyCardType()
cardservice = smartcard.PassThruCardService.PassThruCardService
cr = CardRequest(timeout=10.6, readers=[reader], cardType=ct, cardServiceClass=cardservice)
cs = cr.waitforcard()
cs.connection.connect()
self.assertEquals(cs.__class__, smartcard.PassThruCardService.PassThruCardService)
self.assertEquals(atr, cs.connection.getATR())
self.assertEquals(cs.connection.getReader(), expectedReaderForATR[toHexString(atr)])
开发者ID:12019,项目名称:pyscard,代码行数:14,代码来源:testcase_CardRequest.py
示例15: sc_connect
def sc_connect():
global cardservice
# detect the smart card based on the content of the ATR (card-centric approach)
print('Initializing card connection...')
try:
cardtype = ATRCardType( toBytes( "3B 90 11 00" ) )
cardrequest = CardRequest( timeout=5, cardType=cardtype )
cardservice = cardrequest.waitforcard()
print('Card connection established correctly')
except:
print('ERROR: Timeout exceeded')
sys.exit(0)
# connect to the card using T0 protocol.
cardservice.connection.connect( CardConnection.T0_protocol )
开发者ID:356255531,项目名称:cryptography,代码行数:14,代码来源:trace_measurement_v2.py
示例16: __CardMonitoringThreadSingleton
class __CardMonitoringThreadSingleton(Thread):
"""The real card monitoring thread class.
A single instance of this class is created
by the public CardMonitoringThread class.
"""
def __init__(self, observable):
Thread.__init__(self)
self.observable = observable
self.stopEvent = Event()
self.stopEvent.clear()
self.cards = []
self.setDaemon(True)
# the actual monitoring thread
def run(self):
"""Runs until stopEvent is notified, and notify
observers of all card insertion/removal.
"""
self.cardrequest = CardRequest(timeout=0.1)
while self.stopEvent.isSet() != 1:
try:
currentcards = self.cardrequest.waitforcardevent()
addedcards = []
for card in currentcards:
if not self.cards.__contains__(card):
addedcards.append(card)
removedcards = []
for card in self.cards:
if not currentcards.__contains__(card):
removedcards.append(card)
if addedcards != [] or removedcards != []:
self.cards = currentcards
self.observable.setChanged()
self.observable.notifyObservers(
(addedcards, removedcards))
# when CardMonitoringThread.__del__() is invoked in
# response to shutdown, e.g., when execution of the
# program is done, other globals referenced by the
# __del__() method may already have been deleted.
# this causes ReaderMonitoringThread.run() to except
# with a TypeError or AttributeError
except TypeError:
pass
except AttributeError:
pass
except:
# FIXME Tighten the exceptions caught by this block
traceback.print_exc()
# stop the thread by signaling stopEvent
def stop(self):
self.stopEvent.set()
开发者ID:AnnePieter,项目名称:P4Pkoffiekaart,代码行数:59,代码来源:CardMonitoring.py
示例17: testcase_CardRequestNewCardAnyCardTypeInfiniteTimeOut
def testcase_CardRequestNewCardAnyCardTypeInfiniteTimeOut(self):
"""Test smartcard.CardRequest for any new card without time-out."""
self.removeAllCards()
cardtype = AnyCardType()
cardrequest = CardRequest(timeout=None, cardType=cardtype, newcardonly=True)
print("re-insert any combination of cards six time")
count = 0
for i in range(0, 6):
cardservice = cardrequest.waitforcard()
try:
cardservice.connection.connect()
print(toHexString(cardservice.connection.getATR()), "in", cardservice.connection.getReader())
except CardConnectionException:
# card was removed too fast
pass
cardservice.connection.disconnect()
count += 1
self.assertEqual(6, count)
开发者ID:shoaly,项目名称:pyscard,代码行数:19,代码来源:testcase_manualCardRequest.py
示例18: testcase_CardRequestNewCardAnyCardTypeFiniteTimeOutNoInsertion
def testcase_CardRequestNewCardAnyCardTypeFiniteTimeOutNoInsertion(self):
"""Test smartcard.CardRequest for new card with time-out and no
insertion before time-out."""
self.removeAllCards()
# make sure we have 6 time-outs
cardtype = AnyCardType()
cardrequest = CardRequest(
timeout=1, cardType=cardtype, newcardonly=True)
count = 0
for i in range(0, 6):
try:
before = time.time()
cardservice = cardrequest.waitforcard()
except CardRequestTimeoutException, e:
elapsed = int(10 * (time.time() - before))
print '.',
self.assert_(elapsed >= 10 and elapsed <= 11.)
count += 1
开发者ID:317070,项目名称:drapri,代码行数:20,代码来源:testcase_manualCardRequest.py
示例19: update
def update(self, observable, actions):
(addedcards, removedcards) = actions
for card in addedcards:
try:
cardType = ATRCardType( toBytes( "%s" %toHexString(card.atr) ))
cardRequest = CardRequest(timeout = 1, cardType = cardType)
cardService = cardRequest.waitforcard()
cardService.connection.connect()
SELECT = [0xFF, 0xCA, 0x00, 0x00, 0x00]
apdu = SELECT
#print ("sending" + toHexString(apdu))
response, sw1, sw2 = cardService.connection.transmit( apdu )
#print ('response: ', response, ' status words: ', "%x %x" % (sw1, sw2))
hexUID = self.getParseHexUID(response)
#print (hexUID)
self.process(hexUID)
# id = tagid
# print ("UID is",id)
except Exception as e:
print (e)
开发者ID:chaycv,项目名称:reader-unican,代码行数:20,代码来源:NFCReader.py
示例20: testcase_CardRequestNewCardAnyCardTypeFiniteTimeOutInsertion
def testcase_CardRequestNewCardAnyCardTypeFiniteTimeOutInsertion(self):
"""Test smartcard.CardRequest for new card with time-out and
insertion before time-out."""
self.removeAllCards()
# make sure insertion is within 5s
cardtype = AnyCardType()
cardrequest = CardRequest(
timeout=5, cardType=cardtype, newcardonly=True)
count = 0
for i in range(0, 6):
try:
print 're-insert any card within the next 5 seconds'
before = time.time()
cardservice = cardrequest.waitforcard()
count += 1
elapsed = int(10 * (time.time() - before))
self.assert_(elapsed <= 55.)
except CardRequestTimeoutException, e:
print 'too slow... Test will show a failure'
开发者ID:317070,项目名称:drapri,代码行数:21,代码来源:testcase_manualCardRequest.py
注:本文中的smartcard.CardRequest.CardRequest类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论