Skip to content

Commit f3a46ae

Browse files
authored
Merge pull request #1 from launchdarkly/drichelson/ch1741/python-release-python-2-6-compatible-sdk
Make all code Python2.6 compatible. Add documentation, package manager support.
2 parents c7f75fb + bc64bca commit f3a46ae

15 files changed

+65
-17
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to the LaunchDarkly Python SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
44

5+
## [4.0.2] - 2017-03-13
6+
### Added
7+
- Support for Python 2.6.
8+
59
## [4.0.1] - 2017-01-10
610
### Changed
711
- RedisFeatureStore now returns default when Redis errors occur

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ Your first feature flag
3333
else:
3434
# the code to run if the feature is off
3535

36+
Python 2.6
37+
----------
38+
Python 2.6 is supported for polling mode only and requires an extra dependency. Here's how to set it up:
39+
40+
1. Use the `python2.6` extra in your requirements.txt:
41+
`ldclient-py[python2.6]`
42+
43+
1. Due to Python 2.6's lack of SNI support, LaunchDarkly's streaming flag updates are not available. Set the `stream=False` option in the client config to disable it. You'll still receive flag updates, but via a polling mechanism with efficient caching. Here's an example:
44+
`config = ldclient.Config(stream=False, sdk_key="SDK_KEY")`
45+
46+
3647
Twisted
3748
-------
3849
Twisted is supported for LDD mode only. To run in Twisted/LDD mode,

circle.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@ machine:
33
- redis
44
dependencies:
55
pre:
6+
- pyenv shell 2.6.6; $(pyenv which pip) install --upgrade pip setuptools
67
- pyenv shell 2.7.10; $(pyenv which pip) install --upgrade pip setuptools
78
- pyenv shell 3.3.3; $(pyenv which pip) install --upgrade pip setuptools
89
- pyenv shell 3.4.2; $(pyenv which pip) install --upgrade pip setuptools
910

11+
- pyenv shell 2.6.6; $(pyenv which pip) install -r python2.6-requirements.txt
12+
- pyenv shell 2.6.6; $(pyenv which pip) install -r test-requirements.txt
1013
- pyenv shell 2.7.10; $(pyenv which pip) install -r test-requirements.txt
1114
- pyenv shell 3.3.3; $(pyenv which pip) install -r test-requirements.txt
1215
- pyenv shell 3.4.2; $(pyenv which pip) install -r test-requirements.txt
1316

17+
- pyenv shell 2.6.6; $(pyenv which python) setup.py install
1418
- pyenv shell 2.7.10; $(pyenv which python) setup.py install
1519
- pyenv shell 3.3.3; $(pyenv which python) setup.py install
1620
- pyenv shell 3.4.2; $(pyenv which python) setup.py install
1721

1822
test:
1923
override:
24+
- pyenv shell 2.6.6; $(pyenv which py.test) testing
2025
- pyenv shell 2.7.10; $(pyenv which py.test) testing
2126
- pyenv shell 3.3.3; $(pyenv which py.test) -s testing
2227
- pyenv shell 3.4.2; $(pyenv which py.test) -s testing

ldclient/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def cb(all_flags):
217217
return self._store.all(cb)
218218

219219
def _evaluate_multi(self, user, flags):
220-
return {k: self._evaluate(v, user)[0] for k, v in flags.items() or {}}
220+
return dict([(k, self._evaluate(v, user)[0]) for k, v in flags.items() or {}])
221221

222222
def secure_mode_hash(self, user):
223223
if user.get('key') is None or self._config.sdk_key is None:

ldclient/feature_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def upsert(self, key, feature):
6060
f = self._features.get(key)
6161
if f is None or f['version'] < feature['version']:
6262
self._features[key] = feature
63-
log.debug("Updated feature {} to version {}".format(key, feature['version']))
63+
log.debug("Updated feature {0} to version {1}".format(key, feature['version']))
6464
finally:
6565
self._lock.unlock()
6666

ldclient/redis_feature_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self,
2323
expiration=15,
2424
capacity=1000):
2525

26-
self._features_key = "{}:features".format(prefix)
26+
self._features_key = "{0}:features".format(prefix)
2727
self._cache = ForgetfulDict() if expiration == 0 else ExpiringDict(max_len=capacity,
2828
max_age_seconds=expiration)
2929
self._pool = redis.ConnectionPool.from_url(url=url, max_connections=max_connections)

ldclient/streaming.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def initialized(self):
5858

5959
@staticmethod
6060
def process_message(store, requester, msg, ready):
61-
log.debug("Received stream event {} with data: {}".format(msg.event, msg.data))
61+
log.debug("Received stream event {0} with data: {1}".format(msg.event, msg.data))
6262
if msg.event == 'put':
6363
payload = json.loads(msg.data)
6464
store.init(payload)

ldclient/twisted_redis_feature_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self,
2323
parsed_url = urlparse.urlparse(url)
2424
self._redis_host = parsed_url.hostname
2525
self._redis_port = parsed_url.port
26-
self._features_key = "{}:features".format(redis_prefix)
26+
self._features_key = "{0}:features".format(redis_prefix)
2727
self._cache = ForgetfulDict() if expiration == 0 else ExpiringDict(max_len=capacity,
2828
max_age_seconds=expiration)
2929
log.info("Created TwistedRedisFeatureStore with url: " + url + " using key: " + self._features_key)

ldclient/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _headers(sdk_key):
3838

3939
def _stream_headers(sdk_key, client="PythonClient"):
4040
return {'Authorization': sdk_key,
41-
'User-Agent': '{}/{}'.format(client, VERSION),
41+
'User-Agent': '{0}/{1}'.format(client, VERSION),
4242
'Cache-Control': 'no-cache',
4343
'Accept': "text/event-stream"}
4444

ldclient/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = "4.0.1"
1+
VERSION = "4.0.2"

0 commit comments

Comments
 (0)