From 970196b4be3bd7080392b264f6747206f7f267b3 Mon Sep 17 00:00:00 2001 From: Josef Kudera <46950237+kudj@users.noreply.github.com> Date: Thu, 13 Mar 2025 12:36:18 +0100 Subject: [PATCH 1/6] logging libraries --- .github/workflows/push.yml | 2 +- src/client/client.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index b8fe4fd..1f08098 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -47,7 +47,7 @@ jobs: echo "branch_name=$branch_name" | tee -a $GITHUB_OUTPUT else raw=$(git branch -r --contains ${{ github.ref }}) - branch="$(echo ${raw//origin\//} | tr -d '\n')" + branch="$(echo $raw | sed "s/.*origin\///" | tr -d '\n')" echo "branch_name=$branch" | tee -a $GITHUB_OUTPUT fi diff --git a/src/client/client.py b/src/client/client.py index 90c24f0..74f426c 100644 --- a/src/client/client.py +++ b/src/client/client.py @@ -235,6 +235,7 @@ def _get_sharepoint_folder_id_from_path(self, library_drive_id, folder_path): def _get_sharepoint_library_id(self, library_name): libraries = self._get_sharepoint_document_libraries() + logging.debug(f"Found libraries: {libraries}") library = next((lib for lib in libraries if lib['name'] == library_name), None) if library is None: library = next((lib for lib in libraries if lib['webUrl'].split("/")[-1] == library_name), None) From 11bb23ec7add233b46b8b3a9ba7a71e44f575348 Mon Sep 17 00:00:00 2001 From: Josef Kudera <46950237+kudj@users.noreply.github.com> Date: Thu, 13 Mar 2025 12:51:38 +0100 Subject: [PATCH 2/6] more debugging --- src/client/client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/client/client.py b/src/client/client.py index 74f426c..5d584a8 100644 --- a/src/client/client.py +++ b/src/client/client.py @@ -184,7 +184,9 @@ def _get_folder_contents_sharepoint(self, folder_path=None, library_name=None): if library_name: logging.info(f"The component will try to fetch files from library {library_name}") library_id = self._get_sharepoint_library_id(library_name) + logging.info(f"Library id: {library_id}") library_drive_id = self._get_sharepoint_library_drive_id(library_id) + logging.info(f"Library drive id: {library_drive_id}") if not folder_id: folder_id = self._get_sharepoint_folder_id_from_path(library_drive_id, folder_path) folder_path = self._make_library_folder_path(folder_id, library_drive_id) From 2c8cd8bef4e5fb4f9b8b05a3eb7569a223de139d Mon Sep 17 00:00:00 2001 From: Josef Kudera <46950237+kudj@users.noreply.github.com> Date: Thu, 13 Mar 2025 12:36:18 +0100 Subject: [PATCH 3/6] logging libraries --- src/client/client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/client.py b/src/client/client.py index 90c24f0..74f426c 100644 --- a/src/client/client.py +++ b/src/client/client.py @@ -235,6 +235,7 @@ def _get_sharepoint_folder_id_from_path(self, library_drive_id, folder_path): def _get_sharepoint_library_id(self, library_name): libraries = self._get_sharepoint_document_libraries() + logging.debug(f"Found libraries: {libraries}") library = next((lib for lib in libraries if lib['name'] == library_name), None) if library is None: library = next((lib for lib in libraries if lib['webUrl'].split("/")[-1] == library_name), None) From 1eb461de0aa2b64e832beeaeca9dcb18191e6c2f Mon Sep 17 00:00:00 2001 From: Josef Kudera <46950237+kudj@users.noreply.github.com> Date: Thu, 13 Mar 2025 12:51:38 +0100 Subject: [PATCH 4/6] more debugging --- src/client/client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/client/client.py b/src/client/client.py index 74f426c..5d584a8 100644 --- a/src/client/client.py +++ b/src/client/client.py @@ -184,7 +184,9 @@ def _get_folder_contents_sharepoint(self, folder_path=None, library_name=None): if library_name: logging.info(f"The component will try to fetch files from library {library_name}") library_id = self._get_sharepoint_library_id(library_name) + logging.info(f"Library id: {library_id}") library_drive_id = self._get_sharepoint_library_drive_id(library_id) + logging.info(f"Library drive id: {library_drive_id}") if not folder_id: folder_id = self._get_sharepoint_folder_id_from_path(library_drive_id, folder_path) folder_path = self._make_library_folder_path(folder_id, library_drive_id) From 502d5c12009425b439261f77aefb9de59efe8b05 Mon Sep 17 00:00:00 2001 From: ZdenekSrotyr Date: Wed, 2 Apr 2025 20:48:40 +0200 Subject: [PATCH 5/6] Freeze http lib add catch id key error --- requirements.txt | 3 +-- src/client/client.py | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index b9148ac..afbfa7c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ keboola.component==1.4.4 -keboola.http-client +keboola.http-client==1.0.0 mock~=5.0.1 freezegun~=1.2.2 -keboola.http-client backoff==2.2.1 dataconf==2.2.1 \ No newline at end of file diff --git a/src/client/client.py b/src/client/client.py index 5d584a8..52c29ca 100644 --- a/src/client/client.py +++ b/src/client/client.py @@ -250,7 +250,10 @@ def _get_sharepoint_library_drive_id(self, library_id): response = self.get_request(url, is_absolute_path=True) if response and response.status_code == 200: - return response.json()['id'] + try: + return response.json()['id'] + except KeyError: + raise OneDriveClientException(f"Error fetching library drive: {response.json()}") error_message = f"Error fetching library drive: {response.status_code}, {response.text}" \ if response else "Error fetching library drive: No response received" @@ -297,7 +300,7 @@ def _download_file_from_onedrive_url(self, url, output_path, filename): """ Downloads a file from OneDrive using the provided download URL and saves it to the specified output path. """ - with self.get_request(url, is_absolute_path=True, stream=True) as r: + with self.get_request(new_url, is_absolute_path=True, stream=True) as r: if r is None: self._handle_no_response(filename) From f51ac90d03c547be9f7fa22b51f9455bfad8d531 Mon Sep 17 00:00:00 2001 From: ZdenekSrotyr Date: Wed, 2 Apr 2025 20:51:50 +0200 Subject: [PATCH 6/6] fix typo --- src/client/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/client.py b/src/client/client.py index 52c29ca..81fe328 100644 --- a/src/client/client.py +++ b/src/client/client.py @@ -300,7 +300,7 @@ def _download_file_from_onedrive_url(self, url, output_path, filename): """ Downloads a file from OneDrive using the provided download URL and saves it to the specified output path. """ - with self.get_request(new_url, is_absolute_path=True, stream=True) as r: + with self.get_request(url, is_absolute_path=True, stream=True) as r: if r is None: self._handle_no_response(filename)