From 1ea8f834aa8aa03c520f594ebc642f06af563b34 Mon Sep 17 00:00:00 2001 From: Bishoy-at-pieces Date: Mon, 9 Sep 2024 17:47:04 +0300 Subject: [PATCH 1/3] add headers --- .github/workflows/release.yaml | 2 +- src/pieces_os_client/wrapper/basic_identifier/asset.py | 9 +++++---- src/pieces_os_client/wrapper/client.py | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2292705..88fe993 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -42,7 +42,7 @@ jobs: run: | echo "Version: ${{ steps.get_version.outputs.VERSION }}" poetry version ${{ steps.get_version.outputs.VERSION }} - sed -i "s/__version__ = .*/__version__ = \"${{ steps.get_version.outputs.VERSION }}\"/" __init__.py + sed -i "s/__version__ = .*/__version__ = \"${{ steps.get_version.outputs.VERSION }}\"/" src/pieces_os_client/__init__.py - name: Build and publish if: startsWith(github.ref, 'refs/tags/v') diff --git a/src/pieces_os_client/wrapper/basic_identifier/asset.py b/src/pieces_os_client/wrapper/basic_identifier/asset.py index e4c61a0..c7105b6 100644 --- a/src/pieces_os_client/wrapper/basic_identifier/asset.py +++ b/src/pieces_os_client/wrapper/basic_identifier/asset.py @@ -75,7 +75,7 @@ def raw_content(self) -> Optional[str]: return preview_raw or fragment_raw or '' @raw_content.setter - def raw_content(self, content: str) -> str: + def raw_content(self, content: str): """ Edit the original format of the asset. @@ -86,9 +86,10 @@ def raw_content(self, content: str) -> str: NotImplemented: If the asset is an image. """ format_api = AssetSnapshot.pieces_client.format_api - original = format_api.format_snapshot(self.asset.original.id, transferable=True) - if original.classification.generic == ClassificationGenericEnum.IMAGE: - raise NotImplemented("Can't edit an image yet") + if self.is_image: + original = self._get_ocr_format(self.asset) + else: + original = format_api.format_snapshot(self.asset.original.id, transferable=True) if original.fragment and original.fragment.string and original.fragment.string.raw: original.fragment.string.raw = content diff --git a/src/pieces_os_client/wrapper/client.py b/src/pieces_os_client/wrapper/client.py index 5d7a3dc..e441a70 100644 --- a/src/pieces_os_client/wrapper/client.py +++ b/src/pieces_os_client/wrapper/client.py @@ -63,6 +63,7 @@ def _startup(self) -> bool: self._is_started_runned = True self.tracked_application = self.connector_api.connect(seeded_connector_connection=self._seeded_connector).application + self.api_client.set_default_header("application",self.tracked_application.id) if self._connect_websockets: self.conversation_ws = ConversationWS(self) From 879db76645935150763b63426433f68ddb0b4c31 Mon Sep 17 00:00:00 2001 From: Bishoy Hany <167128903+Bishoy-at-pieces@users.noreply.github.com> Date: Mon, 9 Sep 2024 18:35:37 +0300 Subject: [PATCH 2/3] fix PermissionError in share when you logged in --- src/pieces_os_client/wrapper/basic_identifier/asset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pieces_os_client/wrapper/basic_identifier/asset.py b/src/pieces_os_client/wrapper/basic_identifier/asset.py index c7105b6..864d3f0 100644 --- a/src/pieces_os_client/wrapper/basic_identifier/asset.py +++ b/src/pieces_os_client/wrapper/basic_identifier/asset.py @@ -365,7 +365,7 @@ def _share(asset=None,seed=None): else: kwargs = {"seed" : seed} - user = BasicUser.user_profile + user = AssetSnapshot.pieces_client.user.user_profile if not user: raise PermissionError("You need to be logged in to generate a shareable link") From b51746ca914ed7f1eb5248ccc9a8f879b5a62493 Mon Sep 17 00:00:00 2001 From: Bishoy-at-pieces Date: Mon, 9 Sep 2024 18:51:59 +0300 Subject: [PATCH 3/3] fix attribute error --- src/pieces_os_client/wrapper/basic_identifier/user.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pieces_os_client/wrapper/basic_identifier/user.py b/src/pieces_os_client/wrapper/basic_identifier/user.py index 61eaf19..5c662a1 100644 --- a/src/pieces_os_client/wrapper/basic_identifier/user.py +++ b/src/pieces_os_client/wrapper/basic_identifier/user.py @@ -60,7 +60,7 @@ def logout(self): """ Logs the user out of the OS. """ - self.pieces_client.api_client.os_api.sign_out_of_os() + self.pieces_client.os_api.sign_out_of_os() def connect(self): """ @@ -84,7 +84,7 @@ def disconnect(self): if not self.user_profile: raise PermissionError("You must be logged in to use this feature") if self.user_profile.allocation: # Check if there is an allocation iterable - self.pieces_client.api_client.allocations_api.allocations_disconnect_cloud(self.user_profile.allocation) + self.pieces_client.allocations_api.allocations_disconnect_cloud(self.user_profile.allocation) @property def picture(self) -> Optional[str]: