本文整理汇总了Python中smartcard.System.readers函数的典型用法代码示例。如果您正苦于以下问题:Python readers函数的具体用法?Python readers怎么用?Python readers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readers函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: checklocalconfig
def checklocalconfig():
try:
f = open('local_config.py', 'r')
except IOError:
print 'local_config.py not found; generating local_config.py...'
# generate local configuration
f = open('local_config.py', 'w+')
f.write('from smartcard.util import toHexString\n')
f.write('expectedReaders = ')
f.write(str(readers()) + '\n')
expectedATRs = []
for reader in readers():
try:
expectedATRs.append(getATR(reader))
except NoCardException:
expectedATRs.append([])
f.write('expectedATRs = ')
#for atr in expectedATRs: print `toHexString(atr)`
f.write(`expectedATRs` + '\n')
f.write('expectedATRinReader = {}\n')
f.write('for i in xrange(len(expectedReaders)):\n')
f.write(' expectedATRinReader[expectedReaders[i]] = expectedATRs[i]\n')
f.write('expectedReaderForATR = {}\n')
f.write('for i in xrange(len(expectedReaders)):\n')
f.write(' expectedReaderForATR[toHexString(expectedATRs[i])] = expectedReaders[i]\n')
f.write('expectedReaderGroups = [\'SCard$DefaultReaders\']\n')
f.close()
开发者ID:12019,项目名称:pyscard,代码行数:33,代码来源:configcheck.py
示例2: main
def main():
""" main """
card_connection = readers()[0].createConnection()
card_connection.connect(mode=SCARD_SHARE_DIRECT,
disposition=SCARD_LEAVE_CARD)
feature_list = getFeatureRequest(card_connection)
get_tlv_properties = hasFeature(feature_list, FEATURE_GET_TLV_PROPERTIES)
if get_tlv_properties:
tlv = getTlvProperties(card_connection)
print "Reader: ", readers()[0]
print "IdVendor: 0x%04X" % tlv['PCSCv2_PART10_PROPERTY_wIdVendor']
print "IdProduct: 0x%04X" % tlv['PCSCv2_PART10_PROPERTY_wIdProduct']
ccid_esc_command = hasFeature(feature_list, FEATURE_CCID_ESC_COMMAND)
if ccid_esc_command is None:
raise Exception("FEATURE_CCID_ESC_COMMAND is not supported or allowed")
# Proprietary command for Gemalto readers
# This is implemented by the Gemalto Pinpad v2 and C200 readers
firmware_features = [0x6A]
try:
res = card_connection.control(ccid_esc_command, firmware_features)
except SmartcardException, ex:
print "Failed:", ex
return
开发者ID:FeitianSmartcardReader,项目名称:PCSC,代码行数:27,代码来源:FEATURE_CCID_ESC_COMMAND_Gemalto_features.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: __init__
def __init__(self, readerName=None, cardServiceClass=None):
"""Session constructor. Initializes a smart card session and
connect to the card.
@param readerName: reader to connect to; default is first PCSC reader
@param cardServiceClass: card service to bind the session to; default
is None
"""
# if reader name not given, select first reader
if readerName is None:
if len(readers()) > 0:
self.reader = readers()[0]
self.readerName = repr(self.reader)
else:
raise NoReadersException()
# otherwise select reader from name
else:
self.readerName = readerName
for reader in readers():
if readerName == str(reader):
self.reader = reader
self.readerName = repr(self.reader)
try:
self.reader
except AttributeError:
raise InvalidReaderException(self.readerName)
# open card connection and bind PassThruCardService
cc = self.reader.createConnection()
self.cs = PassThruCardService(cc)
self.cs.connection.connect()
开发者ID:LudovicRousseau,项目名称:pyscard,代码行数:34,代码来源:Session.py
示例5: testcase_Card_Eq_NotEq
def testcase_Card_Eq_NotEq(self):
"""Test == and != for Cards."""
for reader in readers():
card = Card(str(reader), expectedATRinReader[str(reader)])
cardcopy = Card(str(reader), expectedATRinReader[str(reader)])
self.assertEqual(True, card == cardcopy)
self.assertEqual(True, not card != cardcopy)
for reader in readers():
card = Card(str(reader), expectedATRinReader[str(reader)])
cardcopy = Card(str(reader), [0, 0])
self.assertEqual(True, card != cardcopy)
self.assertEqual(True, not card == cardcopy)
开发者ID:AnnePieter,项目名称:P4Pkoffiekaart,代码行数:13,代码来源:testcase_Card.py
示例6: testcase_readers_in_readergroup_nonexistent
def testcase_readers_in_readergroup_nonexistent(self):
foundreaders = {}
for reader in readers(['dummy$group']):
foundreaders[reader] = 1
for reader in expectedReaders:
self.assert_(not reader in foundreaders)
self.assertEquals(0, len(foundreaders))
开发者ID:317070,项目名称:drapri,代码行数:7,代码来源:testcase_readers.py
示例7: main
def main():
""" Ask the first reader/driver to return its Vendor Name if any """
card_connection = readers()[0].createConnection()
card_connection.connect(mode=SCARD_SHARE_DIRECT,
disposition=SCARD_LEAVE_CARD)
try:
# Vendor name
name = card_connection.getAttrib(SCARD_ATTR_VENDOR_NAME)
print(''.join([chr(char) for char in name]))
# Vendor-supplied interface device version (DWORD in the form
# 0xMMmmbbbb where MM = major version, mm = minor version, and
# bbbb = build number).
version = card_connection.getAttrib(SCARD_ATTR_VENDOR_IFD_VERSION)
print("Version: %d.%d.%d" % (version[3], version[2],
version[0]))
# Vendor-supplied interface device serial number.
# only for readers with a USB serial number
serial = card_connection.getAttrib(SCARD_ATTR_VENDOR_IFD_SERIAL_NO)
print(serial)
# Reader's display name
# only with pcsc-lite version >= 1.6.0
name = card_connection.getAttrib(SCARD_ATTR_DEVICE_FRIENDLY_NAME)
print(''.join([chr(char) for char in name]))
except smartcard.Exceptions.SmartcardException, message:
print("Exception:", message)
开发者ID:LudovicRousseau,项目名称:PCSC,代码行数:30,代码来源:getAttrib.py
示例8: setUp
def setUp(self):
r = readers()
self.max = maxim.MaximAPI(r[0])
self.max.Connect()
self.CardInterfaces = [1,2]
self.UnknownInterfaces = [3, 7]
self.timeout = 0b10000111
开发者ID:dudemcbacon,项目名称:MaximAPI,代码行数:7,代码来源:test.py
示例9: open_key_multiple_readers
def open_key_multiple_readers(name=None):
"""
Opens a smartcard reader matching the given name and connects to the
ykneo-oath applet through it.
Returns a reference to the YkneoYubiOath object.
"""
for reader in readers():
print "list of readers"
print readers
try:
conn = reader.createConnection()
conn.connect()
data, status = _cmd2(conn, 0, 0xa4, 0x04, 0x00, 'a0000005272101'.decode('hex'))
if (status) != 0x9000:
print "unable to select the applet on reader %s" % reader
else:
print "using reader"
print reader
return YkneoYubiOath(conn)
except Exception, e:
print "WARNING: %s" % e
print "i am in the except of multiple readers"
开发者ID:DarkDimius,项目名称:yubioath-desktop,代码行数:26,代码来源:libykneo.py
示例10: switch_interface
def switch_interface(interface):
"""
switch from contact to contactless (or reverse) on a GemProx DU reader
"""
for reader in readers():
cardConnection = reader.createConnection()
cardConnection.connect(mode=SCARD_SHARE_DIRECT, disposition=SCARD_LEAVE_CARD)
switch_interface_cmd = [0x52, 0xF8, 0x04, 0x01, 0x00, interface]
print("Reader:", reader, "=>", end=' ')
try:
res = cardConnection.control(IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE,
switch_interface_cmd)
except:
print("FAILED")
else:
if res != [0, 0, 0, 0]:
print("Failed: ", end='')
err = res[0] * 256 + res[1]
if err == 0xFF83:
print("Wrong data parameters")
elif err == 0xFF84:
print("Wrong command bytes")
else:
print("Unknown error:", [hex(x) for x in res])
else:
print("Success")
开发者ID:LudovicRousseau,项目名称:PCSC,代码行数:27,代码来源:control_switch_interface.py
示例11: setup
def setup(readernumber):
"""Open up a connection to the specified reader via PCSC
"""
r = readers()
connection = r[readernumber].createConnection()
connection.connect()
return connection
开发者ID:12019,项目名称:vsmartcard,代码行数:8,代码来源:picc.py
示例12: print_welcome
def print_welcome():
print "Welcome to sandwich-manager beta release."
r = readers()
if len(r) < 1:
print "Warning: no reader available"
else:
print "Reader: " + str(r[0])
print "Type 'help' or 'h' for help."
开发者ID:nimai,项目名称:Project-BITCH,代码行数:8,代码来源:main.py
示例13: __init__
def __init__(self, dbus_server):
self.dbus_server = dbus_server
r = readers()
self.ttag = r[r.index('ACS ACR 38U-CCID 00 00')].createConnection()
self.ttag.connect()
#set retry time to 1
RTO = get_set_retry_time_to_one()
data, sw1, sw2 = self.ttag.transmit( RTO )
开发者ID:maethorechannen,项目名称:arphidtools,代码行数:8,代码来源:arphidd.py
示例14: testcase_CardDictionary
def testcase_CardDictionary(self):
"""Create a dictionnary with Card keys"""
mydict = {}
for reader in readers():
card = Card(reader, expectedATRinReader[str(reader)])
mydict[card] = reader
for card in list(mydict.keys()):
self.assertTrue(str(card.reader) in expectedReaders)
开发者ID:AnnePieter,项目名称:P4Pkoffiekaart,代码行数:9,代码来源:testcase_Card.py
示例15: getAttribute
def getAttribute():
r=readers()
connection = r[0].createConnection()
connection.connect()
GETATTR = [0x80, 0x2B, 0x00, 0x00]
data, sw1, sw2 = connection.transmit( GETATTR )
return (data, sw1, sw2)
开发者ID:adelapie,项目名称:irma_phase_2,代码行数:9,代码来源:management.py
示例16: __init__
def __init__(self):
reader = readers()
print(reader)
if not reader:
print("Reader NOT CONNECTED")
print("Connect reader please, and try again")
Read.exit_app()
else:
print("Приложите карту ")
app_init()
开发者ID:BestLine,项目名称:CardReaderLocal,代码行数:10,代码来源:Main.py
示例17: get_status
def get_status(self):
cards = 0
for reader in readers():
try:
connection = reader.createConnection()
connection.connect()
cards = cards + 1
except NoCardException: pass
self.cards = cards
return (self.cards > 0)
开发者ID:jeffmelville,项目名称:badger,代码行数:10,代码来源:SmartCardMonitor.py
示例18: testcase_ATRCardTypeWithoutMask
def testcase_ATRCardTypeWithoutMask(self):
"""Test smartcard.ATRCardType without mask."""
for reader in readers():
if [] != expectedATRinReader[str(reader)]:
ct = ATRCardType(expectedATRinReader[str(reader)])
connection = reader.createConnection()
connection.connect()
self.assertEquals(True, ct.matches(connection.getATR()))
self.assertEquals(True, ct.matches(connection.getATR(), reader))
connection.disconnect()
开发者ID:12019,项目名称:pyscard,代码行数:11,代码来源:testcase_CardType.py
示例19: testcase_AnyCardType
def testcase_AnyCardType(self):
"""Test smartcard.AnyCardType."""
ct = AnyCardType()
for reader in readers():
if [] != expectedATRinReader[str(reader)]:
connection = reader.createConnection()
connection.connect()
self.assertEquals(True, ct.matches(connection.getATR()))
self.assertEquals(True, ct.matches(connection.getATR(), reader))
connection.disconnect()
开发者ID:12019,项目名称:pyscard,代码行数:11,代码来源:testcase_CardType.py
示例20: check_reader_availability
def check_reader_availability():
global connection
r = readers()
if len(r) < 1:
print "Warning: no reader available"
else:
#from smartcard.CardConnectionObserver import ConsoleCardConnectionObserver
#observer = ConsoleCardConnectionObserver()
connection = r[0].createConnection()
#connection.addObserver(observer)
connection.connect()
开发者ID:nimai,项目名称:Project-BITCH,代码行数:11,代码来源:main.py
注:本文中的smartcard.System.readers函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论