def create_group_icon(_redis, _users): _identicon_store = get_config_server_identicon_store() if _identicon_store == None: logging.error("no identicon_store configed") return None if len(_users) == 0: return None _icon_list = [] for _uuid in _users: _user_key = DeviceUser.__tablename__ + ".uuid." + _uuid _user_icon = _redis.hget(_user_key, "user_icon") if _user_icon == None: _icon_list.append(_user_icon) continue _file_key = FileInfo.__tablename__ + ".uuid." + _user_icon _file_path = _redis.hget(_file_key, "file_path") _icon_list.append(_file_path) _data = ImageConverter.conversation_icon(_icon_list) if _data == None: logging.error("conversation icon data is None, will not create icon file") return None _file_name = hashlib.sha1("".join(_users)).hexdigest() + ".png" _file_path = _identicon_store + os.path.sep + _file_name _file = open(_file_path, "wb") _file.write(_data) _file.close() return _icon_url(_file_name)
def create_group_icon(_redis, _users): if len(_users) == 0: return None _icon_list = [] for _uuid in _users: _user_key = DeviceUser.__tablename__ + ".uuid." + _uuid _user_icon = _redis.hget(_user_key, "user_icon") if _user_icon == None: _icon_list.append(_user_icon) continue _file_key = FileInfo.__tablename__ + ".uuid." + _user_icon _file_path = _redis.hget(_file_key, "file_path") _icon_list.append(_file_path) _data = ImageConverter.conversation_icon(_icon_list) if _data == None: logging.error( "conversation icon data is None, will not create icon file") return None _file_name = hashlib.sha1("".join(_users)).hexdigest() + ".png" _identicon_store = BOOTSTRAP_DATA.get("server").get("identicon_store") _file_path = _identicon_store + os.path.sep + _file_name _file = open(_file_path, "wb") _file.write(_data) _file.close() return _icon_url(_file_name)
def create_group_icon(_redis, _users): _identicon_store = get_config_server_identicon_store() if _identicon_store == None: logging.error("no identicon_store configed") return None if len(_users) == 0: return None if len(_users) == 1: _user_key = DeviceUser.__tablename__ + ".uuid." + list(_users)[0] _user_icon = _redis.hget(_user_key, "user_icon") if _user_icon == None: return _icon_url("default_icon.png") return _user_icon _icon_list = [] for _uuid in _users: _user_key = DeviceUser.__tablename__ + ".uuid." + _uuid _user_icon = _redis.hget(_user_key, "user_icon") if _user_icon != None: _icon_list.append(_user_icon) else: _icon_list.append(_icon_url("default_icon.png")) _icon_list = map(_url2local, _icon_list) _data = ImageConverter.conversation_icon(_icon_list) if _data == None: logging.error( "conversation icon data is None, will not create icon file") return None _file_name = hashlib.sha1("".join(_users)).hexdigest() + ".png" _file_path = _identicon_store + os.path.sep + _file_name _file = open(_file_path, "wb") _file.write(_data) _file.close() return _icon_url(_file_name)