NOTE: The current preferred location for bug reports is the GitHub issue tracker.
Bug 835 - make build script work correctly with python 2.5
make build script work correctly with python 2.5
Status: RESOLVED FIXED
Product: Validator.nu
Classification: Unclassified
Component: General
HEAD
All All
: P2 normal
Assigned To: Michael[tm] Smith
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-05-17 16:20 CEST by Michael[tm] Smith
Modified: 2011-05-17 17:07 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael[tm] Smith 2011-05-17 16:20:51 CEST
The fix to the build script for bug 818 only works in a Python 2.6 environment, because it depends on on a 'timeout' argument to urllib2.urlopen(...), which is new in python 2.6. So it won't work in a python 2.5 environment.

The following patch fixes it.


diff -r b893eb8c0260 build.py
--- a/build.py	Sat Feb 12 20:51:26 2011 +0000
+++ b/build.py	Tue May 17 17:35:45 2011 +0900
@@ -25,6 +25,7 @@
 import shutil
 import httplib
 import urllib2
+import socket
 import re
 try:
   from hashlib import md5
@@ -643,14 +644,18 @@
   # I bet there's a way to do this with more efficient IO and less memory
   print url
   completed = False
+  defaultTimeout = socket.getdefaulttimeout()
   while not completed:
    try:
-    f = urllib2.urlopen(url, timeout=httpTimeoutSeconds)
+    socket.setdefaulttimeout(httpTimeoutSeconds)
+    f = urllib2.urlopen(url)
     data = f.read()
     f.close()
     completed = True
    except httplib.BadStatusLine, e:
     print "received error, retrying"
+   finally:
+    socket.setdefaulttimeout(defaultTimeout)
   if md5sum:
     m = md5(data)
     if md5sum != m.hexdigest():
Comment 1 Michael[tm] Smith 2011-05-17 17:07:16 CEST
https://bitbucket.org/validator/build/changeset/c395ef1f0c44