mirror of
https://github.com/miurahr/aqtinstall.git
synced 2025-12-18 21:24:38 +03:00
Check blacklist when downloading Update.xml
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
This commit is contained in:
@@ -24,8 +24,10 @@ import xml.etree.ElementTree as ElementTree
|
|||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
from requests.adapters import HTTPAdapter
|
||||||
|
from urllib3 import Retry
|
||||||
|
|
||||||
from aqt.helper import Settings
|
from aqt.helper import Settings, altlink
|
||||||
|
|
||||||
|
|
||||||
class ArchiveConnectionError(Exception):
|
class ArchiveConnectionError(Exception):
|
||||||
@@ -215,8 +217,17 @@ class QtArchives:
|
|||||||
self._parse_update_xml(archive_url, target_packages)
|
self._parse_update_xml(archive_url, target_packages)
|
||||||
|
|
||||||
def _download_update_xml(self, update_xml_url):
|
def _download_update_xml(self, update_xml_url):
|
||||||
|
with requests.Session() as session:
|
||||||
|
retry = Retry(connect=5, backoff_factor=0.5)
|
||||||
|
adapter = HTTPAdapter(max_retries=retry)
|
||||||
|
session.mount("http://", adapter)
|
||||||
|
session.mount("https://", adapter)
|
||||||
try:
|
try:
|
||||||
r = requests.get(update_xml_url, timeout=self.timeout)
|
r = requests.get(update_xml_url, allow_redirects=False, timeout=self.timeout)
|
||||||
|
if r.status_code == 302:
|
||||||
|
newurl = altlink(r.url, r.headers["Location"], logger=self.logger)
|
||||||
|
self.logger.info("Redirected URL: {}".format(newurl))
|
||||||
|
r = session.get(newurl, stream=True, timeout=self.timeout)
|
||||||
except (
|
except (
|
||||||
ConnectionResetError,
|
ConnectionResetError,
|
||||||
requests.exceptions.ConnectionError,
|
requests.exceptions.ConnectionError,
|
||||||
|
|||||||
Reference in New Issue
Block a user