mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-05-04 15:45:00 -04:00
make load_url handle arguments similarly to umbra
This commit is contained in:
parent
e9f6408881
commit
8eb92b28e6
1 changed files with 15 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# vim: set sw=4 et:
|
||||||
from json import dumps, loads
|
from json import dumps, loads
|
||||||
import os,sys,argparse, urllib.request, urllib.error, urllib.parse
|
import os,sys,argparse, urllib.request, urllib.error, urllib.parse
|
||||||
import websocket
|
import websocket
|
||||||
|
@ -7,10 +8,21 @@ import uuid
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
from kombu import Connection, Exchange, Queue
|
from kombu import Connection, Exchange, Queue
|
||||||
logging.basicConfig(level=logging.INFO)
|
|
||||||
|
logging.basicConfig(stream=sys.stdout, level=logging.INFO,
|
||||||
|
format='%(asctime)s %(process)d %(levelname)s %(threadName)s %(name)s.%(funcName)s(%(filename)s:%(lineno)d) %(message)s')
|
||||||
|
|
||||||
|
arg_parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),
|
||||||
|
description='load_url.py - send url to umbra via amqp',
|
||||||
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||||
|
arg_parser.add_argument('-u', '--url', dest='amqp_url', default='amqp://guest:guest@localhost:5672//',
|
||||||
|
help='URL identifying the amqp server to talk to')
|
||||||
|
arg_parser.add_argument('urls', metavar='URL', nargs='+', help='URLs to send to umbra')
|
||||||
|
args = arg_parser.parse_args(args=sys.argv[1:])
|
||||||
|
|
||||||
umbra_exchange = Exchange('umbra', 'direct', durable=True)
|
umbra_exchange = Exchange('umbra', 'direct', durable=True)
|
||||||
with Connection(sys.argv[1]) as conn:
|
with Connection(args.amqp_url) as conn:
|
||||||
producer = conn.Producer(serializer='json')
|
producer = conn.Producer(serializer='json')
|
||||||
for url in sys.argv[2:]:
|
for url in args.urls:
|
||||||
producer.publish({'url': url}, 'url', exchange=umbra_exchange)
|
producer.publish({'url': url}, 'url', exchange=umbra_exchange)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue