From 74dddc31f27e87a55b94b295ab39e8c7822e5db6 Mon Sep 17 00:00:00 2001 From: Viktxrrr Date: Wed, 26 Feb 2025 23:17:18 +0700 Subject: [PATCH] [Jira, Confluence] Minor changes --- atlassian/confluence.py | 9 ++++++--- atlassian/jira.py | 10 ++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/atlassian/confluence.py b/atlassian/confluence.py index d296f3c35..c56660fd6 100644 --- a/atlassian/confluence.py +++ b/atlassian/confluence.py @@ -1470,8 +1470,7 @@ def download_attachments_from_page(self, page_id, path=None, start=0, limit=50, file_name = attachment["title"] or attachment["id"] # Use attachment ID if title is unavailable download_link = self.url + attachment["_links"]["download"] # Fetch the file content - response = self._session.get(str(download_link)) - response.raise_for_status() # Raise error if request fails + response = self.get(str(download_link)) if to_memory: # Store in BytesIO object @@ -1493,7 +1492,11 @@ def download_attachments_from_page(self, page_id, path=None, start=0, limit=50, except PermissionError: raise PermissionError("Permission denied when trying to save files to '{path}'.".format(path=path)) except requests.HTTPError as http_err: - raise Exception("HTTP error occurred while downloading attachments: {http_err}".format(http_err=http_err)) + raise requests.HTTPError( + "HTTP error occurred while downloading attachments: {http_err}".format(http_err=http_err), + response=http_err.response, + request=http_err.request + ) except Exception as err: raise Exception("An unexpected error occurred: {error}".format(error=err)) diff --git a/atlassian/jira.py b/atlassian/jira.py index e7603d17f..a94ec2aac 100644 --- a/atlassian/jira.py +++ b/atlassian/jira.py @@ -242,6 +242,16 @@ def get_attachment(self, attachment_id): url = "{base_url}/{attachment_id}".format(base_url=base_url, attachment_id=attachment_id) return self.get(url) + def download_issue_attachments(self, issue, path=None): + """ + Downloads all attachments from a Jira issue. + :param issue: The issue-key of the Jira issue + :param path: Path to directory where attachments will be saved. If None, current working directory will be used. + :return: A message indicating the result of the download operation. + """ + return self.download_attachments_from_issue(issue=issue, path=path, cloud=self.cloud) + + @deprecated(version="3.41.20", reason="Use download_issue_attachments instead") def download_attachments_from_issue(self, issue, path=None, cloud=True): """ Downloads all attachments from a Jira issue.