Ejemplo n.º 1
0
    def test_basic_subscribe(self):
        self.doc1 = document.Document()
        self.sess1 = session.Session()
        self.sess1.use_doc('first')
        self.doc2 = document.Document()
        self.sess2 = session.Session()
        self.sess2.use_doc('second')
        #connect sock to defaultdoc
        #connect sock2 to defaultdoc
        #connect sock3 to defaultdoc2
        import websocket
        sock = websocket.WebSocket()
        connect(sock, ws_address, 'bokehplot:defaultdoc', 'nokey')
        sock2 = websocket.WebSocket()
        connect(sock2, ws_address, 'bokehplot:defaultdoc', 'nokey')

        sock3 = websocket.WebSocket()
        connect(sock3, ws_address, 'bokehplot:defaultdoc2', 'nokey')
        #make sure sock and sock2 receive message
        bokeh_app.publisher.send('bokehplot:defaultdoc', 'hello!')
        msg = sock.recv()
        assert msg == 'bokehplot:defaultdoc:hello!'
        msg = sock2.recv()
        assert msg == 'bokehplot:defaultdoc:hello!'

        # send messages on 2 topics, make sure that sockets receive
        # the right messages
        bokeh_app.publisher.send('bokehplot:defaultdoc', 'hello2!')
        bokeh_app.publisher.send('bokehplot:defaultdoc2', 'hello3!')
        msg = sock.recv()
        assert msg == 'bokehplot:defaultdoc:hello2!'
        msg = sock2.recv()
        assert msg == 'bokehplot:defaultdoc:hello2!'
        msg = sock3.recv()
        assert msg == 'bokehplot:defaultdoc2:hello3!'
Ejemplo n.º 2
0
 def setUp(self):
     super(TestSubscribeWebSocket, self).setUp()
     self.doc1 = document.Document()
     self.sess1 = session.Session()
     self.sess1.use_doc('first')
     self.doc2 = document.Document()
     self.sess2 = session.Session()
     self.sess2.use_doc('second')
Ejemplo n.º 3
0
    def test_basic_subscribe(self):
        self.sess1 = session.Session()
        self.sess1.use_doc('first')
        self.sess2 = session.Session()
        self.sess2.use_doc('second')
        #connect sock to defaultdoc
        #connect sock2 to defaultdoc
        #connect sock3 to defaultdoc2
        firstid = self.sess1.docid
        secondid = self.sess2.docid
        firsttoken = self.sess1.apikey
        secondtoken = self.sess2.apikey
        import websocket
        sock = websocket.WebSocket()
        connect(sock, ws_address, 'bokehplot:%s' % firstid, firsttoken)
        sock2 = websocket.WebSocket()
        connect(sock2, ws_address, 'bokehplot:%s' % firstid, firsttoken)

        sock3 = websocket.WebSocket()
        connect(sock3, ws_address, 'bokehplot:%s' % secondid, secondtoken)
        #make sure sock and sock2 receive message
        bokeh_app.publisher.send('bokehplot:%s' % firstid, 'hello!')
        msg = sock.recv()
        assert msg == 'bokehplot:%s:hello!' % firstid
        msg = sock2.recv()
        assert msg == 'bokehplot:%s:hello!' % firstid

        # send messages on 2 topics, make sure that sockets receive
        # the right messages
        bokeh_app.publisher.send('bokehplot:%s' % firstid, 'hello2!')
        bokeh_app.publisher.send('bokehplot:%s' % secondid, 'hello3!')
        msg = sock.recv()
        assert msg == 'bokehplot:%s:hello2!' % firstid
        msg = sock2.recv()
        assert msg == 'bokehplot:%s:hello2!' % firstid
        msg = sock3.recv()
        assert msg == 'bokehplot:%s:hello3!' % secondid
Ejemplo n.º 4
0
import sys
import time
import requests

from numpy import pi, sin, cos
import numpy as np

from bokeh.objects import (Plot, DataRange1d, LinearAxis, ColumnDataSource,
                           Glyph, PanTool, WheelZoomTool)
from bokeh.glyphs import Line

from bokeh import session
from bokeh import document

document = document.Document()
session = session.Session()
session.use_doc('line_animate')
session.load_document(document)

x = np.linspace(-2 * pi, 2 * pi, 1000)
x_static = np.linspace(-2 * pi, 2 * pi, 1000)
y = sin(x)
z = cos(x)

source = ColumnDataSource(data=dict(x=x, y=y, z=z, x_static=x_static))

xdr = DataRange1d(sources=[source.columns("x")])
xdr_static = DataRange1d(sources=[source.columns("x_static")])
ydr = DataRange1d(sources=[source.columns("y")])

line_glyph = Line(x="x", y="y", line_color="blue")