aboutsummaryrefslogtreecommitdiffstats
path: root/python-tornado/examples/here-now-example.py
blob: c701daff182b8b85010f81debac5d48d2accfd65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/zsh

local failmark="\e[31m✘\e[0m"
local passmark="\e[32m✔\e[0m"
local skipmark="\e[33m☡\e[0m"
local failed=0
local T=

if [[ ## www.pubnub.com - PubNub Real-time push service in the cloud.
# coding=utf8

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

## -----------------------------------
## PubNub 3.1 Real-time Push Cloud API
## -----------------------------------

import sys
from Pubnub import PubnubTornado 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, subscribe_key, secret_key, cipher_key, ssl_on)
crazy = 'hello_world'

## -----------------------------------------------------------------------
## History Example
## -----------------------------------------------------------------------


def here_now_complete(messages):
    print(messages)
    print(type(messages))
    pubnub.stop()

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

## -----------------------------------------------------------------------
## IO Event Loop
## -----------------------------------------------------------------------
pubnub.start()
="o">} \ else { print -n ' '$passmark' '; ((++pass)) }; print -n $T perl -ne '$score += $1 -1 if /Severity: (\d+)/; END { printf "%3d", $score }' "Test/${scriptfile:t:r}/perlcritic.log" 2>/dev/null print -n ' '$T if [[ $pass -lt 3 ]] { if [[ -n $allow_fail[$scriptfile:t:r] ]] { print -n ' '$skipmark' ' } \ else { print -n ' '$failmark' ' if [[ $failed -lt 254 ]] { ((++failed)) } } } \ else { print -n ' '$passmark' '; ((++pass)) echo 1>"Test/${scriptfile:t:r}/passed" } if [[ $+cached_run[(r)$scriptfile] -gt 0 ]] { print -n $T' (c)' } echo } exit $failed