File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change 2222if TYPE_CHECKING :
2323 from planemo .cli import PlanemoCliContext
2424
25+ REQUEST_TIMEOUT = 5
26+
2527
2628def build_lint_args (ctx : "PlanemoCliContext" , ** kwds ) -> Dict [str , Any ]:
2729 """Handle common report, error, and skip linting arguments."""
@@ -134,20 +136,15 @@ def _validate_doi_url(url, lint_ctx):
134136
135137 doi = match .group (1 )
136138 xref_url = f"https://api.crossref.org/works/{ doi } "
137- try :
138- requests .get (xref_url , timeout = 5 )
139- return True
140- except Exception as e :
141- lint_ctx .error (f"Error '{ e } ' accessing { url } " )
142- return False
139+ return _validate_http_url (xref_url , lint_ctx = lint_ctx )
143140
144141
145142def _validate_http_url (url , lint_ctx , user_agent = None ):
146143 """Validate HTTP/HTTPS URL."""
147144 headers = {"User-Agent" : user_agent , "Accept" : "*/*" } if user_agent else None
148145 r = None
149146 try :
150- r = requests .get (url , headers = headers , stream = True )
147+ r = requests .get (url , headers = headers , stream = True , timeout = REQUEST_TIMEOUT )
151148 r .raise_for_status ()
152149 next (r .iter_content (1000 ))
153150 return True
You can’t perform that action at this time.
0 commit comments