コード例 #1
0
ファイル: auth.py プロジェクト: rycus86/IntelliHomeControl-py
 def configure(self, database):
     ModuleBase.configure(self, database)
     
     # Checking database table
     try:
         database.select(Authentication.__exists_query)
     except:
         database.write(Authentication.__create_stmt)
         
     # Checking administrator user
     with database.writer():
         admin_username = database.select(Authentication.__admin_exists_query).fetchone()
         if not admin_username:
             database.write(
                    Authentication.__admin_insert_stmt, 
                    'admin', hashlib.md5('admin').hexdigest())
             print 'AUTH| Created default administrator user'
コード例 #2
0
 def configure(self, database):
     ModuleBase.configure(self, database)
     
     self.__radio_handler = RadioHandler()
     self.__handlers = []
     
     # register communication handlers
     for idx in xrange(len(sysargs.communication.modes)):
         mode = sysargs.communication.modes[idx]
         port = sysargs.communication.ports[idx]
         host = sysargs.communication.hosts[idx]
         
         if mode.lower() == 'mcast':
             if port is None: port = ClientModule.DEFAULT_PORT
             if host is None: host = ClientModule.DEFAULT_MCAST_GROUP
             
             handler = UDPHandler(host, port, handler=self.handle_received_message, multicast=True)
             self.__handlers.append(handler)
             
         elif mode.lower() == 'bcast':
             if port is None: port = ClientModule.DEFAULT_PORT
             if host is None: host = ClientModule.DEFAULT_BCAST_ADDRESS
             
             handler = UDPHandler(host, port, handler=self.handle_received_message, broadcast=True)
             self.__handlers.append(handler)
             
         elif mode.lower() == 'udp':
             if port is None: port = ClientModule.DEFAULT_PORT
             if host is None: host = ClientModule.DEFAULT_BIND_ADDRESS
             
             handler = UDPHandler(host, port, handler=self.handle_received_message)
             self.__handlers.append(handler)
             
         elif mode.lower() == 'tcp':
             if port is None: port = ClientModule.DEFAULT_PORT
             if host is None: host = ClientModule.DEFAULT_BIND_ADDRESS
             
             handler = TCPHandler(host, port, handler=self.handle_received_message)
             self.__handlers.append(handler)
             
         else:
             print 'Unsupported communication mode:', mode
コード例 #3
0
 def configure(self, database):
     ModuleBase.configure(self, database)
     self.__rf.register_message_receiver(self)