File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77from django .core .management import BaseCommand
88from django .db .models import Q
99from django .utils import timezone
10- from requests .exceptions import Timeout
10+ from requests .exceptions import ConnectionError , Timeout
1111
1212from donations .models .ngos import Ngo
1313from donations .workers .check_organization import cult_registry_check_organizations
Original file line number Diff line number Diff line change 55from django .conf import settings
66from django .utils import timezone
77from django_q .tasks import async_task
8- from requests .exceptions import Timeout
8+ from requests .exceptions import ConnectionError , Timeout
99
1010from donations .models .ngos import Ngo
1111from utils .helper_logging import setup_logger
Original file line number Diff line number Diff line change 1616from ngohub .models .organization import Organization , OrganizationGeneral
1717from pycognito import Cognito
1818from requests import Response
19- from requests .exceptions import Timeout
19+ from requests .exceptions import ConnectionError , Timeout
2020
2121from donations .common .validation .validate_slug import NgoSlugValidator
2222from donations .models .common import CommonFilenameCacheModel
@@ -62,17 +62,21 @@ def _copy_file_to_object_with_filename_cache(
6262 return None
6363
6464 failed = False
65+ error_code = ""
6566 try :
6667 r : Response = requests .get (signed_file_url , timeout = 20 )
6768 except Timeout :
6869 failed = True
69- r = None
70+ error_code = "Connection Timeout"
71+ except ConnectionError :
72+ failed = True
73+ error_code = "Connection Error"
7074 else :
7175 if r .status_code != requests .codes .ok :
76+ error_code = r .status_code
7277 failed = True
7378
7479 if failed :
75- error_code = r .status_code if r else "TIMEOUT"
7680 logger .info ("%s file request status = %s" , attribute_name .upper (), error_code )
7781 error_message = f"ERROR: Could not download { attribute_name } file from NGO Hub, error status { error_code } ."
7882 logger .warning (error_message )
You can’t perform that action at this time.
0 commit comments