• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python CardMonitoring.CardMonitor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中smartcard.CardMonitoring.CardMonitor的典型用法代码示例。如果您正苦于以下问题:Python CardMonitor类的具体用法?Python CardMonitor怎么用?Python CardMonitor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了CardMonitor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: smartcardBridge

class smartcardBridge():

    cardmonitor = None
    cardobserver = None

    """
        MainClass for the smartcardBride
    """
    def __init__(self, args):
        # feedbackHandler.setup()

        self.cardmonitor = CardMonitor()
        self.cardobserver = cardReader(args)

        self.addCardObserver(self.cardobserver)

    def shutdown(self):
        print "Shutdown"
        self.removeCardObserver(self.cardobserver)
        # feedbackHandler.shutdown()

    def addCardObserver(self, observer):
        self.cardmonitor.addObserver(observer)

    def removeCardObserver(self, observer):
        self.cardmonitor.deleteObserver(observer)
开发者ID:Uepsilon,项目名称:smartcard-browser-bridge,代码行数:26,代码来源:smartcardBridge.py


示例2: APDUShell

class APDUShell(cmd.Cmd):
    """Command shell to communicate with smartcard via APDU.

    Reader selection will be performed on shell start.
    Prompt will contain a selected reader's name and FID of latest selected EF or DF.
    Response data and SW for each APDU will be printed in console.
    """

    def __init__(self, *args, **kwargs):
        # base classes are old style classes so super() not allowed here
        cmd.Cmd.__init__(self, *args, **kwargs)

        self.reader = select_reader()
        self.card = None
        self.connection = None
        self.sel_obj = ''
        self.card_monitor = CardMonitor()
        self.card_monitor.addObserver(self)

    def _card_observer_update(self, observable, (addedcards, removedcards)):
        """CardObserver interface implementation"""

        if self.card and self.card in removedcards:
            self.sel_obj = ''
            self.card = None
            self.connection = None

        for card in addedcards:
            if card.reader == self.reader:
                self.card = card
                self._set_up_connection()
                break
开发者ID:12019,项目名称:python-apducmd,代码行数:32,代码来源:apducmd.py


示例3: triggered_decorator

def triggered_decorator(func):
    # print("Starting observation of reader %s" % func.__defaults__[0])
    class SimpleObserver(CardObserver):
        reader = func.__defaults__[0]
        def update(self, observable, actions):
            added_cards, removed_cards = actions

            # all readers involved in actions
            action_readers = [c.reader for c in added_cards] + [c.reader for c in removed_cards]

            # if the one we observe is not the list, we return None
            if not self.reader in action_readers:
                return None

            # card added
            if len(added_cards):
                for c in added_cards:
                    if c.reader == self.reader:
                        return func(action="inserted", card=c, reader=self.reader)

            # card removed
            if len(removed_cards):
                for c in removed_cards:
                    if c.reader == self.reader:
                        return func(action="removed", card=c, reader=self.reader)
            return None
    # installing observer
    cm = CardMonitor()
    so = SimpleObserver()
    cm.addObserver(so)
    return so.update
开发者ID:Lapin-Blanc,项目名称:pidoor,代码行数:31,代码来源:beid.py


示例4: main

def main():
    print "Insert or remove a smartcard in the system."
    print "This program will exit in 10 seconds"
    print ""
    cardmonitor = CardMonitor()
    cardobserver = printobserver()
    cardmonitor.addObserver( cardobserver )
开发者ID:HeesangLee,项目名称:nfcPython,代码行数:7,代码来源:nfcTest.py


示例5: SmartCardMonitor

class SmartCardMonitor(CardObserver):
    def __init__ (self, dispatcher): 
        self.cards = 0
        self.dispatcher = dispatcher
        self.dispatcher.update_inserted(self.get_status(), initial=True)

    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)


    def monitor (self): 
        self.cardmonitor = CardMonitor()
        self.cardmonitor.addObserver(self)

    def shutdown (self): 
        self.cardmonitor.deleteObserver(self)

    def update (self, observable, (addedcards, removedcards)):
        #update the number of cards currently inserted in the system
        self.cards = self.cards + len(addedcards) - len(removedcards)
        if self.cards > 0: 
            self.dispatcher.update_inserted(True)
        else:
            self.dispatcher.update_inserted(False)
开发者ID:jeffmelville,项目名称:badger,代码行数:32,代码来源:SmartCardMonitor.py


示例6: CardManager

class CardManager(CardObserver):
    """A simple card observer that is notified
    when cards are inserted/removed from the system and
    prints the list of cards
    """

    def __init__(self, card_list_env, auto_connect_env):
        self.cardmonitor = CardMonitor()
        self.card_list_env = card_list_env
        self.auto_connect_env = auto_connect_env  # TODO
        # self.enable = True
        # self.card_list = []
        self.cardmonitor.addObserver(self)
        # self.autocon = False

    def update(self, observable, xxx_todo_changeme):
        # FIXME should raise an event and no more (WAIT FOR EVENT MANAGER)
        #    the business should not occured here (because of lock, etc..)

        (addedcards, removedcards) = xxx_todo_changeme
        r = ""  # card connected or removed
        # ac = "" #autoconnect result
        if addedcards is not None and len(addedcards) > 0:
            r += "Added card(s) " + str(addedcards)

            # TODO should be in critical section
            card_list = self.card_list_env.getValue()[:]

            for c in addedcards:
                card_list.append(c)

            self.card_list_env.setValue(card_list)
            # XXX

            # ac = self.autoConnect()

        if removedcards is not None and len(removedcards) > 0:

            if len(r) > 0:
                r += "\n"

            r += "Removed cards" + str(removedcards)

            # TODO should be in critical section
            card_list = self.card_list_env.getValue()[:]

            for c in removedcards:
                card_list.remove(c)

            self.card_list_env.setValue(card_list)
            # XXX

            # if hasattr(c,'connection'):
            #    disconnectReaderFromCardFun(Executer.envi)
            #    print("WARNING : the card has been removed, the connection "
            #          "is broken")

        if len(r) > 0:
            notice(r)
开发者ID:djoproject,项目名称:RFIDShell,代码行数:59,代码来源:pcsc.py


示例7: __init__

    def __init__(self, parent, appstyle, clientpanel):
        """Constructor. Create a smartcard and reader tree control on the
        left-hand side of the application main frame.
        @param parent: the tree panel parent
        @param appstyle: a combination of the following styles (bitwise or |)
          - TR_SMARTCARD: display a smartcard tree panel
          - TR_READER: display a reader tree panel
          - default is TR_DEFAULT = TR_SMARTCARD
        @param clientpanel: the client panel to notify of smartcard and reader events
        """
        wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS)

        sizer = wx.BoxSizer(wx.VERTICAL)

        # create the smartcard tree
        if appstyle & smartcard.wx.SimpleSCardApp.TR_SMARTCARD:
            self.cardtreectrl = CardTreeCtrl(self, clientpanel=clientpanel)

            # create the smartcard insertion observer
            self.cardtreecardobserver = self._CardObserver(self.cardtreectrl)

            # register as a CardObserver; we will ge
            # notified of added/removed cards
            self.cardmonitor = CardMonitor()
            self.cardmonitor.addObserver(self.cardtreecardobserver)

            sizer.Add(
                self.cardtreectrl, flag=wx.EXPAND | wx.ALL, proportion=1)

        # create the reader tree
        if appstyle & smartcard.wx.SimpleSCardApp.TR_READER:
            self.readertreectrl = ReaderTreeCtrl(
                                        self, clientpanel=clientpanel)

            # create the reader insertion observer
            self.readertreereaderobserver = self._ReaderObserver(
                                                    self.readertreectrl)

            # register as a ReaderObserver; we will ge
            # notified of added/removed readers
            self.readermonitor = ReaderMonitor()
            self.readermonitor.addObserver(self.readertreereaderobserver)

            # create the smartcard insertion observer
            self.readertreecardobserver = self._CardObserver(
                                                self.readertreectrl)

            # register as a CardObserver; we will get
            # notified of added/removed cards
            self.cardmonitor = CardMonitor()
            self.cardmonitor.addObserver(self.readertreecardobserver)

            sizer.Add(
                self.readertreectrl, flag=wx.EXPAND | wx.ALL, proportion=1)

        self.SetSizer(sizer)
        self.SetAutoLayout(True)
开发者ID:LudovicRousseau,项目名称:pyscard,代码行数:57,代码来源:CardAndReaderTreePanel.py


示例8: daemon_body

def daemon_body():
	# The main loop
	try:
		cardmonitor = CardMonitor()
		cardobserver = printobserver()
		cardmonitor.addObserver(cardobserver)

		while True:
			sleep(1000000) # sleep forever

	except:
		cardmonitor.deleteObserver(cardobserver)
开发者ID:giometti,项目名称:beaglebone_home_automation_blueprints,代码行数:12,代码来源:smart_card2twitter.py


示例9: __init__

class ContactPoint:
    """
    ContactPoint is the central class of the application.
    """
    debug = False
    local_config = {}
    listening = False

    def __init__(self):
        '''
        Initialises the debug mode, logger.
        '''
        self.env = environ['CONTACTPOINT_ENV']
        if self.env == 'development':
            self.debug = True
        self.init_emulator()
        self.logger = Logger(self.debug)
        self.logger.log('System started...')
        self.server = Server(self, self.debug)
        self.listen()

    def process(self, action, tag_id=None):
        '''
        The process function is called each time an action happens on the RFID
        reader.
        '''
        response = dict(action=action)
        if tag_id is not None:
            response['tag_id'] = tag_id
        self.logger.debug(response)
        self.server.send_msg('listen_taps', response)

    def init_emulator(self):
        '''
        If the application is running in development mode, the process method is
        aliased as emulate too. This is for nomenclature convenience. This
        function shall be called as emulate, to emulate card taps in development
        mode.
        '''
        if self.debug is True:
            self.emulate = self.process

    def listen(self):
        '''
        The listen function is called during initialisation of the class & the
        application. It initialises the process of starting to listen to card
        taps on the reader.
        '''
        self.monitor = CardMonitor()
        self.observer = Observer(self)
        self.monitor.addObserver(self.observer)
开发者ID:hasgeek,项目名称:contactpoint,代码行数:51,代码来源:__init__.py


示例10: daemon_body

def daemon_body():
        # The main loop
	logging.info("INFO waiting for card... (hit CTRL+C to stop)")

	try:
		cardmonitor = CardMonitor()
		cardobserver = printobserver()
		cardmonitor.addObserver(cardobserver)

		while True:
			sleep(1000000) # sleep forever

	except:
		cardmonitor.deleteObserver(cardobserver)
开发者ID:giometti,项目名称:beaglebone_home_automation_blueprints,代码行数:14,代码来源:smart_card.py


示例11: testthread

    class testthread(Thread):

        def __init__(self, obsindex):
            Thread.__init__(self)
            self.readermonitor = CardMonitor()
            self.obsindex = obsindex
            self.observer = None

        def run(self):
            # create and register observer
            self.observer = printobserver(self.obsindex)
            self.readermonitor.addObserver(self.observer)
            sleep(10)
            self.readermonitor.deleteObserver(self.observer)
开发者ID:317070,项目名称:drapri,代码行数:14,代码来源:CardMonitoring.py


示例12: startLoop

def startLoop():
    now = datetime.datetime.today()
    directory = "%04u-%02u-%02u_%02uh%02um%02us" % (now.year, now.month, now.day, now.hour, now.minute, now.second)
    os.makedirs(directory)
    cardmonitor = CardMonitor()
    cardobserver = observer(directory)
    cardmonitor.addObserver(cardobserver)
    while True:
        try:
            time.sleep(60)
        except:
            break

    cardmonitor.deleteObserver(cardobserver)
开发者ID:Zengwn,项目名称:pssi,代码行数:14,代码来源:loop.py


示例13: testthread

class testthread(threading.Thread):

    def __init__(self, obsindex, testcase):
        threading.Thread.__init__(self)
        self.obsindex = obsindex
        self.testcase = testcase
        self.cardmonitor = CardMonitor()
        self.observer = None

    def run(self):
        # create and register observer
        self.observer = printobserver(self.obsindex, self.testcase)
        self.cardmonitor.addObserver(self.observer)
        time.sleep(1)
        self.cardmonitor.deleteObserver(self.observer)
开发者ID:12019,项目名称:pyscard,代码行数:15,代码来源:testcase_CardMonitor.py


示例14: __init__

 def __init__(self, card_list_env, auto_connect_env):
     self.cardmonitor = CardMonitor()
     self.card_list_env = card_list_env
     self.auto_connect_env = auto_connect_env  # TODO
     # self.enable = True
     # self.card_list = []
     self.cardmonitor.addObserver(self)
开发者ID:djoproject,项目名称:RFIDShell,代码行数:7,代码来源:pcsc.py


示例15: __init__

    def __init__(self, args):
        feedbackHandler.setup()

        self.cardmonitor = CardMonitor()
        self.cardobserver = cardWebconnector(args)

        self.addCardObserver(self.cardobserver)
开发者ID:StuffCard,项目名称:smartcard-webconnector-python,代码行数:7,代码来源:webconnector.py


示例16: entry_point

def entry_point():        
    print u"Smartcard monitor applet by Lauri Võsandi <[email protected]>"
    if not os.path.exists(PCSCD):
        print "Unable to find", PCSCD, "are you sure it is installed"
        
    applet = SmartcardApplet()
    reader_monitor = ReaderMonitor()
    reader_monitor.addObserver(applet.reader_observer)
    card_monitor = CardMonitor()
    card_monitor.addObserver(applet.card_observer)
    try:
        gtk.main()
    except KeyboardInterrupt:
        pass
    card_monitor.deleteObserver(applet.card_observer)
    reader_monitor.deleteObserver(applet.reader_observer)
开发者ID:laurivosandi,项目名称:esteidtray,代码行数:16,代码来源:applet.py


示例17: _CcidCardObserver

class _CcidCardObserver(CardObserver):

    def __init__(self, controller):
        self._controller = weakref.ref(controller)
        self._monitor = CardMonitor()
        self._monitor.addObserver(self)

    def update(self, observable, tup):
        (added, removed) = tup
        c = self._controller()
        if c:
            c._update([card.reader for card in added],
                      [r.reader for r in removed])

    def delete(self):
        self._monitor.deleteObservers()
开发者ID:Yubico,项目名称:yubioath-desktop-dpkg,代码行数:16,代码来源:ccid.py


示例18: listen

 def listen(self):
     '''
     The listen function is called during initialisation of the class & the
     application. It initialises the process of starting to listen to card
     taps on the reader.
     '''
     self.monitor = CardMonitor()
     self.observer = Observer(self)
     self.monitor.addObserver(self.observer)
开发者ID:hasgeek,项目名称:contactpoint,代码行数:9,代码来源:__init__.py


示例19: __init__

    def __init__(self, *args, **kwargs):
        # base classes are old style classes so super() not allowed here
        cmd.Cmd.__init__(self, *args, **kwargs)

        self.reader = select_reader()
        self.card = None
        self.connection = None
        self.sel_obj = ''
        self.card_monitor = CardMonitor()
        self.card_monitor.addObserver(self)
开发者ID:12019,项目名称:python-apducmd,代码行数:10,代码来源:apducmd.py


示例20: Webconnector

class Webconnector():

    cardmonitor = None
    cardobserver = None

    """
        MainClass for the Webconnector
    """
    def __init__(self, args):
        feedbackHandler.setup()

        self.cardmonitor = CardMonitor()
        self.cardobserver = cardWebconnector(args)

        self.addCardObserver(self.cardobserver)

    def shutdown(self):
        print "Shutdown"
        self.removeCardObserver(self.cardobserver)
        feedbackHandler.shutdown()

    def addCardObserver(self, observer):
        self.cardmonitor.addObserver(observer)

    def removeCardObserver(self, observer):
        self.cardmonitor.deleteObserver(observer)

    def checkConnection(self, url):
        try:
            # Try connection
            response = urllib2.urlopen(url, timeout=1)

            # Connection successful, activate Connection-LED
            feedbackHandler.setFeedback(feedbackHandler.CONNECTION, feedbackHandler.ACTIVE)

            return True
        except urllib2.URLError as e:
            # No Connection to Server
            feedbackHandler.setFeedback(feedbackHandler.CONNECTION, feedbackHandler.INACTIVE)
        finally:
            return False
开发者ID:StuffCard,项目名称:smartcard-webconnector-python,代码行数:41,代码来源:webconnector.py



注:本文中的smartcard.CardMonitoring.CardMonitor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python CardRequest.CardRequest类代码示例发布时间:2022-05-27
下一篇:
Python utils.unicode_sorter函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap