From e8193afedfc95995b40f80fe261a9a4212e01d9e Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Mon, 2 Jul 2018 22:53:07 +0300 Subject: [PATCH] fixes after revert --- .gitignore | 2 ++ toxygen/contacts/common.py | 20 ++++++++++---------- toxygen/file_transfers/file_transfers.py | 7 ++----- toxygen/user_data/profile_manager.py | 2 +- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index f31ca4c..0a8182a 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ html Toxygen.egg-info *.tox .cache +*.db + diff --git a/toxygen/contacts/common.py b/toxygen/contacts/common.py index b37c6a2..4dc25e8 100644 --- a/toxygen/contacts/common.py +++ b/toxygen/contacts/common.py @@ -25,15 +25,15 @@ class FriendTypingNotificationHandler(BaseTypingNotificationHandler): BaseTypingNotificationHandler.DEFAULT_HANDLER = BaseTypingNotificationHandler() -def generate_avatar(tox_id): - foreground = ["rgb(45,79,255)", - "rgb(254,180,44)", - "rgb(226,121,234)", - "rgb(30,179,253)", - "rgb(232,77,65)", - "rgb(49,203,115)", - "rgb(141,69,170)"] - generator = Generator(5, 5, foreground=foreground, background="rgba(42,42,42,0)") - identicon = generator.generate(tox_id, 220, 220, padding=(10, 10, 10, 10)) +def generate_avatar(public_key): + foreground = ['rgb(45,79,255)', 'rgb(185, 66, 244)', 'rgb(185, 66, 244)', + 'rgb(254,180,44)', 'rgb(252, 2, 2)', 'rgb(109, 198, 0)', + 'rgb(226,121,234)', 'rgb(130, 135, 124)', + 'rgb(30,179,253)', 'rgb(160, 157, 0)', + 'rgb(232,77,65)', 'rgb(102, 4, 4)', + 'rgb(49,203,115)', + 'rgb(141,69,170)'] + generator = Generator(5, 5, foreground=foreground, background='rgba(42,42,42,0)') + identicon = generator.generate(public_key, 220, 220, padding=(10, 10, 10, 10)) return identicon diff --git a/toxygen/file_transfers/file_transfers.py b/toxygen/file_transfers/file_transfers.py index 61a379f..c2d1168 100644 --- a/toxygen/file_transfers/file_transfers.py +++ b/toxygen/file_transfers/file_transfers.py @@ -50,9 +50,6 @@ class FileTransfer: self._finished_event = Event() self._file_id = self._file = None - def set_tox(self, tox): - self._tox = tox - def set_state_changed_handler(self, handler): self._state_changed_event += handler @@ -344,11 +341,11 @@ class ReceiveAvatar(ReceiveTransfer): self.send_control(TOX_FILE_CONTROL['RESUME']) def write_chunk(self, position, data): - super().write_chunk(position, data) - if self.state: + if data is None: avatar_path = self._path[:-4] if exists(avatar_path): chdir(dirname(avatar_path)) remove(avatar_path) rename(self._path, avatar_path) self._finished() + super().write_chunk(position, data) diff --git a/toxygen/user_data/profile_manager.py b/toxygen/user_data/profile_manager.py index 6643d68..3324fce 100644 --- a/toxygen/user_data/profile_manager.py +++ b/toxygen/user_data/profile_manager.py @@ -13,7 +13,7 @@ class ProfileManager: self._path = path self._directory = os.path.dirname(path) # create /avatars if not exists: - avatars_directory = util.join_path(Settings.get_default_path(), 'avatars') + avatars_directory = util.join_path(self._directory, 'avatars') if not os.path.exists(avatars_directory): os.makedirs(avatars_directory)