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


Python queryconfig.Query类代码示例

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


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

示例1: Mochad

class Mochad(XplPlugin):

    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

    def connect(self):
        for res in socket.getaddrinfo(self.__host, self.__port, socket.AF_UNSPEC, socket.SOCK_STREAM):
            af, socktype, proto, canonname, sa = res
            try:
                self.mochad_socket = socket.socket(af, socktype, proto)
            except socket.error, msg:
                self.mochad_socket = None
                continue
            try:
                self.mochad_socket.connect(sa)
            except socket.error, msg:
                self.mochad_socket.close()
                self.mochad_socket = None
                continue
            break
开发者ID:capof,项目名称:domogik,代码行数:49,代码来源:mochad.py

示例2: __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

示例3: __init__

    def __init__(self):
        """ Create lister for google agenda requets
        """
        XplPlugin.__init__(self, name = 'gagenda')

        # Create logger
        self.log.debug("Listener for Google agenda created")

        # Get config
        self._config = Query(self.myxpl, self.log)
        self._email = self._config.query('gagenda', 'email')
        self._password = self._config.query('gagenda', 'password')
        self._calendar_name = self._config.query('gagenda', 'calendarname')

        # Create object
        self._gagenda_manager = GAgenda(self.log, \
                                       self._email, \
                                       self._password, \
                                       self._calendar_name, \
                                       self._broadcast_events)

        # Create listener for today
        Listener(self.gagenda_cb, self.myxpl, {'schema': 'calendar.request',
                'xpltype': 'xpl-cmnd', 'command': 'REQUEST'})
        self.enable_hbeat()
开发者ID:capof,项目名称:domogik,代码行数:25,代码来源:gagenda.py

示例4: __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

示例5: __init__

    def __init__(self, proxy_ip, proxy_port):
        """
        Initiate properties
        Then, start HTTP server and give it initialized data
        @param proxy_ip :  ip of the proxy server
        @param proxy_port :  port of proxy server
        """

        XplPlugin.__init__(self, name = 'proxy',
            reload_cb = self.reload_config)
        # logging initialization
        self.log.info("Proxy initialisation ...")
        self.log.debug("locale : %s %s" % locale.getdefaultlocale())
        self._config = Query(self.myxpl, self.log)
        self.server = None
        self.server_process = None
        self.proxy_ip = None
        self.proxy_port = None
        self.use_ssl = False
        self.ssl_certificate = None
        self.server_ip = None
        self.server_port = None
        self.auth_method = None
        self.username = None
        self.password = None
        self.add_stop_cb(self.stop_http)
        self.enable_hbeat()
        self.reload_config()
开发者ID:capof,项目名称:domogik,代码行数:28,代码来源:proxy.py

示例6: __init__

    def __init__(self):
        """ Create lister and launch bg listening
        """
        try:
            XplPlugin.__init__(self, name = 'karotz')
        except:
            self.log.error("Error to create Karotz Xplplugin=%s" % (traceback.format_exc()))
            return
            
        self._config = Query(self.myxpl, self.log)

        self.instid = self._config.query('karotz', 'installid')
        self.lang = self._config.query('karotz', 'language')
        
        try:
            self.log.info("Starting library")
            self.karotz=Karotz(self.log,self.instid)
            self.log.info("Started")
        except:
            self.log.error("Error to create Karotz object=%s" % (traceback.format_exc()))
            return

                
        self.log.info("Creating listener for Karotz")
        Listener(self.xpl_command, self.myxpl, {'schema': 'karotz.basic', 'xpltype': 'xpl-cmnd'})
        

        #self.add_stop_cb(self.stop)
        self.enable_hbeat()

        self.log.info("Plugin ready :)")
开发者ID:capof,项目名称:domogik,代码行数:31,代码来源:karotz.py

示例7: __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

示例8: __init__

    def __init__(self):
        '''
        Create the plcbusMain class
        This class is used to connect PLCBUS to the xPL Network
        '''
        # Load config
        XplPlugin.__init__(self, name = 'plcbus')
        # Create listeners
        Listener(self._plcbus_cmnd_cb, self.myxpl, {
            'schema': 'plcbus.basic',
            'xpltype': 'xpl-cmnd',
        })
        self._config = Query(self.myxpl, self.log)
        device = self._config.query('plcbus', 'device')
        self._usercode = self._config.query('plcbus', 'usercode')
        self._probe_inter = int( self._config.query('plcbus', 'probe-interval'))
        self._probe_list = self._config.query('plcbus', 'probe-list')

        # Create log instance
        self.api = PLCBUSAPI(self.log, device, self._command_cb, self._message_cb)
        self.add_stop_cb(self.api.stop)
        if self._probe_inter == 0:
            self.log.warning("The probe interval has been set to 0. This is not correct. The plugin will use a probe interval of 5 seconds")
            self._probe_inter = 5 
        self._probe_status = {}
        self._probe_thr = XplTimer(self._probe_inter, self._send_probe, self.myxpl)
        self._probe_thr.start()
#       self.register_timer(self._probe_thr)
        self.enable_hbeat()
开发者ID:capof,项目名称:domogik,代码行数:29,代码来源:plcbus.py

示例9: __init__

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

        # Configuration
        self._config = Query(self.myxpl, self.log)
        device = self._config.query('cidmodem', 'device')

        cid_command = self._config.query('cidmodem', 'cid-command')

        # Init Modem
        cid  = CallerIdModem(self.log, self.send_xpl)
        
        # Open Modem
        try:
            cid.open(device, cid_command)
        except CallerIdModemException as e:
            self.log.error(e.value)
            print(e.value)
            self.force_leave()
            return
            
        # Start reading Modem
        cid_process = threading.Thread(None,
                                   cid.listen,
                                   "listen_cid",
                                   (),
                                   {})                                  
        cid_process.start()                              
        self.enable_hbeat()
开发者ID:capof,项目名称:domogik,代码行数:31,代码来源:cidmodem.py

示例10: __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

示例11: __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

示例12: CIDManager

class CIDManager(XplPlugin):
    """ Manage the modem to get CID
    """

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

        # Configuration
        self._config = Query(self.myxpl, self.log)
        device = self._config.query('cidmodem', 'device')

        cid_command = self._config.query('cidmodem', 'cid-command')

        # Init Modem
        cid  = CallerIdModem(self.log, self.send_xpl)
        
        # Open Modem
        try:
            cid.open(device, cid_command)
        except CallerIdModemException as e:
            self.log.error(e.value)
            print(e.value)
            self.force_leave()
            return
            
        # Start reading Modem
        cid_process = threading.Thread(None,
                                   cid.listen,
                                   "listen_cid",
                                   (),
                                   {})                                  
        cid_process.start()                              
        self.enable_hbeat()

    def send_xpl(self, num):
        """ Send xPL message on network
            @param num : call number
        """
        print("Input call : %s " % num)
        msg = XplMessage()
        msg.set_type("xpl-trig")
        msg.set_schema("cid.basic")
        msg.add_data({"calltype" : "INBOUND"})
        msg.add_data({"phone" : num})
        self.myxpl.send(msg)
开发者ID:capof,项目名称:domogik,代码行数:47,代码来源:cidmodem.py

示例13: __init__

    def __init__(self):
        """ Init plugin
        """
        XplPlugin.__init__(self, name='velbus')
        self._config = Query(self.myxpl, self.log)
        # get the config values
        device_type = self._config.query('velbus', 'connection-type')
        if device_type == None:
            self.log.error('Devicetype is not configured, exitting') 
            print('Devicetype is not configured, exitting')
            self.force_leave()
            return
        device = self._config.query('velbus', 'device')
        #device = '192.168.1.101:3788'
        if device == None:
            self.log.error('Device is not configured, exitting') 
            print('Device is not configured, exitting')
            self.force_leave()
            return
        # validate the config vars
        if (device_type != 'serial') and (device_type != 'socket'):
            self.log.error('Devicetype must be socket or serial, exitting') 
            print('Devicetype must be socket or serial, exitting')
            self.force_leave()
            return
        if device_type == 'socket' and not re.match('[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:[0-9]+', device):
            self.log.error('A socket device is in the form of <ip>:<port>, exitting') 
            print('A socket device is in the form of <ip>:<port>, exitting')
            self.force_leave()
            return

        # Init RFXCOM
        self.manager  = VelbusDev(self.log, self.send_xpl,
			self.send_trig, self.get_stop())
        self.add_stop_cb(self.manager.close)
        
        # Create a listener for all messages used by RFXCOM
        Listener(self.process_lighting_basic, self.myxpl,
                 {'xpltype': 'xpl-cmnd', 'schema': 'lighting.basic'})
        Listener(self.process_shutter_basic, self.myxpl,
                 {'xpltype': 'xpl-cmnd', 'schema': 'shutter.basic'})
        # Create listeners
        try:
            self.manager.open(device, device_type)
        except VelbusException as ex:
            self.log.error(ex.value)
            self.force_leave()
            return
        self.manager.scan()
            
        # Start reading RFXCOM
        listenthread = threading.Thread(None,
                                   self.manager.listen,
                                   "velbus-process-reader",
                                   (self.get_stop(),),
                                   {})
        self.register_thread(listenthread)
        listenthread.start()
        self.enable_hbeat()
开发者ID:capof,项目名称:domogik,代码行数:59,代码来源:velbus.py

示例14: __init__

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

        # Get config
        self._config = Query(self.myxpl, self.log)
        unit = self._config.query('yweather', 'unit' )
        if unit == None:
            self.log.error("Unit not configured : exiting")
            print("Unit not configured : exiting")
            self.force_leave()
            return
        unit = unit.lower()
        
        self.enable_current = self._config.query('yweather', 'en-current' )
        self.enable_previsionnal = self._config.query('yweather', 'en-prev' )

        self.cities = {}
        num = 1
        loop = True
        while loop == True:
            city_code = self._config.query('yweather', 'city-%s' % str(num))
            device = self._config.query('yweather', 'device-%s' % str(num))
            if city_code != None:
                self.cities[city_code] = { "device" : device }
                num = num + 1
            else:
                loop = False

        # Open weather for cities
        for city in self.cities:
            self.cities[city]["obj"] = YWeather(self.log, self.send_xpl)
            try:
                self.log.info("Init weather for '%s'" % city)
                self.cities[city]["obj"].open(city, unit,
                                              self.cities[city]["device"])
            except YWeatherException as err:
                self.log.error(err.value)
                print(err.value)
                self.force_leave()
                return

        # Start listening for weather
        for city in self.cities:
            try:
                self.log.info("Start listening weather for '%s'" % city)
                self._listen_thr = XplTimer(TIME_BETWEEN_EACH_WEATHER_READ, \
                                            self.cities[city]["obj"].get, \
                                            self.myxpl)
                self._listen_thr.start()
                self.enable_hbeat()
            except YWeatherException as err:
                self.log.error(err.value)
                print(err.value)
                self.force_leave()
                return
        self.enable_hbeat()
开发者ID:capof,项目名称:domogik,代码行数:58,代码来源:yweather.py

示例15: __init__

    def __init__(self):
        """ Create lister and launch bg listening
        """
        XplPlugin.__init__(self, name = 'zibase')

        self._config = Query(self.myxpl, self.log)

        self.address = self._config.query('zibase', 'ip')
        self.inter = self._config.query('zibase', 'interface')
        self.port = int(self._config.query('zibase', 'port'))
        self.valvar=self._config.query('zibase', 'envar')
        self.interv=int(self._config.query('zibase', 'interv'))

        self.log.info("Creating listener for ZiBase")
        Listener(self.zibase_command, self.myxpl, {'schema': 'zibase.basic',
                'xpltype': 'xpl-cmnd'})
        
        try:
            self.ip_host=get_ip_address(self.inter)
            self.log.debug("Adress IP Host=%s" % (self.ip_host))
        except:
            self.log.error("IP Host not found=%s" % (traceback.format_exc()))
            return

        try:
            self.api = APIZiBase(self.log,self.address)
        except:
            self.log.error("API ZiBase error=%s" % (traceback.format_exc()))
            return

        try:
            self.th=ServerZiBase(self.log,self.ip_host,self.port,self.myxpl)
            self.th.start()
        except:
            self.log.error("Server ZiBase error=%s" % (traceback.format_exc()))
            self.stop()

        try:
            self.api.Connect(self.ip_host,self.port)
        except:
            self.log.error("Connection ZiBase error=%s" % (traceback.format_exc()))
            self.stop()

        if self.valvar=="True" :
            try:
                self.log.info("Start reading internal variables")
                var_read=XplTimer(self.interv,self.zibase_read_var,self.myxpl)
                var_read.start()
            except:
                self.log.error("reading internal variables error")
                return

        self.add_stop_cb(self.stop)
        self.enable_hbeat()

        self.log.info("Plugin ready :)")
开发者ID:capof,项目名称:domogik,代码行数:56,代码来源:zibase.py


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