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


Python Entity.find方法代码示例

本文整理汇总了Python中entities.Entity.find方法的典型用法代码示例。如果您正苦于以下问题:Python Entity.find方法的具体用法?Python Entity.find怎么用?Python Entity.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在entities.Entity的用法示例。


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

示例1: test_12_modify2

# 需要导入模块: from entities import Entity [as 别名]
# 或者: from entities.Entity import find [as 别名]
 def test_12_modify2(self):
     te = Entity.find( 'UID-1234' )
     te.state = STATE_OFF
     te.state_value = None
     te.last_checkin = time.time()
     te.save()
     self.printall()
开发者ID:rycus86,项目名称:IntelliHomeControl-py,代码行数:9,代码来源:tentity.py

示例2: test_11_modify1

# 需要导入模块: from entities import Entity [as 别名]
# 或者: from entities.Entity import find [as 别名]
 def test_11_modify1(self):
     te = Entity.find( 'UID-1234' )
     te.name = 'Test entity 1'
     te.state = STATE_ON
     te.state_value = '30%'
     te.assigned_id = 0x01
     te.last_checkin = time.time()
     te.save()
     self.printall()
开发者ID:rycus86,项目名称:IntelliHomeControl-py,代码行数:11,代码来源:tentity.py

示例3: test_24_power_state_plus_control

# 需要导入模块: from entities import Entity [as 别名]
# 或者: from entities.Entity import find [as 别名]
 def test_24_power_state_plus_control(self):
     tl = Entity.find( 'POWER-0' )
     tl.control(COMMAND_ON)
     self.printall()
     print tl
     
     tl.set_state(STATE_ON)
     self.printall()
     print tl
开发者ID:rycus86,项目名称:IntelliHomeControl-py,代码行数:11,代码来源:tentity.py

示例4: receive

# 需要导入模块: from entities import Entity [as 别名]
# 或者: from entities.Entity import find [as 别名]
 def receive(self, address, unique_id, flags, data):
     ''' Processes received data from a physical device. '''
     
     DeviceHandler.receive(self, address, unique_id, flags, data)
     
     entity = Entity.find(unique_id)
     if entity is None:
         print 'No device found with id:', unique_id
     else:
         if entity.state_changed(data):
             ClientModule.instance().send_state_change(entity)
开发者ID:rycus86,项目名称:IntelliHomeControl-py,代码行数:13,代码来源:client.py

示例5: send_message

# 需要导入模块: from entities import Entity [as 别名]
# 或者: from entities.Entity import find [as 别名]
 def send_message(self, unique_id, message):
     ''' Sends a message to the entity identified by "unique_id". '''
     
     entity = Entity.find(unique_id)
     if entity is None:
         print 'No device found with id:', unique_id
     else:
         if entity.entity_type.comm_type == EntityType.COMM_TYPE_RADIO:
             self.__radio_handler.send(unique_id, message)
         else:
             print 'No communication type found for:', entity.entity_type, '| entity:', entity
开发者ID:rycus86,项目名称:IntelliHomeControl-py,代码行数:13,代码来源:client.py

示例6: describe

# 需要导入模块: from entities import Entity [as 别名]
# 或者: from entities.Entity import find [as 别名]
 def describe(self, address, unique_id, data):
     ''' Registers a device for the given physical address. '''
     
     DeviceHandler.describe(self, address, unique_id, data)
     
     etype_id = data[0]
     etype = EntityType.find(etype_id)
     if etype:
         entity = Entity.find(unique_id)
         if entity is None:
             entity = Entity(unique_id, etype, 'Unknown device: ' + unique_id, last_checkin=time.time())
             entity.save()
             print 'Device registered:', entity
             ClientModule.instance().send_state_change(entity)
         else:
             entity.last_checkin = time.time()
             entity.save()
             print 'Device found:', entity
             ClientModule.instance().send_state_change(entity)
     else:
         print 'Entity type not found:', etype_id
开发者ID:rycus86,项目名称:IntelliHomeControl-py,代码行数:23,代码来源:client.py

示例7: handle_received_message

# 需要导入模块: from entities import Entity [as 别名]
# 或者: from entities.Entity import find [as 别名]
 def handle_received_message(self, handler, sender, header, message):
     ''' Handles received messages from client connections. '''
     
     if header == Header.MSG_A_LOGIN:
         if ClientModule.DEBUG:
             print 'Login Message received from', sender, ':', header, message
         
         try:
             username, password = message.split(':')
             session_id, admin = Authentication.instance().authenticate(username, password)
             if session_id is not None:
                 handler.authentication_succeeded(session_id, sender)
                 self.respond(handler, header, session_id + ('*' if admin else ''), sender)
             else:
                 handler.authentication_failed(sender)
         except:
             handler.authentication_failed(sender)
     
     # needs session checking
     elif handler.is_valid_session(message, sender):
         
         original_message = message
         message = handler.strip_session_prefix(message)
         
         if ClientModule.DEBUG:
             print 'Message received from', sender, ':', header, 
             print '\'' + message + '\'',
             print '| original was', '\'' + original_message + '\''
         
         if header == Header.MSG_A_KEEPALIVE:
             self.respond(handler, header, None, sender)
         
         elif header == Header.MSG_A_LIST_DEVICE_TYPES:
             rsp = ''
             for t in EntityType.all():
                 rsp = rsp + t.serialize() + ','
             if len(rsp) > 0:
                 rsp = rsp[0:-1]
             rsp = '[' + rsp + ']'
             
             self.respond(handler, header, rsp, sender)
             
         elif header == Header.MSG_A_LIST_DEVICES:
             typeid, name_pattern = None, None
             if re.match('^[0-9]+;.*$', message):
                 typeid, name_pattern = message.split(';')
                 typeid = int(typeid)
             elif re.match('^[0-9]+', message):
                 typeid = int(message)
             elif len(message) > 0:
                 name_pattern = message
             
             rsp = ''
             for e in Entity.list(typeid, name_pattern):
                 rsp = rsp + e.serialize() + ','
             if len(rsp) > 0:
                 rsp = rsp[0:-1]
             rsp = '[' + rsp + ']'
             
             self.respond(handler, header, rsp, sender)
             
         elif header == Header.MSG_A_SEND_COMMAND:
             entity_id, cmd = message.split('#')
             cmd_param = None
             if ';' in cmd:
                 cmd, cmd_param = cmd.split(';')
             
             entity = Entity.find(entity_id)
             if entity:
                 command = EntityCommand.find( int(cmd) )
                 if command:
                     entity.control(self, command, cmd_param)
                     self.respond(handler, header, None, sender)
                 else:
                     self.respond(handler, Header.MSG_A_ERROR, _('error.not.found.command') + ': ' + str(cmd), sender)
             else:
                 self.respond(handler, Header.MSG_A_ERROR, _('error.not.found.device') + ': ' + str(entity_id), sender)
         
         elif header == Header.MSG_A_LOAD_TYPE_IMAGE:
             imgname = message
             
             content = None
             
             image_path = self.__find_image_path(imgname)
             if image_path: 
                 imgfile = file(image_path)
                 try:
                     content = base64.b64encode(imgfile.read())
                 finally:
                     imgfile.close()
             
             if content:
                 self.respond(handler, header, content, sender)
             else:
                 self.respond(handler, Header.MSG_A_ERROR, _('error.load.image') + ': ' + imgname, sender)
                 
         elif header == Header.MSG_A_RENAME_DEVICE:
             eid, name = message.split(';', 1)
             
             entity = Entity.find(eid)
#.........这里部分代码省略.........
开发者ID:rycus86,项目名称:IntelliHomeControl-py,代码行数:103,代码来源:client.py

示例8: test_22_light_state_changed

# 需要导入模块: from entities import Entity [as 别名]
# 或者: from entities.Entity import find [as 别名]
 def test_22_light_state_changed(self):
     tl = Entity.find( 'LIGHT-1' )
     tl.set_state(STATE_OFF)
     self.printall()
     print tl
开发者ID:rycus86,项目名称:IntelliHomeControl-py,代码行数:7,代码来源:tentity.py

示例9: test_21_light_command

# 需要导入模块: from entities import Entity [as 别名]
# 或者: from entities.Entity import find [as 别名]
 def test_21_light_command(self):
     tl = Entity.find( 'LIGHT-1' )
     tl.control(COMMAND_ON)
     tl.control(EntityCommand.find(100), 30)
     tl.control(COMMAND_OFF)
开发者ID:rycus86,项目名称:IntelliHomeControl-py,代码行数:7,代码来源:tentity.py

示例10: test_14_find

# 需要导入模块: from entities import Entity [as 别名]
# 或者: from entities.Entity import find [as 别名]
 def test_14_find(self):
     te3 = Entity.find( 'UID-1234' )
     print te3
开发者ID:rycus86,项目名称:IntelliHomeControl-py,代码行数:5,代码来源:tentity.py

示例11: test_13_non_existent

# 需要导入模块: from entities import Entity [as 别名]
# 或者: from entities.Entity import find [as 别名]
 def test_13_non_existent(self):
     te2 = Entity.find( 'UID-xxx' )
     print te2
开发者ID:rycus86,项目名称:IntelliHomeControl-py,代码行数:5,代码来源:tentity.py


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