File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77from src .parser import parse_file
88
9+ EXIT_STATUS = 0
10+
911
1012def link_status (link ):
1113 """Check link status
@@ -18,9 +20,9 @@ def link_status(link):
1820 """
1921
2022 try :
21- status_code = requests .get (link , timeout = 3 ).status_code
23+ status_code = requests .get (link , timeout = 5 ).status_code
2224 except requests .exceptions .SSLError :
23- status_code = requests .get (link , verify = False , timeout = 3 ).status_code
25+ status_code = requests .get (link , verify = False , timeout = 5 ).status_code
2426 except Exception : # noqa
2527 # TODO: include exception in logging
2628 status_code = None
@@ -54,18 +56,26 @@ def main(source):
5456
5557 for link in links :
5658 for url in link .urls :
57- status , code = link_status (url )
59+ # try two time at least
60+ for _ in range (2 ):
61+ status , code = link_status (url )
62+ if status :
63+ break
5864
5965 if status :
6066 fg = "green"
6167 icon = "✓"
6268 else :
6369 fg = "red"
6470 icon = "✗"
71+ EXIT_STATUS = 1
72+
6573 click .echo (
6674 "{icon} L{ln} : {l}" .format (
6775 icon = click .style (icon , fg = fg , bold = True ),
6876 ln = link .line ,
6977 l = click .style (url , fg = fg ),
7078 )
7179 )
80+
81+ exit (EXIT_STATUS )
You can’t perform that action at this time.
0 commit comments