def wb_update(wr_ws, status, i):
# build green and red style sheets for excel
green_st = xlwt.easyxf('pattern: pattern solid;')
green_st.pattern.pattern_fore_colour = 3
red_st = xlwt.easyxf('pattern: pattern solid;')
red_st.pattern.pattern_fore_colour = 2
yellow_st = xlwt.easyxf('pattern: pattern solid;')
yellow_st.pattern.pattern_fore_colour = 5
# if stanzas to catch the status code from the request
# and then input the appropriate information in the workbook
# this then writes the changes to the doc
if status == 200:
wr_ws.write(i, 1, 'Success (200)', green_st)
if status == 400:
print("Error 400 - Bad Request - ABORT!")
print("Probably have a bad URL or payload")
wr_ws.write(i, 1, 'Bad Request (400)', red_st)
pass
if status == 401:
print("Error 401 - Unauthorized - ABORT!")
print("Probably have incorrect credentials")
wr_ws.write(i, 1, 'Unauthorized (401)', red_st)
pass
if status == 403:
print("Error 403 - Forbidden - ABORT!")
print("Server refuses to handle your request")
wr_ws.write(i, 1, 'Forbidden (403)', red_st)
pass
if status == 404:
print("Error 404 - Not Found - ABORT!")
print("Seems like you're trying to POST to a page that doesn't"
" exist.")
wr_ws.write(i, 1, 'Not Found (400)', red_st)
pass
if status == 666:
print("Error - Something failed!")
print("The POST failed, see stdout for the exception.")
wr_ws.write(i, 1, 'Unkown Failure', yellow_st)
pass
if status == 667:
print("Error - Invalid Input!")
print("Invalid integer or other input.")
wr_ws.write(i, 1, 'Unkown Failure', yellow_st)
pass
评论列表
文章目录