changeset 1:f867f7c3c2db

Move testclient to client/
author Lewin Bormann <lbo@spheniscida.de>
date Thu, 28 Feb 2019 18:19:09 +0100
parents 3508454a9a1a
children 61952d5a8718
files client/testclient.py testclient.py
diffstat 2 files changed, 45 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/client/testclient.py	Thu Feb 28 18:19:09 2019 +0100
@@ -0,0 +1,45 @@
+#!/usr/bin/env python3
+
+import zmq
+
+from matplotlib import figure
+from matplotlib.backends import backend_cairo
+
+ctx = zmq.Context()
+sock = ctx.socket(zmq.SUB)
+sock.setsockopt(zmq.IPV6, 1)
+sock.connect('tcp://[::1]:9988')
+sock.setsockopt_string(zmq.SUBSCRIBE, '')
+
+history = {}
+i = 0
+
+
+def draw_symbols():
+    for sym, hist in history.items():
+        fig = figure.Figure()
+        ax = fig.add_subplot(111)
+        ax.grid(True)
+        ax.set_xlim(0, len(hist))
+        ax.set_ybound(0, 100)
+        ax.plot([i for i in range(0, len(hist))], hist)
+        backend_cairo.FigureCanvas(fig).print_png('{}.png'.format(sym))
+
+while True:
+    i += 1
+    msg = sock.recv_json()
+    msg.pop('_stockdata')
+    for sym, val in sorted(msg.items()):
+        print(' {}: {:.2f}'.format(sym, val / 100.))
+        if sym in history:
+            history[sym].append(val/100.)
+            if len(history[sym]) > 500:
+                history[sym] = history[sym][1:]
+        else:
+            history[sym] = [val/100.]
+    print('')
+
+    if i > 25:
+        draw_symbols()
+        i = 0
+
--- a/testclient.py	Thu Feb 28 14:31:53 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-#!/usr/bin/env python3
-
-import zmq
-
-from matplotlib import figure
-from matplotlib.backends import backend_cairo
-
-ctx = zmq.Context()
-sock = ctx.socket(zmq.SUB)
-sock.setsockopt(zmq.IPV6, 1)
-sock.connect('tcp://[::1]:9988')
-sock.setsockopt_string(zmq.SUBSCRIBE, '')
-
-history = {}
-i = 0
-
-
-def draw_symbols():
-    for sym, hist in history.items():
-        fig = figure.Figure()
-        ax = fig.add_subplot(111)
-        ax.grid(True)
-        ax.set_xlim(0, len(hist))
-        ax.set_ybound(0, 100)
-        ax.plot([i for i in range(0, len(hist))], hist)
-        backend_cairo.FigureCanvas(fig).print_png('{}.png'.format(sym))
-
-while True:
-    i += 1
-    msg = sock.recv_json()
-    msg.pop('_stockdata')
-    for sym, val in sorted(msg.items()):
-        print(' {}: {:.2f}'.format(sym, val / 100.))
-        if sym in history:
-            history[sym].append(val/100.)
-            if len(history[sym]) > 500:
-                history[sym] = history[sym][1:]
-        else:
-            history[sym] = [val/100.]
-    print('')
-
-    if i > 25:
-        draw_symbols()
-        i = 0
-