Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 30th, 2012  |  syntax: Python  |  size: 1.01 KB  |  views: 27  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import sys
  2.  
  3. import avro.ipc as ipc
  4. import avro.protocol as protocol
  5.  
  6. PROTOCOL = protocol.parse(open("flume.avpr").read())
  7.  
  8. server_addr = ('172.28.19.112', 41414)
  9.  
  10. class UsageError(Exception):
  11.     def __init__(self, value):
  12.         self.value = value
  13.     def __str__(self):
  14.         return repr(self.value)
  15.  
  16. if __name__ == '__main__':
  17.     if len(sys.argv) != 3:
  18.         raise UsageError("Usage: <category> <body>")
  19.  
  20.     print("Connecting to " + str(server_addr[0]) + ", " + str(server_addr[1]))
  21.     client = ipc.HTTPTransceiver(server_addr[0], server_addr[1])
  22.     requestor = ipc.Requestor(PROTOCOL, client)
  23.    
  24.     # fill in the Message record and send it
  25.     event = dict()
  26.     event['headers'] = dict()
  27.     event['headers']['category'] = sys.argv[1]
  28.     event['body'] = sys.argv[2]
  29.    
  30.     params = dict()
  31.     params['event'] = event
  32.     requestor.request('append', params)
  33.     #print("Result: " + requestor.request('append', params)))
  34.     print("done")
  35.    
  36.     # cleanup
  37.     client.close()
clone this paste RAW Paste Data