Skip to content
Snippets Groups Projects
  • Ramin Yaghoubzadeh's avatar
    b3d33372
    Updated ipaaca helper scripts: · b3d33372
    Ramin Yaghoubzadeh authored
    ipaaca-iu-sniffer optionally takes a list of category arguments
    (if not specified, it still listens for everything).
    ipaaca-iu-injector needs to be provided with a category name
    and, optionally, with key-value pairs for the payload, as such:
    $ ipaaca-iu-injector  murmlfile  data  smile_3sec.us
    b3d33372
    History
    Updated ipaaca helper scripts:
    Ramin Yaghoubzadeh authored
    ipaaca-iu-sniffer optionally takes a list of category arguments
    (if not specified, it still listens for everything).
    ipaaca-iu-injector needs to be provided with a category name
    and, optionally, with key-value pairs for the payload, as such:
    $ ipaaca-iu-injector  murmlfile  data  smile_3sec.us
ipaaca-iu-injector.py 695 B
#!/usr/bin/env python

import time
import logging
import ipaaca
import sys

def my_update_handler(iu, event_type, local):
	print(event_type+': '+str(iu))

if len(sys.argv)<2:
	print "Please use the program as follows:"
	print " "+sys.argv[0]+" <categoryname> [<payloadkey> <payloadvalue>] [<k2> <v2>] ..."
	sys.exit(1)

cate = sys.argv[1]
idx=2
pl={}
while len(sys.argv)>idx+1:
	pl[sys.argv[idx]] = sys.argv[idx+1]
	idx+=2

print "Sending Message of category "+cate
print " with payload "+str(pl)

ob = ipaaca.OutputBuffer('IUInjector')
ob.register_handler(my_update_handler)
iu_top = ipaaca.Message(cate)
iu_top.payload = pl
ob.add(iu_top)
print "Message sent."

time.sleep(0.3)
print "done."