예제 #1
0
publish_key   = len(sys.argv) > 1 and sys.argv[1] or 'demo'
subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'demo'
secret_key    = len(sys.argv) > 3 and sys.argv[3] or 'demo'
cipher_key    = len(sys.argv) > 4 and sys.argv[4] or 'demo'
ssl_on        = len(sys.argv) > 5 and bool(sys.argv[5]) or False
origin        = len(sys.argv) > 6 and sys.argv[6] or 'pubsub.pubnub.com'


## -----------------------------------------------------------------------
## Initiat Class
## -----------------------------------------------------------------------
pubnub = Pubnub(
    publish_key,
    subscribe_key,
    secret_key = secret_key,
    cipher_key = cipher_key,
    ssl_on = ssl_on,
    origin = origin
)
crazy  = ' ~`!@#$%^&*( 顶顅 Ȓ)+=[]\\{}|;\':",./<>?abcd'

## -----------------------------------------------------------------------
## BENCHMARK
## -----------------------------------------------------------------------
def connected() :
    pubnub.publish({
        'channel' : crazy,
        'message' : { 'Info' : 'Connected!' }
    })

trips = { 'last' : None, 'current' : None, 'max' : 0, 'avg' : 0 }
예제 #2
0
## http://www.pubnub.com/

import sys
from Pubnub import PubnubTwisted as Pubnub

publish_key = len(sys.argv) > 1 and sys.argv[1] or 'pam'
subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'pam'
secret_key = len(sys.argv) > 3 and sys.argv[3] or 'pam'
cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False

## -----------------------------------------------------------------------
## Initiate Pubnub State
## -----------------------------------------------------------------------
pubnub = Pubnub(publish_key=publish_key,
                subscribe_key=subscribe_key,
                secret_key=secret_key,
                cipher_key=cipher_key,
                ssl_on=ssl_on)
channel = 'hello_world'
authkey = "abcd"


def callback(message):
    print(message)


pubnub.revoke(channel, authkey, callback=callback, error=callback)

pubnub.start()
예제 #3
0
from Pubnub import PubnubTwisted as Pubnub
import time

pubnub = Pubnub("demo", "demo")
pubnub_pam = Pubnub("pub-c-c077418d-f83c-4860-b213-2f6c77bde29a",
                    "sub-c-e8839098-f568-11e2-a11a-02ee2ddab7fe",
                    "sec-c-OGU3Y2Q4ZWUtNDQwMC00NTI1LThjNWYtNWJmY2M4OGIwNjEy")


# Grant permission read true, write true, on channel ( Async Mode )
def test_1():
    def _callback(resp, ch=None):
        assert resp == {
            'message': u'Success',
            'payload': {
                u'auths': {
                    u'abcd': {
                        u'r': 1,
                        u'w': 1
                    }
                },
                u'subscribe_key':
                u'sub-c-e8839098-f568-11e2-a11a-02ee2ddab7fe',
                u'level': u'user',
                u'channel': u'abcd',
                u'ttl': 1
            }
        }

    def _error(response):
        assert False
예제 #4
0
import datetime
from Pubnub import PubnubTwisted as Pubnub
from functools import partial
from threading import current_thread
import threading
publish_key = len(sys.argv) > 1 and sys.argv[1] or 'demo'
subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'demo'
secret_key = len(sys.argv) > 3 and sys.argv[3] or 'demo'
cipher_key = len(sys.argv) > 4 and sys.argv[4] or None
ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False

## -----------------------------------------------------------------------
## Initiate Pubnub State
## -----------------------------------------------------------------------
#pubnub = Pubnub( publish_key, subscribe_key, secret_key, cipher_key, ssl_on )
pubnub = Pubnub(publish_key, subscribe_key, secret_key, ssl_on)
crazy = 'hello_world'

current = -1

errors = 0
received = 0

## -----------------------------------------------------------------------
## Subscribe Example
## -----------------------------------------------------------------------


def message_received(message):
    print(message)
import sys
import datetime
from twisted.internet import reactor
from Pubnub import PubnubTwisted as 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'
secret_key    = len(sys.argv) > 3 and sys.argv[3] or 'demo'
cipher_key    = len(sys.argv) > 4 and sys.argv[4] or 'demo'
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'

## -----------------------------------------------------------------------
## BENCHMARK
## -----------------------------------------------------------------------
def connected() :
    pubnub.publish({
        'channel' : crazy,
        'message' : { 'Info' : 'Connected!' }
    })

trips = { 'last' : None, 'current' : None, 'max' : 0, 'avg' : 0 }

def received(message):
    current_trip = trips['current'] = str(datetime.datetime.now())[0:19]
예제 #6
0
## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Configuration
## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
publish_key    = 'pub-c-f6a20151-db8d-45af-ba42-def0edaa459f'
subscribe_key  = 'sub-c-b5ff3208-7f64-11e4-b601-02ee2ddab7fe'
secret_key     = 'demo'
server_channel = 'echo-server'
client_channel = 'echo-channel'

## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Create PubNub Instance
## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
pubnub = Pubnub(
    publish_key=publish_key,
    subscribe_key=subscribe_key,
    secret_key=secret_key,
    ssl_on=True
)

## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Error Log
## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
def error_log(data): print(data)

## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Access Log
## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
def access_log(data): print(data)

## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Respond
예제 #7
0
from Pubnub import PubnubTwisted as Pubnub

## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Configuration
## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
publish_key    = 'pub-c-f6a20151-db8d-45af-ba42-def0edaa459f'
subscribe_key  = 'sub-c-b5ff3208-7f64-11e4-b601-02ee2ddab7fe'
secret_key     = 'demo'
server_channel = 'echo-server'

## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Create PubNub Instance
## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
pubnub = Pubnub(
    publish_key=publish_key,
    subscribe_key=subscribe_key,
    secret_key=secret_key,
    ssl_on=True
)

## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Error Log
## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
def error_log(data): print(data)

## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Access Log
## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
def access_log(data): print(data)

## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Respond
예제 #8
0
## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
from Pubnub import PubnubTwisted as Pubnub

## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Configuration
## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
publish_key = 'pub-c-f6a20151-db8d-45af-ba42-def0edaa459f'
subscribe_key = 'sub-c-b5ff3208-7f64-11e4-b601-02ee2ddab7fe'
secret_key = 'demo'
server_channel = 'echo-server'

## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Create PubNub Instance
## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
pubnub = Pubnub(publish_key=publish_key,
                subscribe_key=subscribe_key,
                secret_key=secret_key,
                ssl_on=True)


## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Error Log
## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
def error_log(data):
    print(data)


## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Access Log
## =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
def access_log(data):
    print(data)
예제 #9
0
## -----------------------------------------------------------------------
## High Security PubNub
## -----------------------------------------------------------------------
pubnub_high_security = Pubnub(
    ## Publish Key
    'pub-c-a30c030e-9f9c-408d-be89-d70b336ca7a0',

    ## Subscribe Key
    'sub-c-387c90f3-c018-11e1-98c9-a5220e0555fd',

    ## Secret Key
    'sec-c-MTliNDE0NTAtYjY4Ni00MDRkLTllYTItNDhiZGE0N2JlYzBl',

    ## Cipher Key
    'YWxzamRmbVjFaa05HVnGFqZHM3NXRBS73jxmhVMkjiwVVXV1d5UrXR1JLSkZFRr' +
    'WVd4emFtUm1iR0TFpUZvbiBoYXMgYmVlbxWkhNaF3uUi8kM0YkJTEVlZYVFjBYi' +
    'jFkWFIxSkxTa1pGUjd874hjklaTFpUwRVuIFNob3VsZCB5UwRkxUR1J6YVhlQWa' +
    'V1ZkNGVH32mDkdho3pqtRnRVbTFpUjBaeGUgYXNrZWQtZFoKjda40ZWlyYWl1eX' +
    'U4RkNtdmNub2l1dHE2TTA1jd84jkdJTbFJXYkZwWlZtRnKkWVrSRhhWbFpZVmFz' +
    'c2RkZmTFpUpGa1dGSXhTa3hUYTFwR1Vpkm9yIGluZm9ybWFNfdsWQdSiiYXNWVX' +
    'RSblJWYlRGcFVqQmFlRmRyYUU0MFpXbHlZV2wxZVhVNFJrTnR51YjJsMWRIRTJU' +
    'W91ciBpbmZvcm1hdGliBzdWJtaXR0ZWQb3UZSBhIHJlc3BvbnNlLCB3ZWxsIHJl' +
    'VEExWdHVybiB0am0aW9uIb24gYXMgd2UgcG9zc2libHkgY2FuLuhcFe24ldWVns' +
    'dSaTFpU3hVUjFKNllWaFdhRmxZUWpCaQo34gcmVxdWlGFzIHNveqQl83snBfVl3',

    ## 2048bit SSL ON - ENABLED TRUE
    True)

## -----------------------------------------------------------------------
## Channel | Message Test Data (UTF-8)
## -----------------------------------------------------------------------
예제 #10
0
import sys
from Pubnub import PubnubTwisted as 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'
secret_key = len(sys.argv) > 3 and sys.argv[3] or 'demo'
cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False

## -----------------------------------------------------------------------
## Initiate Pubnub State
## -----------------------------------------------------------------------
pubnub = Pubnub(publish_key=publish_key,
                subscribe_key=subscribe_key,
                secret_key=secret_key,
                cipher_key=cipher_key,
                ssl_on=ssl_on)
channel = 'a'

# Asynchronous usage


def callback(message):
    print(message)


pubnub.history(channel, count=2, callback=callback, error=callback)

pubnub.start()
예제 #11
0

from Pubnub import PubnubTwisted as Pubnub
import time

pubnub = Pubnub("demo","demo")
pubnub_enc = Pubnub("demo", "demo", cipher_key="enigma")
pubnub_pam = Pubnub("pub-c-c077418d-f83c-4860-b213-2f6c77bde29a", 
	"sub-c-e8839098-f568-11e2-a11a-02ee2ddab7fe", "sec-c-OGU3Y2Q4ZWUtNDQwMC00NTI1LThjNWYtNWJmY2M4OGIwNjEy")



# Publish and receive string
def test_1():

	channel = "test_1-" + str(time.time())
	message = "I am a string"

	def _cb(resp, ch=None):
		assert resp == message
		pubnub.unsubscribe(channel)

	def _connect(resp):
		def _cb1(resp,ch=None):
			assert resp[0] == 1
		def _err1(resp):
			assert False
		pubnub.publish(channel,message, callback=_cb1, error=_err1)

	def _error(resp):
		assert False
예제 #12
0
import sys
from Pubnub import PubnubTwisted as 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'
secret_key = len(sys.argv) > 3 and sys.argv[3] or 'demo'
cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False

## -----------------------------------------------------------------------
## Initiate Pubnub State
## -----------------------------------------------------------------------
pubnub = Pubnub(publish_key=publish_key,
                subscribe_key=subscribe_key,
                secret_key=secret_key,
                cipher_key=cipher_key,
                ssl_on=ssl_on)

channel = 'a'


# Asynchronous usage
def callback(message, channel):
    print(message)


def error(message):
    print("ERROR : " + str(message))

예제 #13
0
## PubNub Real-time Push APIs and Notifications Framework
## Copyright (c) 2010 Stephen Blum
## http://www.pubnub.com/


import sys
from Pubnub import PubnubTwisted as 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'
secret_key = len(sys.argv) > 3 and sys.argv[3] or 'demo'
cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False

## -----------------------------------------------------------------------
## Initiate Pubnub State
## -----------------------------------------------------------------------
pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,
                secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on)
channel = 'hello_world'


# Asynchronous usage

def callback(message):
    print(message)

pubnub.here_now(channel, callback=callback, error=callback)

pubnub.start()
예제 #14
0
import sys
from Pubnub import PubnubTwisted as 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'
secret_key = len(sys.argv) > 3 and sys.argv[3] or 'demo'
cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False

## -----------------------------------------------------------------------
## Initiate Pubnub State
## -----------------------------------------------------------------------
pubnub = Pubnub(publish_key=publish_key,
                subscribe_key=subscribe_key,
                secret_key=secret_key,
                cipher_key=cipher_key,
                ssl_on=ssl_on)
channel = 'hello_world'
message = 'Hello World !!!'

# Asynchronous usage


def callback(message):
    print(message)


pubnub.publish(channel, message, callback=callback, error=callback)

pubnub.start()
예제 #15
0
from Pubnub import PubnubTwisted as Pubnub
import time

pubnub = Pubnub("demo", "demo")
pubnub_enc = Pubnub("demo", "demo", cipher_key="enigma")
pubnub_pam = Pubnub("pub-c-c077418d-f83c-4860-b213-2f6c77bde29a",
                    "sub-c-e8839098-f568-11e2-a11a-02ee2ddab7fe",
                    "sec-c-OGU3Y2Q4ZWUtNDQwMC00NTI1LThjNWYtNWJmY2M4OGIwNjEy")


# Publish and receive string
def test_1():

    channel = "test_1-" + str(time.time())
    message = "I am a string"

    def _cb(resp, ch=None):
        assert resp == message
        pubnub.unsubscribe(channel)

    def _connect(resp):
        def _cb1(resp, ch=None):
            assert resp[0] == 1

        def _err1(resp):
            assert False

        pubnub.publish(channel, message, callback=_cb1, error=_err1)

    def _error(resp):
        assert False
예제 #16
0
from Pubnub import PubnubTwisted as Pubnub
from functools import partial
from threading import current_thread
import threading

publish_key = len(sys.argv) > 1 and sys.argv[1] or 'demo'
subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'demo'
secret_key = len(sys.argv) > 3 and sys.argv[3] or 'demo'
cipher_key = len(sys.argv) > 4 and sys.argv[4] or None
ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False

## -----------------------------------------------------------------------
## Initiate Pubnub State
## -----------------------------------------------------------------------
#pubnub = Pubnub( publish_key, subscribe_key, secret_key, cipher_key, ssl_on )
pubnub = Pubnub(publish_key, subscribe_key, secret_key, ssl_on)
crazy = 'hello_world'

current = -1

errors = 0
received = 0

## -----------------------------------------------------------------------
## Subscribe Example
## -----------------------------------------------------------------------


def message_received(message):
    print(message)
예제 #17
0
## Copyright (c) 2010 Stephen Blum
## http://www.pubnub.com/


import sys
from Pubnub import PubnubTwisted as Pubnub

publish_key = len(sys.argv) > 1 and sys.argv[1] or "pam"
subscribe_key = len(sys.argv) > 2 and sys.argv[2] or "pam"
secret_key = len(sys.argv) > 3 and sys.argv[3] or "pam"
cipher_key = len(sys.argv) > 4 and sys.argv[4] or ""
ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False

## -----------------------------------------------------------------------
## Initiate Pubnub State
## -----------------------------------------------------------------------
pubnub = Pubnub(
    publish_key=publish_key, subscribe_key=subscribe_key, secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on
)
channel = "hello_world"
authkey = "abcd"


def callback(message):
    print(message)


pubnub.revoke(channel, authkey, callback=callback, error=callback)

pubnub.start()
예제 #18
0
파일: history.py 프로젝트: TipWander/python
## PubNub Real-time Push APIs and Notifications Framework
## Copyright (c) 2010 Stephen Blum
## http://www.pubnub.com/


import sys
from Pubnub import PubnubTwisted as 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'
secret_key = len(sys.argv) > 3 and sys.argv[3] or 'demo'
cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False

## -----------------------------------------------------------------------
## Initiate Pubnub State
## -----------------------------------------------------------------------
pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,
                secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on)
channel = 'a'

# Asynchronous usage


def callback(message):
    print(message)

pubnub.history(channel, count=2, callback=callback, error=callback)

pubnub.start()
예제 #19
0
## http://www.pubnub.com/

import sys
from Pubnub import PubnubTwisted as Pubnub

publish_key = len(sys.argv) > 1 and sys.argv[1] or 'pam'
subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'pam'
secret_key = len(sys.argv) > 3 and sys.argv[3] or 'pam'
cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False

## -----------------------------------------------------------------------
## Initiate Pubnub State
## -----------------------------------------------------------------------
pubnub = Pubnub(publish_key=publish_key,
                subscribe_key=subscribe_key,
                secret_key=secret_key,
                cipher_key=cipher_key,
                ssl_on=ssl_on)
channel = 'hello_world'
authkey = "abcd"


def callback(message):
    print(message)


pubnub.grant(channel, authkey, True, True, callback=callback, error=callback)

pubnub.start()
예제 #20
0
    'queued': 0,  # Total Unreceived Queue (UnDeliveries)
    'successful_publishes': 0,  # Confirmed Successful Publish Request
    'failed_publishes': 0,  # Confirmed UNSuccessful Publish Request
    'failed_deliveries': 0,  # (successful_publishes - received)
    'deliverability': 0  # Percentage Delivery
}

trips = {'last': None, 'current': None, 'max': 0, 'avg': 0}

## -----------------------------------------------------------------------
## Initiat Class
## -----------------------------------------------------------------------
channel = 'deliverability-' + str(time.time())
pubnub = Pubnub(publish_key,
                subscribe_key,
                secret_key=secret_key,
                cipher_key=cipher_key,
                ssl_on=ssl_on,
                origin=origin)

## -----------------------------------------------------------------------
## BENCHMARK
## -----------------------------------------------------------------------


def publish_sent(info=None):
    if info and info[0]:
        analytics['successful_publishes'] += 1
    else:
        analytics['failed_publishes'] += 1

    analytics['publishes'] += 1
예제 #21
0
파일: publish.py 프로젝트: TipWander/python
## Copyright (c) 2010 Stephen Blum
## http://www.pubnub.com/


import sys
from Pubnub import PubnubTwisted as 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'
secret_key = len(sys.argv) > 3 and sys.argv[3] or 'demo'
cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False

## -----------------------------------------------------------------------
## Initiate Pubnub State
## -----------------------------------------------------------------------
pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,
                secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on)
channel = 'hello_world'
message = 'Hello World !!!'

# Asynchronous usage


def callback(message):
    print(message)

pubnub.publish(channel, message, callback=callback, error=callback)

pubnub.start()
    "publishes": 0,  # Total Send Requests
    "received": 0,  # Total Received Messages (Deliveries)
    "queued": 0,  # Total Unreceived Queue (UnDeliveries)
    "successful_publishes": 0,  # Confirmed Successful Publish Request
    "failed_publishes": 0,  # Confirmed UNSuccessful Publish Request
    "failed_deliveries": 0,  # (successful_publishes - received)
    "deliverability": 0,  # Percentage Delivery
}

trips = {"last": None, "current": None, "max": 0, "avg": 0}

## -----------------------------------------------------------------------
## Initiat Class
## -----------------------------------------------------------------------
channel = "deliverability-" + str(time.time())
pubnub = Pubnub(publish_key, subscribe_key, secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on, origin=origin)

## -----------------------------------------------------------------------
## BENCHMARK
## -----------------------------------------------------------------------


def publish_sent(info=None):
    if info and info[0]:
        analytics["successful_publishes"] += 1
    else:
        analytics["failed_publishes"] += 1

    analytics["publishes"] += 1
    analytics["queued"] += 1
예제 #23
0
파일: audit.py 프로젝트: TipWander/python
# coding=utf8

## PubNub Real-time Push APIs and Notifications Framework
## Copyright (c) 2010 Stephen Blum
## http://www.pubnub.com/


import sys
from Pubnub import PubnubTwisted as Pubnub

publish_key = len(sys.argv) > 1 and sys.argv[1] or 'pam'
subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'pam'
secret_key = len(sys.argv) > 3 and sys.argv[3] or 'pam'
cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False

## -----------------------------------------------------------------------
## Initiate Pubnub State
## -----------------------------------------------------------------------
pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,
                secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on)
channel = 'hello_world'
authkey = "abcd"

def callback(message):
    print(message)

pubnub.audit(channel, authkey, callback=callback, error=callback)

pubnub.start()
예제 #24
0
## http://www.pubnub.com/

import sys
from Pubnub import PubnubTwisted as Pubnub

publish_key = len(sys.argv) > 1 and sys.argv[1] or 'pam'
subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'pam'
secret_key = len(sys.argv) > 3 and sys.argv[3] or 'pam'
cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False

## -----------------------------------------------------------------------
## Initiate Pubnub State
## -----------------------------------------------------------------------
pubnub = Pubnub(publish_key=publish_key,
                subscribe_key=subscribe_key,
                secret_key=secret_key,
                cipher_key=cipher_key,
                ssl_on=ssl_on)
channel = 'hello_world'
authkey = "abcd"


def callback(message):
    print(message)


pubnub.audit(channel, authkey, callback=callback, error=callback)

pubnub.start()
예제 #25
0
## http://www.pubnub.com/


import sys
from Pubnub import PubnubTwisted as 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'
secret_key = len(sys.argv) > 3 and sys.argv[3] or 'demo'
cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False

## -----------------------------------------------------------------------
## Initiate Pubnub State
## -----------------------------------------------------------------------
pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,
                secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on)

channel = 'a'


# Asynchronous usage
def callback(message, channel):
    print(message)


def error(message):
    print("ERROR : " + str(message))


def connect(message):
    print("CONNECTED")
예제 #26
0
## -----------------------------------------------------------------------
## High Security PubNub
## -----------------------------------------------------------------------
pubnub_high_security = Pubnub(
    ## Publish Key
    'pub-c-a30c030e-9f9c-408d-be89-d70b336ca7a0',

    ## Subscribe Key
    'sub-c-387c90f3-c018-11e1-98c9-a5220e0555fd',

    ## Secret Key
    'sec-c-MTliNDE0NTAtYjY4Ni00MDRkLTllYTItNDhiZGE0N2JlYzBl',

    ## Cipher Key
    'YWxzamRmbVjFaa05HVnGFqZHM3NXRBS73jxmhVMkjiwVVXV1d5UrXR1JLSkZFRr' +
    'WVd4emFtUm1iR0TFpUZvbiBoYXMgYmVlbxWkhNaF3uUi8kM0YkJTEVlZYVFjBYi' +
    'jFkWFIxSkxTa1pGUjd874hjklaTFpUwRVuIFNob3VsZCB5UwRkxUR1J6YVhlQWa' +
    'V1ZkNGVH32mDkdho3pqtRnRVbTFpUjBaeGUgYXNrZWQtZFoKjda40ZWlyYWl1eX' +
    'U4RkNtdmNub2l1dHE2TTA1jd84jkdJTbFJXYkZwWlZtRnKkWVrSRhhWbFpZVmFz' +
    'c2RkZmTFpUpGa1dGSXhTa3hUYTFwR1Vpkm9yIGluZm9ybWFNfdsWQdSiiYXNWVX' +
    'RSblJWYlRGcFVqQmFlRmRyYUU0MFpXbHlZV2wxZVhVNFJrTnR51YjJsMWRIRTJU' +
    'W91ciBpbmZvcm1hdGliBzdWJtaXR0ZWQb3UZSBhIHJlc3BvbnNlLCB3ZWxsIHJl' +
    'VEExWdHVybiB0am0aW9uIb24gYXMgd2UgcG9zc2libHkgY2FuLuhcFe24ldWVns' +
    'dSaTFpU3hVUjFKNllWaFdhRmxZUWpCaQo34gcmVxdWlGFzIHNveqQl83snBfVl3',

    ## 2048bit SSL ON - ENABLED TRUE
    True
)

## -----------------------------------------------------------------------
## Channel | Message Test Data (UTF-8)
예제 #27
0

from Pubnub import PubnubTwisted as Pubnub
import time

pubnub = Pubnub("demo","demo")
pubnub_pam = Pubnub("pub-c-c077418d-f83c-4860-b213-2f6c77bde29a", 
	"sub-c-e8839098-f568-11e2-a11a-02ee2ddab7fe", "sec-c-OGU3Y2Q4ZWUtNDQwMC00NTI1LThjNWYtNWJmY2M4OGIwNjEy")



# Grant permission read true, write true, on channel ( Async Mode )
def test_1():

	def _callback(resp, ch= None):
		assert resp == {
									'message': u'Success',
									'payload': {u'auths': {u'abcd': {u'r': 1, u'w': 1}},
									u'subscribe_key': u'sub-c-e8839098-f568-11e2-a11a-02ee2ddab7fe',
									u'level': u'user', u'channel': u'abcd', u'ttl': 1} 
								}

	def _error(response):
		assert False

	pubnub_pam.grant(channel="abcd", auth_key="abcd", read=True, write=True, ttl=1, callback=_callback, error=_error)
							

# Grant permission read false, write false, on channel ( Async Mode )
def test_2():
	
예제 #28
0
import sys
from Pubnub import PubnubTwisted as 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'
secret_key = len(sys.argv) > 3 and sys.argv[3] or 'demo'
cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False

## -----------------------------------------------------------------------
## Initiate Pubnub State
## -----------------------------------------------------------------------
pubnub = Pubnub(publish_key=publish_key,
                subscribe_key=subscribe_key,
                secret_key=secret_key,
                cipher_key=cipher_key,
                ssl_on=ssl_on)
channel = 'hello_world'

# Asynchronous usage


def callback(message):
    print(message)


pubnub.here_now(channel, callback=callback, error=callback)

pubnub.start()
예제 #29
0
파일: grant.py 프로젝트: TipWander/python
# coding=utf8

## PubNub Real-time Push APIs and Notifications Framework
## Copyright (c) 2010 Stephen Blum
## http://www.pubnub.com/


import sys
from Pubnub import PubnubTwisted as Pubnub

publish_key = len(sys.argv) > 1 and sys.argv[1] or 'pam'
subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'pam'
secret_key = len(sys.argv) > 3 and sys.argv[3] or 'pam'
cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False

## -----------------------------------------------------------------------
## Initiate Pubnub State
## -----------------------------------------------------------------------
pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,
                secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on)
channel = 'hello_world'
authkey = "abcd"

def callback(message):
    print(message)

pubnub.grant(channel, authkey, True, True, callback=callback, error=callback)

pubnub.start()