Fixed urllib3.exceptions.NewConnectionError #173

This commit is contained in:
Dimitris Zlatanidis 2023-06-06 21:43:02 +03:00
parent bb2ace44d2
commit 32ef50708a
2 changed files with 12 additions and 2 deletions

View file

@ -1,3 +1,7 @@
4.8.9 - 06/06/2023
Fixed
- urllib3.exceptions.NewConnectionError (Thanks to rizitis) #173
4.8.8 - 29/05/2023
Updated:
- France manpage

View file

@ -3,6 +3,7 @@
import os
import logging
import requests
from pathlib import Path
from multiprocessing import Process
from urllib3 import PoolManager, ProxyManager, make_headers
@ -90,6 +91,7 @@ class CheckUpdates(Configs):
def compare_the_changelogs(self, local_chg_txt: Path, repo_chg_txt: str) -> bool:
local_size: int = 0
repo_size: int = 0
if self.proxy_address.startswith('http'):
self.set_http_proxy_server()
@ -98,13 +100,17 @@ class CheckUpdates(Configs):
self.set_socks_proxy_server()
try:
requests.get(repo_chg_txt, timeout=2)
repo = self.http.request('GET', repo_chg_txt)
if local_chg_txt.is_file():
local_size: int = int(os.stat(local_chg_txt).st_size)
except KeyboardInterrupt:
raise SystemExit(1)
repo_size: int = int(repo.headers['Content-Length'])
except requests.exceptions.RequestException:
print(f'\n\n{self.endc}{self.prog_name}: {self.bred}Error:{self.endc} '
f'Failed to connect to {repo_chg_txt}\n')
else:
repo_size: int = int(repo.headers['Content-Length'])
logger = logging.getLogger(LoggingConfig.date_time)
logger.info(f'{self.__class__.__name__}: '