Created
March 15, 2011 19:10
-
-
Save tobami/871255 to your computer and use it in GitHub Desktop.
codespeed/tools/save_single_result.py with exception catching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
f = urllib2.urlopen(SPEEDURL + 'result/add/', params) | |
response = f.read() | |
f.close() | |
except urllib2.URLError, e: | |
if hasattr(e, 'reason'): | |
response = '\n We failed to reach a server\n' | |
response += ' Reason: ' + str(e.reason) | |
elif hasattr(e, 'code'): | |
response = '\n The server couldn\'t fulfill the request\n' | |
response += ' Error code: ' + str(e) | |
print "Server (%s) response: %s\n" % (SPEEDURL, response) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment