File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed
Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change 5555from datetime import datetime , timezone
5656
5757import colorama
58- import requests
5958from box import Box
6059
6160import PyFunceble .cli .storage
6564from PyFunceble .converter .internal_url import InternalUrlConverter
6665from PyFunceble .helpers .dict import DictHelper
6766from PyFunceble .helpers .download import DownloadHelper
67+ from PyFunceble .helpers .exceptions import UnableToDownload
6868from PyFunceble .utils .version import VersionUtility
6969
7070
@@ -86,7 +86,7 @@ def get_upstream_version() -> Box:
8686 else True
8787 ),
8888 ).download_text ()
89- except requests . exceptions . RequestException :
89+ except UnableToDownload :
9090 response = "{}"
9191
9292 return Box (
Original file line number Diff line number Diff line change @@ -363,16 +363,21 @@ def download_text(
363363 :raise UnableToDownload: When could not unable to download the URL.
364364 """
365365
366- req = self .session .get (self .url , verify = self .certificate_validation )
366+ try :
367+ req = self .session .get (self .url , verify = self .certificate_validation )
367368
368- if req .status_code == 200 :
369- response = req .text
369+ if req .status_code == 200 :
370+ response = req .text
370371
371- if destination and isinstance (destination , str ):
372- FileHelper (destination ).write (req .text , overwrite = True )
372+ if destination and isinstance (destination , str ):
373+ FileHelper (destination ).write (req .text , overwrite = True )
373374
374- return response
375+ return response
375376
376- raise PyFunceble .helpers .exceptions .UnableToDownload (
377- f"{ req .url } (retries: { self .retries } | status code: { req .status_code } )"
378- )
377+ raise PyFunceble .helpers .exceptions .UnableToDownload (
378+ f"{ req .url } (retries: { self .retries } | status code: { req .status_code } )"
379+ )
380+ except requests .exceptions .RequestException as exception :
381+ raise PyFunceble .helpers .exceptions .UnableToDownload (
382+ f"{ self .url } (could not resolve?)"
383+ ) from exception
You can’t perform that action at this time.
0 commit comments