From e65cc45e333cc33d19b97b5f93e69121ca2beffa Mon Sep 17 00:00:00 2001 From: Devendra Date: Wed, 10 Jul 2013 10:39:58 +0530 Subject: adding makefiles for version updates --- common/Makefile | 16 ++++++++++++++++ common/PubnubBase.py | 20 ++++++++++---------- common/PubnubCoreAsync.py | 9 +++++++++ 3 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 common/Makefile (limited to 'common') diff --git a/common/Makefile b/common/Makefile new file mode 100644 index 0000000..1be6f8c --- /dev/null +++ b/common/Makefile @@ -0,0 +1,16 @@ +include ../Makefile.inc + + +.PHONY: all +all: build + +.PHONY: build +build: + find -name "Pubnub*py" | xargs sed -i "s/PubNub\ [0-9]\.[0-9]\.[0-9]/PubNub\ $(VERSION)/g" + + +.PHONY: clean +clean: + +.PHONY: test +test: diff --git a/common/PubnubBase.py b/common/PubnubBase.py index 0691a87..b5da9fa 100644 --- a/common/PubnubBase.py +++ b/common/PubnubBase.py @@ -319,22 +319,22 @@ class PubnubBase(object): ## Capture User Input channel = str(args['channel']) - params = [] + params = dict() count = 100 if args.has_key('count'): count = int(args['count']) - params.append('count' + '=' + str(count)) + params['count'] = str(count) if args.has_key('reverse'): - params.append('reverse' + '=' + str(args['reverse']).lower()) + params['reverse'] = str(args['reverse']).lower() if args.has_key('start'): - params.append('start' + '=' + str(args['start'])) + params['start'] = str(args['start']) if args.has_key('end'): - params.append('end' + '=' + str(args['end'])) + params['end'] = str(args['end']) ## Fail if bad input. if not channel : @@ -348,14 +348,14 @@ class PubnubBase(object): callback = None ## Get History - return self._request([ + return self._request({ 'urlcomponents' : [ 'v2', 'history', 'sub-key', self.subscribe_key, 'channel', channel, - ],params=params , callback=callback); + ],'urlparams' : params }, callback=callback); def time(self, args = None) : """ @@ -377,10 +377,10 @@ class PubnubBase(object): callback = args['callback'] else : callback = None - time = self._request([ + time = self._request({'urlcomponents' : [ 'time', '0' - ], callback) + ]}, callback) if time != None: return time[0] @@ -400,5 +400,5 @@ class PubnubBase(object): ch for ch in list(bit) ]) for bit in request["urlcomponents"]]) if (request.has_key("urlparams")): - url = url + '?' + "&".join([ x + "=" + y for x,y in request["urlparams"].items()]) + url = url + '?' + "&".join([ x + "=" + y for x,y in request["urlparams"].iteritems()]) return url diff --git a/common/PubnubCoreAsync.py b/common/PubnubCoreAsync.py index 9dcad4b..5b8d130 100644 --- a/common/PubnubCoreAsync.py +++ b/common/PubnubCoreAsync.py @@ -188,3 +188,12 @@ class PubnubCoreAsync(PubnubBase): ## BEGIN SUBSCRIPTION (LISTEN FOR MESSAGES) _subscribe() + def unsubscribe( self, args ): + channel = str(args['channel']) + if not (channel in self.subscriptions): + return False + + ## DISCONNECT + self.subscriptions[channel]['connected'] = 0 + self.subscriptions[channel]['timetoken'] = 0 + self.subscriptions[channel]['first'] = False -- cgit v1.2.3