Permalink
Browse files

Works with python2.4.

  • Loading branch information...
1 parent ac5891e commit 9d1e35bb0d123b2be749df4bbbdbe4545a1a2d19 Jukka Ojaniemi committed Oct 15, 2011
Showing with 27 additions and 12 deletions.
  1. +4 −0 .gitignore
  2. +6 −3 setup.py
  3. +17 −9 src/buildout/sendpickedversions/__init__.py
View
4 .gitignore
@@ -0,0 +1,4 @@
+*.pyc
+*.egg-info
+build
+dist
View
9 setup.py
@@ -6,6 +6,11 @@
entry_point = 'buildout.sendpickedversions:install'
entry_points = {"zc.buildout.extension": ["default = %s" % entry_point]}
+requires=['setuptools','zc.buildout']
+try:
+ import json
+except:
+ requires.append('simplejson')
tests_require=['zc.buildout', 'zope.testing', 'zc.recipe.egg']
@@ -29,9 +34,7 @@
namespace_packages=['buildout'],
include_package_data=True,
zip_safe=False,
- install_requires=['setuptools',
- 'zc.buildout'
- ],
+ install_requires=requires,
tests_require=tests_require,
extras_require=dict(tests=tests_require),
test_suite = 'buildout.sendpickedversions.tests.test_suite',
View
26 src/buildout/sendpickedversions/__init__.py
@@ -1,5 +1,8 @@
import logging
-import json
+try:
+ import json
+except ImportError:
+ import simplejson as json
import urllib2
import zc.buildout.easy_install
import pkg_resources
@@ -33,7 +36,7 @@ def get_dist(self, requirement, ws, always_unzip):
return get_dist
-def send_picked_versions(old_logging_shutdown, wrw_url, buildout_name):
+def send_picked_versions(old_logging_shutdown, whiskers_url, buildout_name):
packages = []
def logging_shutdown():
@@ -51,7 +54,7 @@ def logging_shutdown():
data = dict(packages=packages, buildoutname=buildout_name)
print json.dumps(data)
- res = send_picked_versions_data(wrw_url, json.dumps(data))
+ res = send_picked_versions_data(whiskers_url, json.dumps(data))
if res:
print res
else:
@@ -60,19 +63,24 @@ def logging_shutdown():
old_logging_shutdown()
return logging_shutdown
-def send_picked_versions_data(wrw_url, data):
+def send_picked_versions_data(whiskers_url, data):
+ req = urllib2.Request(url=whiskers_url, data=data)
try:
- req = urllib2.Request(url=wrw_url, data=data)
h = urllib2.urlopen(req, timeout=5)
- return h
+ except TypeError, e:
+ # python2.4 doesn't support timeout
+ h = urllib2.urlopen(req)
except urllib2.URLError, e:
print str(e)
return None
+ else:
+ h = None
+ return h.msg or None
def install(buildout):
- wrw_url = 'requirements-mapper-url' in buildout['buildout'] and \
- buildout['buildout']['requirements-mapper-url'].strip() or \
+ whiskers_url = 'whiskers_url' in buildout['buildout'] and \
+ buildout['buildout']['whiskers_url'].strip() or \
None
buildout_name = 'buildoutname' in buildout['buildout'] and \
buildout['buildout']['buildoutname'].strip() or \
@@ -83,4 +91,4 @@ def install(buildout):
zc.buildout.easy_install.Installer._get_dist = enable_sending_picked_versions(
zc.buildout.easy_install.Installer._get_dist)
- logging.shutdown = send_picked_versions(logging.shutdown, wrw_url, buildout_name)
+ logging.shutdown = send_picked_versions(logging.shutdown, whiskers_url, buildout_name)

0 comments on commit 9d1e35b

Please sign in to comment.