aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevendra2013-07-10 10:39:58 +0530
committerDevendra2013-07-10 10:39:58 +0530
commite65cc45e333cc33d19b97b5f93e69121ca2beffa (patch)
tree284435394f510ab1cd165fdac9b7bded5709dc83
parentdd2e5481c7b0f96d8caae5a613db0c407711999d (diff)
downloadpubnub-python-e65cc45e333cc33d19b97b5f93e69121ca2beffa.tar.bz2
adding makefiles for version updates
-rw-r--r--Makefile19
-rw-r--r--Makefile.inc3
-rw-r--r--VERSION2
-rw-r--r--common/Makefile16
-rw-r--r--common/PubnubBase.py20
-rw-r--r--common/PubnubCoreAsync.py9
-rw-r--r--python-tornado/Makefile17
-rw-r--r--python-tornado/Pubnub.py1
-rw-r--r--python-tornado/tests/benchmark.py2
-rw-r--r--python-tornado/tests/unit-test.py2
-rw-r--r--python-twisted/Makefile18
-rw-r--r--python-twisted/Pubnub.py1
-rw-r--r--python-twisted/tests/unit-test-full.py2
-rw-r--r--python-twisted/tests/unit-test.py15
-rw-r--r--python/Makefile19
-rw-r--r--python/Pubnub.py2
-rwxr-xr-xpython/tests/detailed-history-unit-test.py (renamed from python/examples/detailed-history-unit-test.py)5
-rwxr-xr-xpython/tests/unit-test.py25
18 files changed, 142 insertions, 36 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..dbe0d95
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,19 @@
+SUBDIRS = common python python-twisted python-tornado
+
+.PHONY: all
+all:
+ for dir in $(SUBDIRS); do \
+ $(MAKE) -C $$dir; \
+ done
+
+.PHONY: clean
+clean:
+ for dir in $(SUBDIRS); do \
+ $(MAKE) clean -C $$dir; \
+ done
+
+.PHONY: test
+test:
+ for dir in $(SUBDIRS); do \
+ $(MAKE) test -C $$dir; \
+ done
diff --git a/Makefile.inc b/Makefile.inc
new file mode 100644
index 0000000..68a78c6
--- /dev/null
+++ b/Makefile.inc
@@ -0,0 +1,3 @@
+REPOS_DIR=..
+VERSION=$(shell cat $(REPOS_DIR)/VERSION)
+ECHO=/bin/echo
diff --git a/VERSION b/VERSION
index 4772543..a0891f5 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.3.2
+3.3.4
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
diff --git a/python-tornado/Makefile b/python-tornado/Makefile
new file mode 100644
index 0000000..2c33cf3
--- /dev/null
+++ b/python-tornado/Makefile
@@ -0,0 +1,17 @@
+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/python-tornado/Pubnub.py b/python-tornado/Pubnub.py
index 0d78a86..55ca7ca 100644
--- a/python-tornado/Pubnub.py
+++ b/python-tornado/Pubnub.py
@@ -63,7 +63,6 @@ class Pubnub(PubnubCoreAsync):
def _request( self, request, callback ) :
url = self.getUrl(request)
- print url
## Send Request Expecting JSON Response
#print self.headers
request = tornado.httpclient.HTTPRequest( url, 'GET', self.headers, connect_timeout=310, request_timeout=310 )
diff --git a/python-tornado/tests/benchmark.py b/python-tornado/tests/benchmark.py
index 5f9b5e3..9d1840e 100644
--- a/python-tornado/tests/benchmark.py
+++ b/python-tornado/tests/benchmark.py
@@ -12,7 +12,9 @@
import sys
import datetime
import tornado
+sys.path.append('./')
sys.path.append('../')
+sys.path.append('../common')
from Pubnub import Pubnub
publish_key = len(sys.argv) > 1 and sys.argv[1] or 'demo'
diff --git a/python-tornado/tests/unit-test.py b/python-tornado/tests/unit-test.py
index f593d11..c5940af 100644
--- a/python-tornado/tests/unit-test.py
+++ b/python-tornado/tests/unit-test.py
@@ -19,6 +19,8 @@
import sys
sys.path.append('../')
+sys.path.append('./')
+sys.path.append('../common/')
from Pubnub import Pubnub
publish_key = len(sys.argv) > 1 and sys.argv[1] or 'demo'
diff --git a/python-twisted/Makefile b/python-twisted/Makefile
new file mode 100644
index 0000000..4cd9305
--- /dev/null
+++ b/python-twisted/Makefile
@@ -0,0 +1,18 @@
+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:
+ python tests/unit-test.py
+
diff --git a/python-twisted/Pubnub.py b/python-twisted/Pubnub.py
index 247c4ff..e317a9c 100644
--- a/python-twisted/Pubnub.py
+++ b/python-twisted/Pubnub.py
@@ -81,7 +81,6 @@ class Pubnub(PubnubCoreAsync):
contextFactory = WebClientContextFactory(),
pool = self.ssl and None or pnconn_pool
)), [('gzip', GzipDecoder)])
- print url
request = agent.request( 'GET', url, Headers(self.headers), None )
def received(response):
diff --git a/python-twisted/tests/unit-test-full.py b/python-twisted/tests/unit-test-full.py
index f593d11..c5940af 100644
--- a/python-twisted/tests/unit-test-full.py
+++ b/python-twisted/tests/unit-test-full.py
@@ -19,6 +19,8 @@
import sys
sys.path.append('../')
+sys.path.append('./')
+sys.path.append('../common/')
from Pubnub import Pubnub
publish_key = len(sys.argv) > 1 and sys.argv[1] or 'demo'
diff --git a/python-twisted/tests/unit-test.py b/python-twisted/tests/unit-test.py
index 843f939..ed7fcd5 100644
--- a/python-twisted/tests/unit-test.py
+++ b/python-twisted/tests/unit-test.py
@@ -11,6 +11,8 @@
import sys
sys.path.append('../')
+sys.path.append('./')
+sys.path.append('../common/')
from Pubnub import Pubnub
publish_key = len(sys.argv) > 1 and sys.argv[1] or 'demo'
@@ -23,7 +25,7 @@ ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False
## Initiat Class
## -----------------------------------------------------------------------
pubnub = Pubnub( publish_key, subscribe_key, secret_key, cipher_key, ssl_on )
-crazy = ' ~`!@#$%^&*( 顶顅 Ȓ)+=[]\\{}|;\':",./<>?abcd'
+crazy = 'python-twisted-test-channel'
## ---------------------------------------------------------------------------
## Unit Test Function
@@ -90,10 +92,17 @@ def message_received(message):
'callback' : dumpster
})
+
def connected() :
+ ch = crazy
+ def dump_message( msg):
+ print ch, msg
+ pubnub.unsubscribe({'channel':ch})
+ pubnub.stop()
pubnub.publish({
- 'channel' : crazy,
- 'message' : { 'Info' : 'Connected!' }
+ 'channel' : ch,
+ 'message' : { 'Info' : 'Connected!' },
+ 'callback' : dump_message
})
pubnub.subscribe({
diff --git a/python/Makefile b/python/Makefile
new file mode 100644
index 0000000..9551bb7
--- /dev/null
+++ b/python/Makefile
@@ -0,0 +1,19 @@
+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:
+ python tests/detailed-history-unit-test.py
+ python tests/unit-test.py
+
diff --git a/python/Pubnub.py b/python/Pubnub.py
index 6143b0b..0a6d877 100644
--- a/python/Pubnub.py
+++ b/python/Pubnub.py
@@ -6,7 +6,7 @@
## http://www.pubnub.com/
## -----------------------------------
-## PubNub 3.3.2 Real-time Push Cloud API
+## PubNub 3.3.4 Real-time Push Cloud API
## -----------------------------------
try: import json
diff --git a/python/examples/detailed-history-unit-test.py b/python/tests/detailed-history-unit-test.py
index 2169e52..31bdef8 100755
--- a/python/examples/detailed-history-unit-test.py
+++ b/python/tests/detailed-history-unit-test.py
@@ -9,9 +9,12 @@
## PubNub 3.0 Real-time Push Cloud API
## -----------------------------------
+import sys
+sys.path.append('.')
+sys.path.append('..')
+sys.path.append('../common')
from Pubnub import Pubnub
import unittest2 as unittest
-import sys
publish_key = len(sys.argv) > 1 and sys.argv[1] or 'demo'
diff --git a/python/tests/unit-test.py b/python/tests/unit-test.py
index 88391a0..1737ace 100755
--- a/python/tests/unit-test.py
+++ b/python/tests/unit-test.py
@@ -9,8 +9,11 @@
## PubNub 3.0 Real-time Push Cloud API
## -----------------------------------
-from Pubnub import Pubnub
import sys
+sys.path.append('.')
+sys.path.append('..')
+sys.path.append('../common')
+from Pubnub import Pubnub
publish_key = len(sys.argv) > 1 and sys.argv[1] or 'demo'
subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'demo'
@@ -23,7 +26,7 @@ ssl_on = len(sys.argv) > 4 and bool(sys.argv[4]) or False
## -----------------------------------------------------------------------
pubnub = Pubnub( publish_key, subscribe_key, secret_key, ssl_on )
-crazy = ' ~`!@#$%^&*(顶顅Ȓ)+=[]\\{}|;\':",./<>?abcd'
+crazy = 'demo'
## ---------------------------------------------------------------------------
## Unit Test Function
@@ -37,11 +40,11 @@ def test( trial, name ) :
## -----------------------------------------------------------------------
## Publish Example
## -----------------------------------------------------------------------
-pubish_success = pubnub.publish({
+publish_success = pubnub.publish({
'channel' : crazy,
'message' : crazy
})
-test( pubish_success[0] == 1, 'Publish First Message Success' )
+test( publish_success[0] == 1, 'Publish First Message Success' )
## -----------------------------------------------------------------------
## History Example
@@ -61,17 +64,3 @@ test( len(history) == 1, 'History Message Count' )
## -----------------------------------------------------------------------
timestamp = pubnub.time()
test( timestamp > 0, 'PubNub Server Time: ' + str(timestamp) )
-
-## -----------------------------------------------------------------------
-## Subscribe Example
-## -----------------------------------------------------------------------
-def receive(message) :
- print(message)
- return True
-
-pubnub.subscribe({
- 'channel' : crazy,
- 'callback' : receive
-})
-
-