Added urllib configs

This commit is contained in:
Dimitris Zlatanidis 2024-01-21 22:36:17 +02:00
parent f4564f097b
commit 93cfd13622
3 changed files with 24 additions and 2 deletions

View file

@ -114,6 +114,14 @@ LFTP_MIRROR_OPTIONS = "-c mirror --parallel=100 --only-newer"
# from SBo and ponce repositories.
LFTP_EXCLUDE = "-X SLACKBUILDS.TXT.gz -X CHECKSUMS.md5.asc -X 'TAGS.txt*' -X '*.tar.gz*'"
# Python urllib3 settings used for checking between two changelog files.
# Timeouts allow you to control how long (in seconds) requests are allowed
# to run before being aborted. In simple cases, you can specify a timeout as a float.
# By default, urllib3 will retry requests 3 times and follow up to 3 redirects.
URLLIB_RETRIES = false
URLLIB_REDIRECT = false
URLLIB_TIMEOUT = 3.0
# If you are going to use a proxy server, try to fill in these variables.
# Choose between http or socks proxy type.
# For a sock proxy, you need to install the PySocks package.

View file

@ -31,7 +31,7 @@ class CheckUpdates(Configs):
self.compare: dict = {}
self.http = PoolManager()
self.http = PoolManager(timeout=self.urllib_timeout)
self.proxy_default_headers = make_headers(
proxy_basic_auth=f'{self.proxy_username}:{self.proxy_password}')
@ -107,7 +107,11 @@ class CheckUpdates(Configs):
local_size: int = int(os.stat(local_chg_txt).st_size)
try: # Get repository changelog file size.
repo = self.http.request('GET', repo_chg_txt)
repo = self.http.request(
'GET', repo_chg_txt,
retries=self.urllib_retries,
redirect=self.urllib_redirect
)
repo_size: int = int(repo.headers.get('content-length', 0))
except KeyboardInterrupt:
raise SystemExit(1)

View file

@ -3,6 +3,7 @@
import tomli
import platform
from typing import Any
from pathlib import Path
from dataclasses import dataclass
@ -52,6 +53,10 @@ class Configs:
case_sensitive: bool = True
process_log: bool = True
urllib_retries: Any = False
urllib_redirect: Any = False
urllib_timeout: float = 3.0
proxy_address: str = ''
proxy_username: str = ''
proxy_password: str = ''
@ -91,6 +96,11 @@ class Configs:
border_color: str = config['BORDER_COLOR']
case_sensitive: bool = config['CASE_SENSITIVE']
process_log: bool = config['PROCESS_LOG']
urllib_retries: Any = config['URLLIB_RETRIES']
urllib_redirect: Any = config['URLLIB_REDIRECT']
urllib_timeout: float = config['URLLIB_TIMEOUT']
proxy_address: str = config['PROXY_ADDRESS']
proxy_username: str = config['PROXY_USERNAME']
proxy_password: str = config['PROXY_PASSWORD']