-
-
Save joestringer/5043979 to your computer and use it in GitHub Desktop.
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
import sys | |
import pymongo | |
import rflib.defs as defs | |
import rflib.ipc.MongoIPC as MongoIPC | |
from rflib.ipc.RFProtocolFactory import RFProtocolFactory | |
def usage(): | |
print('Usage: %s <channel>' % sys.argv[0]) | |
print(' channel: "rfclient" or "rfproxy"') | |
sys.exit(1) | |
def parse_args(args=sys.argv): | |
if (len(sys.argv) < 2): | |
return None | |
if (args[1] == 'rfclient'): | |
return defs.RFCLIENT_RFSERVER_CHANNEL | |
if (args[1] == 'rfproxy'): | |
return defs.RFSERVER_RFPROXY_CHANNEL | |
return None | |
if __name__ == '__main__': | |
connection = pymongo.Connection('localhost', 27017) | |
db = connection[defs.MONGO_DB_NAME] | |
channel = parse_args() | |
if (channel == None): | |
usage() | |
factory = RFProtocolFactory() | |
for entry in db[channel].find(): | |
msg = MongoIPC.take_from_envelope(entry, factory) | |
print(msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment