summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshymad <czilukim@o2.pl>2018-05-03 19:08:16 +0200
committerAshymad <czilukim@o2.pl>2018-05-03 19:08:16 +0200
commit44ac4a411243a23023fa0492714c573ae900e8ec (patch)
tree0921b900c785ee4ffe668bc862161d458a0482a6
Example data semder
-rwxr-xr-xsender.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/sender.py b/sender.py
new file mode 100755
index 0000000..6dbd8b3
--- /dev/null
+++ b/sender.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python3
+
+import uuid
+import time
+import random
+import sys
+import signal
+
+from kombu import Connection, Producer, Exchange, Queue
+
+def sigint_handler(signal, frame):
+ print('Exiting...')
+ global loop
+ loop = False
+
+signal.signal(signal.SIGINT, sigint_handler)
+
+piid = 'pc.' + str(uuid.uuid1().node)
+
+print("Starting with id: " + piid)
+
+exch = Exchange('raspi-live', type='direct')
+
+loop = True
+
+with Connection('amqp://guest:guest@SKRADAK') as conn:
+ channel = conn.channel()
+ producer = Producer(channel)
+
+ while loop:
+ producer.publish(
+ {
+ 'x': random.randrange(-2**15, 2**15-1),
+ 'y': random.randrange(-2**15, 2**15-1),
+ 'z': random.randrange(-2**15, 2**15-1),
+ },
+ retry=True,
+ exchange=exch,
+ routing_key=piid,
+ )
+ time.sleep(1)
+