本文整理汇总了Python中smartcard.Observer.Observable类的典型用法代码示例。如果您正苦于以下问题:Python Observable类的具体用法?Python Observable怎么用?Python Observable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Observable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: addObserver
def addObserver(self, observer):
"""Add an observer."""
Observable.addObserver(self, observer)
# If self.startOnDemand is True, the reader monitoring
# thread only runs when there are observers.
if self.startOnDemand:
if 0 < self.countObservers():
if not self.rmthread:
self.rmthread = ReaderMonitoringThread(self,
self.readerProc, self.period)
# start reader monitoring thread in another thread to
# avoid a deadlock; addObserver and notifyObservers called
# in the ReaderMonitoringThread run() method are
# synchronized
try:
# Python 3.x
import _thread
_thread.start_new_thread(self.rmthread.start, ())
except:
# Python 2.x
import thread
thread.start_new_thread(self.rmthread.start, ())
else:
observer.update(self, (self.rmthread.readers, []))
开发者ID:AnnePieter,项目名称:P4Pkoffiekaart,代码行数:26,代码来源:ReaderMonitoring.py
示例2: deleteObserver
def deleteObserver(self, observer):
"""Remove an observer."""
Observable.deleteObserver(self, observer)
# If self.startOnDemand is True, the reader monitoring
# thread is stopped when there are no more observers.
if self.startOnDemand:
if 0 == self.countObservers():
self.rmthread.stop()
del self.rmthread
self.rmthread = None
开发者ID:AnnePieter,项目名称:P4Pkoffiekaart,代码行数:10,代码来源:ReaderMonitoring.py
示例3: connect
def connect(self, protocol=None, mode=None, disposition=None):
"""Connect to card.
protocol: a bit mask of the protocols to use, from
CardConnection.T0_protocol, CardConnection.T1_protocol,
CardConnection.RAW_protocol, CardConnection.T15_protocol
mode: passed as-is to the PC/SC layer
"""
Observable.setChanged(self)
Observable.notifyObservers(self, CardConnectionEvent('connect'))
开发者ID:12019,项目名称:pyscard,代码行数:10,代码来源:CardConnection.py
示例4: __init__
def __init__(self, reader):
"""Construct a new card connection.
readerName: name of the reader in which the smartcard to connect
to is located.
"""
Observable.__init__(self)
self.reader = reader
self.errorcheckingchain = None
self.defaultprotocol = CardConnection.T0_protocol | CardConnection.T1_protocol
开发者ID:12019,项目名称:pyscard,代码行数:10,代码来源:CardConnection.py
示例5: deleteObserver
def deleteObserver(self, observer):
"""Remove an observer.
We delete the CardMonitoringThread reference when there
are no more observers.
"""
Observable.deleteObserver(self, observer)
if _START_ON_DEMAND_:
if self.countObservers() == 0:
if self.rmthread != None:
self.rmthread = None
开发者ID:AnnePieter,项目名称:P4Pkoffiekaart,代码行数:11,代码来源:CardMonitoring.py
示例6: __init__
def __init__(self, startOnDemand=True, readerProc=smartcard.System.readers, period=1):
self.__dict__ = self.__shared_state
Observable.__init__(self)
self.startOnDemand = startOnDemand
self.readerProc = readerProc
self.period = period
if self.startOnDemand:
self.rmthread = None
else:
self.rmthread = ReaderMonitoringThread(self, self.readerProc, self.period)
self.rmthread.start()
开发者ID:daniel-hartmann,项目名称:pyscard,代码行数:11,代码来源:ReaderMonitoring.py
示例7: addObserver
def addObserver(self, observer):
"""Add an observer.
We only start the card monitoring thread when
there are observers.
"""
Observable.addObserver(self, observer)
if _START_ON_DEMAND_:
if self.countObservers() > 0 and self.rmthread is None:
self.rmthread = CardMonitoringThread(self)
else:
observer.update(self, (self.rmthread.cards, []))
开发者ID:c0deh4xor,项目名称:pyscard,代码行数:12,代码来源:CardMonitoring.py
示例8: connect
def connect(self, protocol=None, mode=None, disposition=None):
"""Connect to card.
protocol: a bit mask of the protocols to use, from
CardConnection.T0_protocol, CardConnection.T1_protocol,
CardConnection.RAW_protocol, CardConnection.T15_protocol
mode: SCARD_SHARE_SHARED (default), SCARD_SHARE_EXCLUSIVE or
SCARD_SHARE_DIRECT
disposition: SCARD_LEAVE_CARD (default), SCARD_RESET_CARD,
SCARD_UNPOWER_CARD or SCARD_EJECT_CARD
"""
Observable.setChanged(self)
Observable.notifyObservers(self, CardConnectionEvent('connect'))
开发者ID:benmehlman,项目名称:pyscard,代码行数:14,代码来源:CardConnection.py
示例9: getAttrib
def getAttrib(self, attribId):
"""return the requested attribute
attribId: attribute id like SCARD_ATTR_VENDOR_NAME
"""
Observable.setChanged(self)
Observable.notifyObservers(self,
CardConnectionEvent(
'attrib',
[attribId]))
data = self.doGetAttrib(attribId)
if None != self.errorcheckingchain:
self.errorcheckingchain[0](data)
return data
开发者ID:benmehlman,项目名称:pyscard,代码行数:14,代码来源:CardConnection.py
示例10: transmit
def transmit(self, bytes, protocol=None):
"""Transmit an apdu. Internally calls doTransmit() class method
and notify observers upon command/response APDU events.
Subclasses must override the doTransmit() class method.
bytes: list of bytes to transmit
protocol: the transmission protocol, from
CardConnection.T0_protocol,
CardConnection.T1_protocol, or
CardConnection.RAW_protocol
"""
Observable.setChanged(self)
Observable.notifyObservers(self,
CardConnectionEvent(
'command',
[bytes, protocol]))
data, sw1, sw2 = self.doTransmit(bytes, protocol)
Observable.setChanged(self)
Observable.notifyObservers(self,
CardConnectionEvent(
'response',
[data, sw1, sw2]))
if None != self.errorcheckingchain:
self.errorcheckingchain[0](data, sw1, sw2)
return data, sw1, sw2
开发者ID:benmehlman,项目名称:pyscard,代码行数:26,代码来源:CardConnection.py
示例11: control
def control(self, controlCode, bytes=[]):
"""Send a control command and buffer. Internally calls doControl()
class method and notify observers upon command/response events.
Subclasses must override the doControl() class method.
controlCode: command code
bytes: list of bytes to transmit
"""
Observable.setChanged(self)
Observable.notifyObservers(self, CardConnectionEvent('command', [controlCode, bytes]))
data = self.doControl(controlCode, bytes)
Observable.setChanged(self)
Observable.notifyObservers(self, CardConnectionEvent('response', data))
if None != self.errorcheckingchain:
self.errorcheckingchain[0](data)
return data
开发者ID:12019,项目名称:pyscard,代码行数:17,代码来源:CardConnection.py
示例12: disconnect
def disconnect(self):
"""Disconnect from card."""
Observable.setChanged(self)
Observable.notifyObservers(self, CardConnectionEvent('disconnect'))
开发者ID:benmehlman,项目名称:pyscard,代码行数:4,代码来源:CardConnection.py
示例13: deleteObserver
def deleteObserver(self, observer):
"""Remove a CardConnection observer."""
Observable.deleteObserver(self, observer)
开发者ID:benmehlman,项目名称:pyscard,代码行数:3,代码来源:CardConnection.py
示例14: addObserver
def addObserver(self, observer):
"""Add a CardConnection observer."""
Observable.addObserver(self, observer)
开发者ID:benmehlman,项目名称:pyscard,代码行数:3,代码来源:CardConnection.py
示例15: __init__
def __init__(self):
Observable.__init__(self)
if _START_ON_DEMAND_:
self.rmthread = None
else:
self.rmthread = CardMonitoringThread(self)
开发者ID:c0deh4xor,项目名称:pyscard,代码行数:6,代码来源:CardMonitoring.py
注:本文中的smartcard.Observer.Observable类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论