def update(device_id): if isinstance(device_id, Device): device = device_id else: device = Device.get(device_id) if device is None: log.error("当前设备不存在,或者参数错误: device_id = {}".format(device_id)) return False if DeviceService.get_update_state( device) != DeviceUpdateStatus.UPDATE_FINISH: log.info( "当前设备游戏更新状态不需要设置: device_id = {} update_state = {}".format( device.id, device.update_state)) return True # 判断是否有游戏需要更新 if not DeviceGameService.is_device_need_update(device.id): log.info("当前游戏都是最新版, 不需要更新: device_id = {}".format(device.id)) return True log.info("当前存在游戏需要更新,通知客户端更新: device_id = {}".format(device.id)) return DeviceService.set_update_state(device, DeviceUpdateStatus.UPDATE_WAIT)
def to_dict(self): device = Device.get(self.device_id) if device is None: device_dict = {} else: device_dict = device.to_dict() return { 'id': self.id, 'device': device_dict, 'province': self.province, 'city': self.city, 'area': self.area, 'location': self.location, 'utime': self.utime.strftime('%Y-%m-%d %H:%M:%S'), 'ctime': self.ctime.strftime('%Y-%m-%d %H:%M:%S'), }
def get_device_by_id(device_id): return Device.get(device_id)