Skip to content

Commit 0761571

Browse files
committed
Shuffle exceptions and code around
1 parent d820c68 commit 0761571

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

check_urls.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ def get_url_status(url, timeout, retries):
8585
return (clean_url, response.status_code)
8686
except requests.exceptions.Timeout:
8787
return (clean_url, 504)
88-
except requests.exceptions.ConnectionError:
89-
return (clean_url, -1)
9088
except requests.exceptions.TooManyRedirects:
89+
return (clean_url, -301)
90+
except requests.exceptions.ConnectionError:
9191
return (clean_url, -1)
9292

9393

9494
def bad_url(url_status):
95-
if url_status == -1:
95+
if url_status == -301 or url_status == -1:
9696
return True
9797
elif url_status == 401 or url_status == 403:
9898
return False
@@ -136,7 +136,10 @@ def main():
136136
for url_path, url_status in run_workers(
137137
get_url_status, all_urls.keys(),
138138
threads=args.threads, timeout=args.timeout, retries=args.retries):
139-
output = f'Currently checking: id={url_id} host={urllib3.util.parse_url(url_path).host}'
139+
output = (
140+
f'Currently checking: id={url_id} '
141+
f'host={urllib3.util.parse_url(url_path).host}'
142+
)
140143
if max_strlen < len(output):
141144
max_strlen = len(output)
142145
print(output.ljust(max_strlen), end='\r')

0 commit comments

Comments
 (0)