当前位置: 首页>>代码示例>>Python>>正文


Python plugin.XplPlugin类代码示例

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


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

示例1: __init__

    def __init__(self):
        parser = OptionParser()
        parser.add_option("-c", action="store_true", dest="compress", \
		default=False, help="Diaply data in a compress way")
        parser.add_option("-t", action="store", dest="xpltype", \
                default=None, type="string", \
                help="Filter messages on XPL message type")
        parser.add_option("-s", action="store", dest="xplsource", \
                default=None, type="string", \
                help="Filter messages on XPL source field")
        parser.add_option("-S", action="store", dest="xplschema", \
                default=None, type="string", \
                help="Filter messages on XPL schema field")
        parser.add_option("-i", action="store", dest="xplinstance", \
                default=None, type="string", \
                help="Filter messages on XPL instance")
        XplPlugin.__init__(self, name='dump_xpl', daemonize=False, \
                parser=parser)
        fil = {}
        if self.options.xpltype != None:
            fil['xpltype'] = self.options.xpltype
        if self.options.xplsource != None:
            fil['xplsource'] = self.options.xplsource
        if self.options.xplschema != None:
            fil['schema'] = self.options.xplschema
        if self.options.xplinstance != None:
            fil['xplinstance'] = self.options.xplinstance
        Listener(self._sniffer_cb, self.myxpl, filter=fil)
        self.enable_hbeat()
开发者ID:capof,项目名称:domogik,代码行数:29,代码来源:dump_xpl.py

示例2: __init__

    def __init__(self):
        """ Init plugin
        """
        XplPlugin.__init__(self, name='k8056')

        # check if the plugin is configured. If not, this will stop the plugin and log an error
        if not self.check_configured():
            return

        # Configuration
        device = self.get_config("k8056_device")                         # Serial port
        if device is None:
            self.log.error('### Device is not configured, exitting')
            self.force_leave()
            return

        # Init relayboard
        self.k8056_board = K8056(self.log)

        # Open serial port
        try:
            self.k8056_board.open(device)
        except K8056Exception as e:
            self.log.error(e.value)
            print(e.value)
            self.force_leave()
            return

        # Create listeners
        self.log.info("### Creating listener for K8056")
        Listener(self.k8056_cmnd_cb, self.myxpl, {'xpltype': 'xpl-cmnd', 'schema': 'ac.basic'})    # ac.basic { address=0 unit=1 command=off }

        self.ready()
开发者ID:vdomos,项目名称:domogik-plugin-k8056,代码行数:33,代码来源:k8056.py

示例3: __init__

 def __init__(self):
     XplPlugin.__init__(self, name="scenario")
     self._backend = ScenarioManager(self.log)
     self.add_stop_cb(self.end)
     self.add_stop_cb(self.shutdown)
     self.log.info(u"Scenario Frontend and Manager initialized, let's wait for some work.")
     self.ready()
开发者ID:Basilic,项目名称:domogik,代码行数:7,代码来源:scenario.py

示例4: __init__

 def __init__(self):
     """
     Create the X10Main class
     This class is used to connect x10 (through heyu) to the xPL Network
     """
     XplPlugin.__init__(self, name = 'x10_heyu')
     self._heyu_cfg_path_res = ""
     self._config = Query(self.myxpl, self.log)
     self._heyu_cfg_path_res = self._config.query('x10_heyu', 'heyu-cfg-path')
     try:
         self.__myx10 = X10API(self._heyu_cfg_path_res, self.log)
     except Exception:
         self.log.error("Something went wrong during heyu init, check logs")
         self.log.error("Exception : %s" % traceback.format_exc())
         exit(1)
     #Create listeners
     Listener(self.x10_cmnd_cb, self.myxpl, {'schema': 'x10.basic', 'xpltype': 'xpl-cmnd'})
     #One listener for system schema, allowing to reload config
     #Listener(self.heyu_reload_config, self.myxpl, {'schema': 'domogik.system', 'xpltype': 'xpl-cmnd',
     #                                                'command': 'reload', 'plugin': 'x10'})
     #One listener for system schema, allowing to dump config
     #Listener(self.heyu_dump_config, self.myxpl, {'schema': 'domogik.system', 'xpltype': 'xpl-cmnd',
     #                                              'command': 'push_config', 'plugin': 'x10'})
     self.log.debug("before start X10monitor")
     self._monitor = X10Monitor(self._heyu_cfg_path_res)
     self._monitor.get_monitor().add_cb(self.x10_monitor_cb)
     self._monitor.get_monitor().start()
     self.enable_hbeat()
     self.log.debug("Heyu correctly started")
开发者ID:capof,项目名称:domogik,代码行数:29,代码来源:x10_heyu.py

示例5: __init__

    def __init__(self):
        """
        Create the bluez plugin.
        """
        XplPlugin.__init__(self, name = 'bluez')
        self.log.info("__init__ : Start ...")
        self.config = Query(self.myxpl, self.log)

        self.log.debug("__init__ : Try to start the bluez API")
        try:
            self._bluez = BluezAPI(self.log, self.config, self.myxpl, \
                self.get_stop())
        except:
            error = "Something went wrong during bluezAPI init : %s" %  \
                     (traceback.format_exc())
            self.log.error("__init__ : "+error)

        self.log.debug("__init__ : Try to create listeners")
        Listener(self.basic_cmnd_cb, self.myxpl,
                 {'schema': 'bluez.basic', 'xpltype': 'xpl-cmnd'})

        self.add_stop_cb(self._bluez.stop_all)

        #self.enable_helper()
        self.enable_hbeat()
        self._bluez.start_adaptator()
        self.log.info("Plugin bluez correctly started.")
开发者ID:capof,项目名称:domogik,代码行数:27,代码来源:bluez.py

示例6: __init__

    def __init__(self):
        """ Init plugin
        """
        XplPlugin.__init__(self, name='weather')

        # check if the plugin is configured. If not, this will stop the plugin and log an error
        #if not self.check_configured():
        #    return

        # get the devices list
        # for this plugin, if no devices are created we won't be able to use devices.
        self.devices = self.get_device_list(quit_if_no_device = True)


        self.weather_manager = Weather(self.log, 
                                       self.send_xpl_sensor_basic, 
                                       self.send_xpl_weather_forecast, 
                                       self.get_stop(), 
                                       self.get_parameter_for_feature)
        # Start getting weather informations
        weather_process = threading.Thread(None,
                                    self.weather_manager.start_loop,
                                    "weather-process",
                                    (self.devices,),
                                    {})
        self.register_thread(weather_process)
        weather_process.start()

        self.ready()
开发者ID:fritz-smh,项目名称:domogik-plugin-weather,代码行数:29,代码来源:weather.py

示例7: __init__

    def __init__(self):
        """ Init plugin
        """
        XplPlugin.__init__(self, name='daikcode')

        # check if the plugin is configured. If not, this will stop the plugin and log an error
        if not self.check_configured():
            return

        # get the devices list
        self.devices = self.get_device_list(quit_if_no_device = False)
        # get the config values
        self.remoteManager = RemoteManager(self, self.send_xpl)
        for a_device in self.devices :
            try :
                if a_device['device_type_id'] != 'daikcode.remotearc' :
                #if device_name == None  or irtransmitter == None or options == None :
                    self.log.error(u"No daikcode.remotearc device type")
                    break
                else :
                    self.remoteManager.addRemote(a_device)
                    self.log.debug("Ready to work with device {0}".format(getRemoteId(a_device)))
            except:
                self.log.error(traceback.format_exc())
                # we don't quit plugin if an error occured
                #self.force_leave()
                #return
         # Create the xpl listeners
        Listener(self.handle_xpl_cmd, self.myxpl,{'schema': 'daikin.basic',
                                                                        'xpltype': 'xpl-cmnd'})
        Listener(self.handle_xpl_trig, self.myxpl,{'schema': 'ir.basic',
                                                                        'xpltype': 'xpl-trig'})
        print "Plugin ready :)"
        self.log.info("Plugin ready :)")
        self.ready()
开发者ID:Nico0084,项目名称:domogik-plugin-daikcode,代码行数:35,代码来源:daikcode.py

示例8: __init__

    def __init__(self):
        """ Init plugin
        """
        XplPlugin.__init__(self, name='mirror')
        # Get config
        #   - device
        self._config = Query(self.myxpl, self.log)
        device = self._config.query('mirror', 'device')

        # Init Mir:ror
        mirror  = Mirror(self.log, self.send_xpl)
        
        # Open Mir:ror
        try:
            mirror.open(device)
        except MirrorException as e:
            self.log.error(e.value)
            print(e.value)
            self.force_leave()
            return
            
        # Start reading Mir:ror
        mirror_process = threading.Thread(None,
                                   mirror.listen,
                                   "mirror-process-reader",
                                   (self.get_stop(),),
                                   {})
        self.register_thread(mirror_process)
        mirror_process.start()
        self.enable_hbeat()
开发者ID:capof,项目名称:domogik,代码行数:30,代码来源:mirror.py

示例9: on_mdp_request

    def on_mdp_request(self, msg):
        """ Called when a MQ req/rep message is received
        """
        XplPlugin.on_mdp_request(self, msg)
        if msg.get_action() == "client.cmd":
            print(msg)
            reason = None
            status = True
            data = msg.get_data()
            if 'blacklist' in data:
                bl = data['blacklist']
            else:
                reason = u"Invalid command : no blacklist key in message"
                status = False

            if status == True:
                try:
                    with open(self.blacklist_file, 'ab') as fp_blacklist:
                        fp_blacklist.write("\n{0};{1}".format("manual blacklisting", bl))
                except:
                    reason = u"Error while completing blacklist file : {0}. Error is : {1}".format(self.blacklist_file, traceback.format_exc())
                    self.log.error(reason)
                    status = False
                self.load_blacklist()


            self.log.info("Reply to command")
            reply_msg = MQMessage()
            reply_msg.set_action('client.cmd.result')
            reply_msg.add_data('status', status)
            reply_msg.add_data('reason', reason)
            self.reply(reply_msg.get())

            if status == True:
                thread.start_new_thread(self.open_modems, ())
开发者ID:fritz-smh,项目名称:domogik-plugin-callerid,代码行数:35,代码来源:callerid.py

示例10: __init__

    def __init__(self):
        '''
        Start teleinfo device handler
        '''
        XplPlugin.__init__(self, name='teleinfo')
        self._config = Query(self.myxpl, self.log)
        device = self._config.query('teleinfo', 'device')
        interval = self._config.query('teleinfo', 'interval')

        # Init Teleinfo
        teleinfo  = Teleinfo(self.log, self.send_xpl)
        
        # Open Teleinfo modem
        try:
            teleinfo.open(device)
        except TeleinfoException as err:
            self.log.error(err.value)
            print(err.value)
            self.force_leave()
            return
            
        self.add_stop_cb(teleinfo.close)
        # Start reading Teleinfo
        teleinfo_process = threading.Thread(None,
                                   teleinfo.listen,
                                   'teleinfo-listen',
                                   (float(interval),),
                                   {})                                  
        teleinfo_process.start()                              
        self.enable_hbeat()
开发者ID:capof,项目名称:domogik,代码行数:30,代码来源:teleinfo.py

示例11: __init__

    def __init__(self):
        """ Init manager
        """
        XplPlugin.__init__(self, name = 'sms')

        # Configuration

        self._config = Query(self.myxpl, self.log)
        login = self._config.query('sms', 'login')
        password = self._config.query('sms', 'password')
        phone = self._config.query('sms', 'phone')
	operator = self._config.query('sms', 'operator')
	operator = operator.lower()

        if (operator == "orange"):
		from domogik_packages.xpl.lib.sms_orange import Sms
	if (operator == "sfr"):
		from domogik_packages.xpl.lib.sms_sfr import Sms
	if (operator == "bouygues"):
		from domogik_packages.xpl.lib.sms_bouygues import Sms		
        self.log.debug("Init info for sms created")
        ### Create Sms objects
        self.my_sms = Sms(self.log,login,password,phone)
	self.log.debug("Create object for sms created")
        # Create listener
        Listener(self.sms_cb, self.myxpl, {'schema': 'sendmsg.basic','xpltype': 'xpl-cmnd'})
        self.log.debug("Listener for sms created")

        self.enable_hbeat()
开发者ID:capof,项目名称:domogik,代码行数:29,代码来源:sms.py

示例12: __init__

    def __init__(self):
        """ Init plugin
        """
        XplPlugin.__init__(self, name='rfxbnz')

        # check if the plugin is configured. If not, this will stop the plugin and log an error
        if not self.check_configured():
            return

        # Configuration
        host = self.get_config("host")                         # host where rfxcomrx run
        if host is None:
            self.log.error('### Host is not configured, exiting')
            self.force_leave()
            return

        self.lastTimestampHbeat = time.time()

        # Create listeners
        self.log.info("==>  Creating listener for rfxbnz")
        Listener(self.rfxbnz_stat_cb, self.myxpl, {'xplsource': 'bnz-rfxcomrx.' + host, 'xpltype': 'xpl-stat', 'schema': 'hbeat.app'})

        self.log.info("==> Launch thread to rfxbnz_chk_hbeat")
        threads = {}
        thr_name = "rfxbnz_chk"
        threads[thr_name] = threading.Thread(None,
                                            self.rfxbnz_chk_hbeat,
                                            thr_name,
                                            (self.log,
                                                self.get_stop()),
                                            {})
        threads[thr_name].start()
        self.register_thread(threads[thr_name])

        self.ready()
开发者ID:vdomos,项目名称:domogik-plugin-rfxbnz,代码行数:35,代码来源:rfxbnz.py

示例13: __init__

    def __init__(self):
        """
        Create the tsChacon class
        This class is used to connect chacon devices (through TellSitck) to the xPL Network
        """
        XplPlugin.__init__(self, name = 'tschacon')
        self.log.debug("tschacon correctly started")
        self._device = "/dev/tellstick"
	#Check if the device exists
        if not os.path.exists(self._device):
            self.log.error(self._device + " is not present")
        else:
            self.log.debug("device present as "+self._device)
        self._config = Query(self.myxpl, self.log)
        try:
            self.__mytellstick = TellStick()
        except Exception:
            self.log.error("Something went wrong during TellStick init, check logs")
            self.log.error("Exception : %s" % traceback.format_exc())
            exit(1)
        #Create listeners
        Listener(self.tsChacon_cmnd_cb, self.myxpl, 
                 {'schema': 'ts.arctech', 'xpltype': 'xpl-cmnd'})
        self.enable_hbeat()
        self.log.debug("tschacon plugin correctly started")
开发者ID:capof,项目名称:domogik,代码行数:25,代码来源:tschacon.py

示例14: __init__

    def __init__(self):
        # Connect to the socket

        XplPlugin.__init__(self, name = 'mochad')

        self.mochad_socket = None

        self._config = Query(self.myxpl, self.log)
        self.__host = self._config.query('mochad','mochad-host')
        self.__port = self._config.query('mochad','mochad-port')
        if self._config.query('mochad','cm15') == "True":
            self.__cm15 = True
        else:
            self.__cm15 = False
        if self._config.query('mochad','cm19') == "True":
            self.__cm19 = True
        else:
            self.__cm19 = False

        if self.__cm15:
            self.__itf = "pl"
        elif self.__cm19:
            self.__itf = "rf"

        self.connect()

        child_pid = os.fork()
        if child_pid == 0:
            self.listener()
        else:
            return None
开发者ID:capof,项目名称:domogik,代码行数:31,代码来源:mochad.py

示例15: __init__

    def __init__(self):
        """ Init plugin
        """
        XplPlugin.__init__(self, name='irtrans')

        # check if the plugin is configured. If not, this will stop the plugin and log an error
        if not self.check_configured():
            return

        # get the devices list
        self.devices = self.get_device_list(quit_if_no_device = False)
        # get the config values
        self.managerClients = ManagerClients(self,  self.send_xplTrig)
        for a_device in self.devices :
            try :
                if (a_device['device_type_id'] != 'irtrans.irtrans_lan') and (a_device['device_type_id'] != 'irtrans.irwsserver') :
                    self.log.error(u"No a device type reconized : {0}".format(a_device['device_type_id']))
                    break
                else :
                    if self.managerClients.addClient(a_device) :
                        self.log.info("Ready to work with device {0}".format(getIRTransId(a_device)))
                    else : self.log.info("Device parameters not configured, can't create IRTrans Client : {0}".format(getIRTransId(a_device)))
            except:
                self.log.error(traceback.format_exc())
                # we don't quit plugin if an error occured
                #self.force_leave()
                #return
        # Create the xpl listeners
        Listener(self.handle_xpl_cmd, self.myxpl,{'schema': 'irtrans.basic',
                                                                        'xpltype': 'xpl-cmnd'})
        print "Plugin ready :)"
        self.log.info("Plugin ready :)")
        self.ready()
开发者ID:Raghbinho,项目名称:domogik-plugin-irtrans,代码行数:33,代码来源:irtrans.py


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