|
5 | 5 | import os
|
6 | 6 | import re
|
7 | 7 | import time
|
| 8 | +from typing import cast |
8 | 9 |
|
| 10 | +import requests |
9 | 11 | from bs4 import BeautifulSoup
|
10 | 12 | from deprecated import deprecated
|
11 |
| -import requests |
12 | 13 | from requests import HTTPError
|
13 | 14 |
|
14 | 15 | from atlassian import utils
|
| 16 | + |
15 | 17 | from .errors import (
|
16 | 18 | ApiConflictError,
|
17 | 19 | ApiError,
|
@@ -1644,7 +1646,7 @@ def set_page_label(self, page_id, label):
|
1644 | 1646 |
|
1645 | 1647 | return response
|
1646 | 1648 |
|
1647 |
| - def remove_page_label(self, page_id, label): |
| 1649 | + def remove_page_label(self, page_id: str, label: str): |
1648 | 1650 | """
|
1649 | 1651 | Delete Confluence page label
|
1650 | 1652 | :param page_id: content_id format
|
@@ -2740,13 +2742,13 @@ def get_space_export(self, space_key: str, export_type: str) -> str:
|
2740 | 2742 | :return: The URL to download the exported file.
|
2741 | 2743 | """
|
2742 | 2744 |
|
2743 |
| - def get_atl_request(url: str): |
| 2745 | + def get_atl_request(link: str): |
2744 | 2746 | # Nested function used to get atl_token used for XSRF protection.
|
2745 | 2747 | # This is only applicable to html/csv/xml space exports
|
2746 | 2748 | try:
|
2747 |
| - response = self.get(url, advanced_mode=True) |
| 2749 | + response = self.get(link, advanced_mode=True) |
2748 | 2750 | parsed_html = BeautifulSoup(response.text, "html.parser")
|
2749 |
| - atl_token = parsed_html.find("input", {"name": "atl_token"}).get("value") |
| 2751 | + atl_token = parsed_html.find("input", {"name": "atl_token"}).get("value") # type: ignore[union-attr] |
2750 | 2752 | return atl_token
|
2751 | 2753 | except Exception as e:
|
2752 | 2754 | raise ApiError("Problems with getting the atl_token for get_space_export method :", reason=e)
|
@@ -2798,17 +2800,17 @@ def get_atl_request(url: str):
|
2798 | 2800 | parsed_html = BeautifulSoup(response.text, "html.parser")
|
2799 | 2801 | # Getting the poll URL to get the export progress status
|
2800 | 2802 | try:
|
2801 |
| - poll_url = parsed_html.find("meta", {"name": "ajs-pollURI"}).get("content") |
| 2803 | + poll_url = cast("str", parsed_html.find("meta", {"name": "ajs-pollURI"}).get("content")) # type: ignore[union-attr] |
2802 | 2804 | except Exception as e:
|
2803 | 2805 | raise ApiError("Problems with getting the poll_url for get_space_export method :", reason=e)
|
2804 | 2806 | running_task = True
|
2805 | 2807 | while running_task:
|
2806 | 2808 | try:
|
2807 |
| - progress_response = self.get(poll_url) |
2808 |
| - log.info("Space" + space_key + " export status: " + progress_response["message"]) |
2809 |
| - if progress_response["complete"]: |
2810 |
| - parsed_html = BeautifulSoup(progress_response["message"], "html.parser") |
2811 |
| - download_url = parsed_html.find("a", {"class": "space-export-download-path"}).get("href") |
| 2809 | + progress_response = self.get(poll_url) or {} |
| 2810 | + log.info(f"Space {space_key} export status: {progress_response.get('message', 'None')}") |
| 2811 | + if progress_response is not {} and progress_response.get("complete"): |
| 2812 | + parsed_html = BeautifulSoup(progress_response.get("message"), "html.parser") |
| 2813 | + download_url = cast("str", parsed_html.find("a", {"class": "space-export-download-path"}).get("href")) # type: ignore |
2812 | 2814 | if self.url in download_url:
|
2813 | 2815 | return download_url
|
2814 | 2816 | else:
|
|
0 commit comments