-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendQueue.py
More file actions
33 lines (23 loc) · 855 Bytes
/
sendQueue.py
File metadata and controls
33 lines (23 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
import pika
<<<<<<< HEAD
credentials = pika.PlainCredentials('speedtest', '1nfield')
=======
import yaml
with open('/opt/speedtest/config.yaml', 'r') as f:
config = yaml.load(f)
username = config["message_server"]["username"]
password = config["message_server"]["password"]
credentials = pika.PlainCredentials(username, password)
>>>>>>> origin/raspberrypi
connection = pika.BlockingConnection(pika.ConnectionParameters(
'localhost', 5672, '/', credentials))
channel = connection.channel()
channel.queue_declare(queue='sendQueue')
print ' [*] Waiting for messages. To exit press CTRL+C'
def callback(ch, method, properties, body):
print " [x] Received %r" % (body,)
channel.basic_consume(callback,
queue='sendQueue',
no_ack=True)
channel.start_consuming()