I try to run observe.py in IDLE.
/home/rafa/Desktop/gnuradio-compagnion/observe/observe.py’
Present on github.
File “/usr/local/lib/python2.7/dist-packages/bokeh/client/session.py”, line 369, in push
raise IOError(“Cannot push session document because we failed to connect
to the server (to start the server, try the ‘bokeh serve’ command)”)
IOError: Cannot push session document because we failed to connect to the server (to start the server, try the ‘bokeh serve’ command)
As you can see the issue is the connection with the server, but when i
try to connect typing in the ubuntu 16.04 terminal, bokeh serve, it works and when i try to plot a graph it works.
I can’t understand the issue there. i installed all dependencies and gr-bokehgui with the using source code.
Can you help me please ?
Thank you in advance .
In there the code observe.py:
#!/usr/bin/env python2
-- coding: utf-8 --
···
##################################################
GNU Radio Python Flow Graph
Title: Observe
Generated: Thu Apr 5 12:04:16 2018
##################################################
if name == ‘main’:
import ctypes
import sys
if sys.platform.startswith(‘linux’):
try:
x11 = ctypes.cdll.LoadLibrary(‘libX11.so’)
x11.XInitThreads()
except:
print “Warning: failed to XInitThreads()”
from bokeh.client import push_session
from bokeh.plotting import curdoc
from gnuradio import analog
from gnuradio import blocks
from gnuradio import eng_notation
from gnuradio import gr
from gnuradio.eng_option import eng_option
from gnuradio.filter import firdes
from optparse import OptionParser
import bokehgui
import functools
import signal
import time
class observe(gr.top_block):
def init(self, doc):
gr.top_block.init(self, “Observe”)
self.doc = doc
self.plot_lst =
self.widget_lst =
##################################################
# Variables
##################################################
self.samp_rate = samp_rate = 32000
##################################################
# Blocks
##################################################
self.bokehgui_time_sink_x_0 = bokehgui.time_sink_f_proc(1024, samp_rate, "", 1)
self.bokehgui_time_sink_x_0_plot = bokehgui.time_sink_f(self.doc, self.plot_lst, self.bokehgui_time_sink_x_0, is_message = False)
labels = ['', '', '', '', '',
'', '', '', '', '']
legend_list = []
for i in xrange(1):
if len(labels[i]) == 0:
legend_list.append("Data {0}".format(i))
else:
legend_list.append(labels[i])
self.bokehgui_time_sink_x_0_plot.initialize(log_x = False,
log_y = False,
update_time = 100,
legend_list = legend_list)
self.bokehgui_time_sink_x_0_plot.set_y_axis([-1, 1])
self.bokehgui_time_sink_x_0_plot.set_y_label('Amplitude')
self.bokehgui_time_sink_x_0_plot.set_x_label('Time')
self.bokehgui_time_sink_x_0_plot.enable_tags(-1, True)
self.bokehgui_time_sink_x_0_plot.set_trigger_mode(bokehgui.TRIG_MODE_FREE, bokehgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
self.bokehgui_time_sink_x_0_plot.enable_grid(False)
self.bokehgui_time_sink_x_0_plot.enable_axis_labels(True)
self.bokehgui_time_sink_x_0_plot.disable_legend(not True)
self.bokehgui_time_sink_x_0_plot.set_layout(*(((1,0))))
colors = ["blue", "red", "green", "black", "cyan",
"magenta", "yellow", "blue", "blue", "blue"]
widths = [1, 1, 1, 1, 1,
1, 1, 1, 1, 1]
styles = ["solid", "solid", "solid", "solid", "solid",
"solid", "solid", "solid", "solid", "solid"]
markers = [None, None, None, None, None,
None, None, None, None, None]
alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0]
for i in xrange(1):
self.bokehgui_time_sink_x_0_plot.format_line(i, colors[i], widths[i], styles[i], markers[i], alphas[i])
self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
self.blocks_add_xx_0 = blocks.add_vff(1)
self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)
self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, .01, 0)
if self.widget_lst:
input_t = bokehgui.BokehLayout.widgetbox(self.widget_lst)
widgetbox = bokehgui.BokehLayout.WidgetLayout(input_t)
widgetbox.set_layout(*((0, 0)))
list_obj = [widgetbox] + self.plot_lst
else:
list_obj = self.plot_lst
layout_t = bokehgui.BokehLayout.create_layout(list_obj, "fixed")
self.doc.add_root(layout_t)
##################################################
# Connections
##################################################
self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))
self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 0))
self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
self.connect((self.blocks_throttle_0, 0), (self.bokehgui_time_sink_x_0, 0))
def get_samp_rate(self):
return self.samp_rate
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.bokehgui_time_sink_x_0.set_samp_rate(self.samp_rate)
self.blocks_throttle_0.set_sample_rate(self.samp_rate)
self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
def main(top_block_cls=observe, options=None):
serverProc, port = bokehgui.utils.create_server()
def killProc(signum, frame, tb):
tb.stop()
tb.wait()
serverProc.terminate()
serverProc.kill()
time.sleep(1)
try:
# Define the document instance
doc = curdoc()
doc.title = "Observe"
session = push_session(doc, session_id="observe",
url = "http://localhost:" + port + "/bokehgui")
# Create Top Block instance
tb = top_block_cls(doc)
try:
tb.start()
signal.signal(signal.SIGTERM, functools.partial(killProc, tb=tb))
session.loop_until_closed()
finally:
print "Exiting the simulation. Stopping Bokeh Server"
tb.stop()
tb.wait()
finally:
serverProc.terminate()
serverProc.kill()
if name == ‘main’:
main()