forked from lyonbros/faxrobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworker.py
executable file
·27 lines (19 loc) · 877 Bytes
/
worker.py
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
import os
import redis
from rq import Worker, Queue, Connection
import sys
import argparse
parser = argparse.ArgumentParser(description='Run the Fax Robot Worker.')
parser.add_argument('--listen', nargs=1, help='Listen queue: high|default|low')
parser.add_argument('--device', nargs=1, help='Modem device to use for faxing')
args = parser.parse_args()
listen = args.listen if args.listen else ['high', 'default', 'low']
# JL TODO ~ Fix this horrible hack. We should not modify Python's __builtin__.
MODEM_DEVICE = args.device[0] if args.device else '/dev/ttyUSB0'
print >> sys.stderr, "Binding to modem device: " + MODEM_DEVICE
conn = redis.from_url(os.environ.get('REDIS_URI'))
if __name__ == '__main__':
with Connection(conn):
Worker.MODEM_DEVICE = MODEM_DEVICE
worker = Worker(map(Queue, listen))
worker.work()