Skip to content

Commit ab57c72

Browse files
committed
Additional PEP8 fixes (my IDE Line Length was set too high)
1 parent 1d2e315 commit ab57c72

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

Code-Sleep-Python/website_status_check/website_status_check.py

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@ def check_url(url):
88
r = requests.get(url) # added spacing for PEP8
99
return r.status_code
1010
except requests.ConnectionError:
11-
return 999 # added default code in case of failure in the requests library
11+
# added default code in case of failure in the requests library
12+
return 999
1213

1314

1415
def print_message(code):
15-
statusMessage = {
16+
status_message = {
1617
100: 'Website is slow to respond, but appears ok.',
1718
101: 'Server is upgrading to the requested protocol.',
1819
102: 'Request received, website has yet to respond.',
1920
200: "Website is online.",
2021
201: "The request has succeeded and a new resource has been created.",
2122
202: "The request has been received but not yet acted upon.",
22-
203: "Website returned meta-information from a copy of the origin server.",
23+
203: "Website returned meta-information from a copy of the server.",
2324
204: "There is no content to send for this request.",
2425
205: "Reset document view which sent this request.",
2526
206: "Separate download into multiple streams.",
@@ -29,54 +30,67 @@ def print_message(code):
2930
300: "Website has different choices and cannot be resolved into one.",
3031
301: "Website has been redirected permanently.",
3132
302: "Website has been redirected temporarily.",
32-
303: "Website sent this response to direct the client to get the requested resource at another URI.",
33+
303: "Website sent this response to direct the client to get the "
34+
"requested resource at another URI.",
3335
304: "Website cache has not been modified.",
3436
305: "Website requested response must be accessed by a proxy.",
3537
306: "Unused staus code, held for upcoming purpose",
3638
307: "Website has been redirected temporarily.",
3739
308: "Website has been redirected permanently.",
38-
400: "The request could not be understood by the server due to malformed syntax.",
40+
400: "The request could not be understood by the server due to "
41+
"malformed syntax.",
3942
401: "The request requires user authentication",
4043
402: "Website requires payment before serving responses.",
41-
403: "Forbidden. The server understood the request, but is refusing to fulfill it.",
44+
403: "Forbidden. The server understood the request, but is refusing "
45+
"to fulfill it.",
4246
404: "Website not found!",
43-
405: "The request method is known by the server but has been disabled and cannot be used.",
47+
405: "The request method is known by the server but has been "
48+
"disabled and cannot be used.",
4449
406: "No Content found!",
4550
407: "Website requires 3rd party authentication.",
4651
408: "Website request Timed out.",
4752
409: "Server conflict, please try again.",
4853
410: "Requested content has been permanently deleted from server.",
49-
411: 'Website rejected the request because the Content-Length header field is not defined.',
54+
411: 'Website rejected the request because the Content-Length header '
55+
'field is not defined.',
5056
412: "Website doesn't meet client preconditions.",
5157
413: "Request entity is larger than limits defined by server.",
5258
414: "The URI requested by the client is too long.",
53-
415: "The media format of the requested data is not supported by the server.",
54-
416: "The range specified by the Range header field in the request can't be fulfilled by the website.",
55-
417: "Data indicated by the Expect request header field can't be met by the server.",
59+
415: "The media format of the requested data is not supported by the "
60+
"server.",
61+
416: "The range specified by the Range header field in the request "
62+
"can't be fulfilled by the website.",
63+
417: "Data indicated by the Expect request header field can't be met "
64+
"by the server.",
5665
418: "The server refuses the attempt to brew coffee with a teapot.",
5766
421: "Website redirection failed.",
5867
422: "The request failed due to semantic errors.",
5968
423: "The resource that is being accessed is locked.",
6069
424: "The request failed due to failure of a previous request.",
61-
426: "The server refuses to perform the request using the current protocol.",
70+
426: "The server refuses to perform the request using the current "
71+
"protocol.",
6272
428: "Data update conflict.",
63-
429: "Website refused due to too many requests, please try again later.",
73+
429: "Website refused due to too many requests, please try again "
74+
"later.",
6475
431: "Request refused due to large size headers.",
6576
451: "Request refused due to legal reasons.",
6677
500: "Website is experiencing errors.",
6778
501: "Unsupported request.",
6879
502: "Website Gateway error.",
69-
503: "The web server is unable to handle your HTTP request at the time.",
80+
503: "The web server is unable to handle your HTTP request at the "
81+
"time.",
7082
504: "Gateway Timeout.",
7183
505: "HTTP Version Not Supported.",
7284
506: "The server has an internal configuration error.",
7385
507: "The server is out of space.",
74-
508: "The server went to infinity and beyond, but could not return your request.",
75-
510: "Further extensions to the request are required for the server to fulfill it.",
86+
508: "The server went to infinity and beyond, but could not return "
87+
"your request.",
88+
510: "Further extensions to the request are required for the server "
89+
"to fulfill it.",
7690
511: "Network Authentication Required.",
7791
999: 'Failed to connect.'
7892
}
79-
print(statusMessage[status])
93+
print(status_message[code])
8094

8195

8296
# added extra line for PEP8

0 commit comments

Comments
 (0)