This repository has been archived by the owner on Dec 28, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding emdr-gateway and emdr-snooper bin convenience commands.
- Loading branch information
Greg Taylor
committed
Apr 16, 2012
1 parent
a7354ee
commit c8f0e2d
Showing
7 changed files
with
86 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python | ||
""" | ||
WSGI gateway application. Runs using bottle+gevent. | ||
""" | ||
import argparse | ||
from bottle import run | ||
from emdr.conf import default_settings | ||
|
||
parser = argparse.ArgumentParser( | ||
description="The gateway accepts uploads from player uploader clients " \ | ||
"over HTTP. Market data is then sent to the broker.", | ||
) | ||
parser.add_argument( | ||
'--sender', action='append', dest='senders', | ||
help="Overrides default gateway sender bindings. This determines where " \ | ||
"the gateway sends its messages, typically a broker.") | ||
|
||
parsed = parser.parse_args() | ||
|
||
if parsed.senders: | ||
print("* Overriding default gateway sender bindings.") | ||
default_settings.GATEWAY_SENDER_BINDINGS = parsed.senders | ||
|
||
#noinspection PyUnresolvedReferences | ||
from emdr.daemons.gateway import wsgi | ||
|
||
# Fire up a bottle+gevent process. | ||
run( | ||
host='localhost', | ||
port=8080, | ||
server='gevent', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python | ||
""" | ||
CLI util used to attach to ZMQ sockets to listen to whatever is coming down. | ||
Currently hard-wired to SUB. | ||
""" | ||
import argparse | ||
import zlib | ||
import zmq | ||
import simplejson | ||
from pprint import pprint | ||
|
||
parser = argparse.ArgumentParser( | ||
description="Connects to a PUB ZMQ socket and prints whatever is coming" \ | ||
"out. ", | ||
) | ||
parser.add_argument('receiver', nargs=1, help="The ZMQ socket to connect to.") | ||
|
||
parsed = parser.parse_args() | ||
|
||
receiver_uri = parsed.receiver[0] | ||
|
||
context = zmq.Context() | ||
subscriber = context.socket(zmq.SUB) | ||
|
||
# Connect to the first publicly available relay. | ||
subscriber.connect(receiver_uri) | ||
# Disable filtering. | ||
subscriber.setsockopt(zmq.SUBSCRIBE, "") | ||
|
||
print("Connected to %s" % receiver_uri) | ||
|
||
while True: | ||
# Receive raw market JSON strings. | ||
market_json = zlib.decompress(subscriber.recv()) | ||
# Un-serialize the JSON data to a Python dict. | ||
market_data = simplejson.loads(market_json) | ||
# Dump the market data to stdout. Or, you know, do more fun | ||
# things here. | ||
pprint(market_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters