Skip to content

Commit 2f4b6a4

Browse files
committed
Support for etcd v0.2.0 final
1 parent d64957a commit 2f4b6a4

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ python:
44
- "3.3"
55

66
before_install:
7-
- ./build_etcd.sh v0.2.0-rc1
7+
- ./build_etcd.sh v0.2.0
88

99
# command to install dependencies
1010
install:

src/etcd/__init__.py

+15
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ def children(self):
4747
yield child
4848
return
4949

50+
def __eq__(self, other):
51+
if not (type(self) is type(other)):
52+
return False
53+
for k in self._node_props.keys():
54+
try:
55+
a = getattr(self, k)
56+
b = getattr(other, k)
57+
if a != b:
58+
return False
59+
except:
60+
return False
61+
return True
62+
63+
def __ne__(self, other):
64+
return not self.__eq__(other)
5065

5166

5267
class EtcdException(Exception):

src/etcd/client.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,11 @@ def write(self, key, value, ttl=None, dir=False, append = False, **kwdargs):
247247
else:
248248
params[k] = v
249249

250-
method = append and self._MPOST or self.MPUT
250+
method = append and self._MPOST or self._MPUT
251251
if '_endpoint' in kwdargs:
252252
path = kwdargs['_endpoint'] + key
253253
else:
254-
path = self.key_endpoint + key)
254+
path = self.key_endpoint + key
255255
response = self.api_execute(path, method, params)
256256
return self._result_from_response(response)
257257

@@ -316,7 +316,7 @@ def delete(self, key, recursive=None, dir=None):
316316
if recursive is not None:
317317
kwds['recursive'] = recursive and "true" or "false"
318318
if dir is not None:
319-
kwds['dir'] = dir and "true" on "false"
319+
kwds['dir'] = dir and "true" or "false"
320320

321321
response = self.api_execute(
322322
self.key_endpoint + key, self._MDELETE, kwds)
@@ -440,9 +440,10 @@ def _result_from_response(self, response):
440440
#TODO: add headers we obtained from the http respose to the etcd result.
441441
try:
442442
res = json.loads(response.data.decode('utf-8'))
443+
r = etcd.EtcdResult(**res)
443444
if response.status == 201:
444-
res['newKey'] = True
445-
return etcd.EtcdResult(**res)
445+
r.newKey = True
446+
return r
446447
except Exception as e:
447448
raise etcd.EtcdException(
448449
'Unable to decode server response: %s' % e)

0 commit comments

Comments
 (0)