21
21
import parse
22
22
23
23
import github as pygithub
24
- from adabot import github_requests as gh_reqs
24
+ from adabot import github_requests as gh_reqs , REQUESTS_TIMEOUT
25
25
from adabot .lib import common_funcs
26
26
from adabot .lib import assign_hacktober_label as hacktober
27
27
@@ -231,7 +231,7 @@ def rtd_yml_base(self):
231
231
"%20if%20cookiecutter.sphinx_docs%20in%20%5B'y'%2C%20'yes'%5D%20%25"
232
232
"%7D.readthedocs.yaml%7B%25%20endif%20%25%7D"
233
233
)
234
- rtd_yml = requests .get (rtd_yml_dl_url )
234
+ rtd_yml = requests .get (rtd_yml_dl_url , timeout = REQUESTS_TIMEOUT )
235
235
if rtd_yml .ok :
236
236
try :
237
237
self ._rtd_yaml_base = yaml .safe_load (rtd_yml .text )
@@ -255,7 +255,7 @@ def pcc_versions(self):
255
255
"circuitpython/main/%7B%7B%20cookiecutter.__dirname%20%7D%7D/.pre-"
256
256
"commit-config.yaml"
257
257
)
258
- pcc_yml = requests .get (pcc_yml_dl_url )
258
+ pcc_yml = requests .get (pcc_yml_dl_url , timeout = REQUESTS_TIMEOUT )
259
259
if pcc_yml .ok :
260
260
try :
261
261
pcc_yaml_base = yaml .safe_load (pcc_yml .text )
@@ -463,7 +463,7 @@ def _filter_file_diffs(filenames):
463
463
def _validate_readme (self , download_url ):
464
464
# We use requests because file contents are hosted by
465
465
# githubusercontent.com, not the API domain.
466
- contents = requests .get (download_url , timeout = 30 )
466
+ contents = requests .get (download_url , timeout = REQUESTS_TIMEOUT )
467
467
if not contents .ok :
468
468
return [ERROR_README_DOWNLOAD_FAILED ]
469
469
@@ -509,7 +509,7 @@ def _validate_py_for_u_modules(self, download_url):
509
509
"""
510
510
# We use requests because file contents are hosted by
511
511
# githubusercontent.com, not the API domain.
512
- contents = requests .get (download_url , timeout = 30 )
512
+ contents = requests .get (download_url , timeout = REQUESTS_TIMEOUT )
513
513
if not contents .ok :
514
514
return [ERROR_PYFILE_DOWNLOAD_FAILED ]
515
515
@@ -547,7 +547,7 @@ def _validate_actions_build_yml(self, actions_build_info):
547
547
"""
548
548
549
549
download_url = actions_build_info ["download_url" ]
550
- contents = requests .get (download_url , timeout = 30 )
550
+ contents = requests .get (download_url , timeout = REQUESTS_TIMEOUT )
551
551
if not contents .ok :
552
552
return [ERROR_PYFILE_DOWNLOAD_FAILED ]
553
553
@@ -557,7 +557,7 @@ def _validate_actions_build_yml(self, actions_build_info):
557
557
558
558
def _validate_pre_commit_config_yaml (self , file_info ):
559
559
download_url = file_info ["download_url" ]
560
- contents = requests .get (download_url , timeout = 30 )
560
+ contents = requests .get (download_url , timeout = REQUESTS_TIMEOUT )
561
561
if not contents .ok :
562
562
return [ERROR_PYFILE_DOWNLOAD_FAILED ]
563
563
@@ -594,15 +594,15 @@ def _validate_pre_commit_config_yaml(self, file_info):
594
594
def _validate_pyproject_toml (self , file_info ):
595
595
"""Check pyproject.toml for pypi compatibility"""
596
596
download_url = file_info ["download_url" ]
597
- contents = requests .get (download_url , timeout = 30 )
597
+ contents = requests .get (download_url , timeout = REQUESTS_TIMEOUT )
598
598
if not contents .ok :
599
599
return [ERROR_TOMLFILE_DOWNLOAD_FAILED ]
600
600
return []
601
601
602
602
def _validate_requirements_txt (self , repo , file_info , check_blinka = True ):
603
603
"""Check requirements.txt for pypi compatibility"""
604
604
download_url = file_info ["download_url" ]
605
- contents = requests .get (download_url , timeout = 30 )
605
+ contents = requests .get (download_url , timeout = REQUESTS_TIMEOUT )
606
606
if not contents .ok :
607
607
return [ERROR_PYFILE_DOWNLOAD_FAILED ]
608
608
@@ -717,7 +717,9 @@ def validate_contents(self, repo):
717
717
if ".readthedocs.yaml" in files :
718
718
filename = ".readthedocs.yaml"
719
719
file_info = content_list [files .index (filename )]
720
- rtd_contents = requests .get (file_info ["download_url" ])
720
+ rtd_contents = requests .get (
721
+ file_info ["download_url" ], timeout = REQUESTS_TIMEOUT
722
+ )
721
723
if rtd_contents .ok :
722
724
try :
723
725
rtd_yml = yaml .safe_load (rtd_contents .text )
@@ -735,7 +737,9 @@ def validate_contents(self, repo):
735
737
if len (self ._pcc_versions ) or self .pcc_versions != "" :
736
738
filename = ".pre-commit-config.yaml"
737
739
file_info = content_list [files .index (filename )]
738
- pcc_contents = requests .get (file_info ["download_url" ])
740
+ pcc_contents = requests .get (
741
+ file_info ["download_url" ], timeout = REQUESTS_TIMEOUT
742
+ )
739
743
if pcc_contents .ok :
740
744
try :
741
745
pcc_yml = yaml .safe_load (pcc_contents .text )
@@ -888,7 +892,8 @@ def validate_readthedocs(self, repo):
888
892
return []
889
893
if not self .rtd_subprojects :
890
894
rtd_response = requests .get (
891
- "https://readthedocs.org/api/v2/project/74557/subprojects/" , timeout = 15
895
+ "https://readthedocs.org/api/v2/project/74557/subprojects/" ,
896
+ timeout = REQUESTS_TIMEOUT ,
892
897
)
893
898
if not rtd_response .ok :
894
899
return [ERROR_RTD_SUBPROJECT_FAILED ]
@@ -937,7 +942,7 @@ def validate_readthedocs(self, repo):
937
942
url = f"https://readthedocs.org/api/v3/projects/{ rtd_slug } /builds/"
938
943
rtd_token = os .environ ["RTD_TOKEN" ]
939
944
headers = {"Authorization" : f"token { rtd_token } " }
940
- response = requests .get (url , headers = headers )
945
+ response = requests .get (url , headers = headers , timeout = REQUESTS_TIMEOUT )
941
946
json_response = response .json ()
942
947
943
948
error_message = json_response .get ("detail" )
@@ -981,7 +986,7 @@ def validate_core_driver_page(self, repo):
981
986
"https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/"
982
987
"main/docs/drivers.rst"
983
988
),
984
- timeout = 15 ,
989
+ timeout = REQUESTS_TIMEOUT ,
985
990
)
986
991
if not driver_page .ok :
987
992
return [ERROR_DRIVERS_PAGE_DOWNLOAD_FAILED ]
0 commit comments