Skip to content

Commit 874ea54

Browse files
prepare 6.10.2 release (#131)
1 parent 5030f71 commit 874ea54

File tree

14 files changed

+742
-379
lines changed

14 files changed

+742
-379
lines changed

.ldrelease/update-version.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/api-main.rst

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,28 @@ ldclient module
66

77
.. automodule:: ldclient
88
:members: get,set_config,set_sdk_key
9-
:show-inheritance:
109

1110
ldclient.client module
1211
----------------------
1312

1413
.. automodule:: ldclient.client
1514
:members: LDClient
16-
:special-members: __init__
17-
:show-inheritance:
1815

1916
ldclient.config module
2017
----------------------
2118

2219
.. automodule:: ldclient.config
2320
:members:
24-
:special-members: __init__
25-
:show-inheritance:
2621

2722
ldclient.flag module
2823
--------------------
2924

3025
.. automodule:: ldclient.flag
3126
:members: EvaluationDetail
32-
:special-members: __init__
33-
:show-inheritance:
3427

3528
ldclient.flags_state module
3629
---------------------------
3730

3831
.. automodule:: ldclient.flags_state
3932
:members:
40-
:show-inheritance:
33+
:exclude-members: __init__, add_flag

docs/conf.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@
167167
# -- Extension configuration -------------------------------------------------
168168

169169
autodoc_default_options = {
170-
'members': None,
171-
'show-inheritance': None,
172-
'special-members': None,
173-
'undoc-members': None
170+
'special-members': '__init__',
171+
'undoc-members': False
174172
}

ldclient/event_processor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ class EventDispatcher(object):
211211
def __init__(self, inbox, config, http_client):
212212
self._inbox = inbox
213213
self._config = config
214-
self._http = create_http_pool_manager(num_pools=1, verify_ssl=config.verify_ssl) if http_client is None else http_client
214+
self._http = create_http_pool_manager(num_pools=1, verify_ssl=config.verify_ssl,
215+
target_base_uri=config.events_uri) if http_client is None else http_client
215216
self._close_http = (http_client is None) # so we know whether to close it later
216217
self._disabled = False
217218
self._outbox = EventBuffer(config.events_max_pending)
@@ -388,5 +389,5 @@ def _post_message_and_wait(self, type):
388389
def __enter__(self):
389390
return self
390391

391-
def __exit__(self, tyep, value, traceback):
392+
def __exit__(self, type, value, traceback):
392393
self.stop()

ldclient/feature_requester.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
class FeatureRequesterImpl(FeatureRequester):
2626
def __init__(self, config):
2727
self._cache = dict()
28-
self._http = create_http_pool_manager(num_pools=1, verify_ssl=config.verify_ssl)
28+
self._http = create_http_pool_manager(num_pools=1, verify_ssl=config.verify_ssl, target_base_uri=config.base_uri)
2929
self._config = config
3030

3131
def get_all_data(self):
@@ -36,7 +36,7 @@ def get_all_data(self):
3636
}
3737

3838
def get_one(self, kind, key):
39-
return self._do_request(kind.request_api_path + '/' + key, False)
39+
return self._do_request(self._config.base_uri + kind.request_api_path + '/' + key, False)
4040

4141
def _do_request(self, uri, allow_cache):
4242
hdrs = _headers(self._config.sdk_key)
@@ -49,7 +49,7 @@ def _do_request(self, uri, allow_cache):
4949
timeout=urllib3.Timeout(connect=self._config.connect_timeout, read=self._config.read_timeout),
5050
retries=1)
5151
throw_if_unsuccessful_response(r)
52-
if r.status == 304 and cache_entry is not None:
52+
if r.status == 304 and allow_cache and cache_entry is not None:
5353
data = cache_entry.data
5454
etag = cache_entry.etag
5555
from_cache = True

ldclient/sse_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(self, url, last_id=None, retry=3000, connect_timeout=10, read_timeo
3232
self._chunk_size = chunk_size
3333

3434
# Optional support for passing in an HTTP client
35-
self.http = create_http_pool_manager(num_pools=1, verify_ssl=verify_ssl)
35+
self.http = create_http_pool_manager(num_pools=1, verify_ssl=verify_ssl, target_base_uri=url)
3636

3737
# Any extra kwargs will be fed into the request call later.
3838
self.requests_kwargs = kwargs

ldclient/streaming.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,10 @@ def _parse_path(path):
154154
if path.startswith(kind.stream_api_path):
155155
return ParsedPath(kind = kind, key = path[len(kind.stream_api_path):])
156156
return None
157+
158+
# magic methods for "with" statement (used in testing)
159+
def __enter__(self):
160+
return self
161+
162+
def __exit__(self, type, value, traceback):
163+
self.stop()

ldclient/util.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import certifi
77
import logging
8+
from os import environ
89
import six
910
import sys
1011
import urllib3
@@ -84,15 +85,37 @@ def status(self):
8485
return self._status
8586

8687

87-
def create_http_pool_manager(num_pools=1, verify_ssl=False):
88+
def create_http_pool_manager(num_pools=1, verify_ssl=False, target_base_uri=None):
89+
proxy_url = _get_proxy_url(target_base_uri)
90+
8891
if not verify_ssl:
89-
return urllib3.PoolManager(num_pools=num_pools)
90-
return urllib3.PoolManager(
91-
num_pools=num_pools,
92-
cert_reqs='CERT_REQUIRED',
93-
ca_certs=certifi.where()
92+
if proxy_url is None:
93+
return urllib3.PoolManager(num_pools=num_pools)
94+
else:
95+
return urllib3.ProxyManager(proxy_url, num_pools=num_pools)
96+
97+
if proxy_url is None:
98+
return urllib3.PoolManager(
99+
num_pools=num_pools,
100+
cert_reqs='CERT_REQUIRED',
101+
ca_certs=certifi.where()
102+
)
103+
else:
104+
return urllib3.ProxyManager(
105+
proxy_url,
106+
num_pools=num_pools,
107+
cert_reqs='CERT_REQUIRED',
108+
ca_certs=certifi.where()
94109
)
95110

111+
def _get_proxy_url(target_base_uri):
112+
if target_base_uri is None:
113+
return None
114+
is_https = target_base_uri.startswith('https:')
115+
if is_https:
116+
return environ.get('https_proxy')
117+
return environ.get('http_proxy')
118+
96119

97120
def throw_if_unsuccessful_response(resp):
98121
if resp.status >= 400:

scripts/release.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,9 @@ echo "Starting python-server-sdk release."
1313

1414
VERSION=$1
1515

16-
#Update version in ldclient/version.py
16+
# Update version in ldclient/version.py - setup.py references this constant
1717
echo "VERSION = \"${VERSION}\"" > ldclient/version.py
1818

19-
# Update version in setup.py
20-
SETUP_PY_TEMP=./setup.py.tmp
21-
sed "s/ldclient_version=.*/ldclient_version='${VERSION}'/g" setup.py > ${SETUP_PY_TEMP}
22-
mv ${SETUP_PY_TEMP} setup.py
23-
2419
# Prepare distribution
2520
python setup.py sdist
2621

setup.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33
import sys
44
import uuid
55

6-
6+
# Get VERSION constant from ldclient.version - we can't simply import that module because
7+
# ldclient/__init__.py imports all kinds of stuff that requires dependencies we may not have
8+
# loaded yet. Based on https://packaging.python.org/guides/single-sourcing-package-version/
9+
version_module_globals = {}
10+
with open('./ldclient/version.py') as f:
11+
exec(f.read(), version_module_globals)
12+
ldclient_version = version_module_globals['VERSION']
13+
714
def parse_requirements(filename):
815
""" load requirements from a pip requirements file """
916
lineiter = (line.strip() for line in open(filename))
1017
return [line for line in lineiter if line and not line.startswith("#")]
1118

12-
13-
ldclient_version='6.10.1'
14-
1519
# parse_requirements() returns generator of pip.req.InstallRequirement objects
1620
install_reqs = parse_requirements('requirements.txt')
1721
test_reqs = parse_requirements('test-requirements.txt')

0 commit comments

Comments
 (0)