Skip to content
Snippets Groups Projects
Commit b3d33372 authored by Ramin Yaghoubzadeh's avatar Ramin Yaghoubzadeh
Browse files

Updated ipaaca helper scripts:

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
parent 7100fcc8
No related branches found
No related tags found
No related merge requests found
...@@ -3,18 +3,33 @@ ...@@ -3,18 +3,33 @@
import time import time
import logging import logging
import ipaaca import ipaaca
import sys
def my_update_handler(iu, event_type, local): def my_update_handler(iu, event_type, local):
print(event_type+': '+str(iu)) print(event_type+': '+str(iu))
ob = ipaaca.OutputBuffer('CoolInformerOut') if len(sys.argv)<2:
ob.register_handler(my_update_handler) 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
iu_top = ipaaca.IU('murmlfile') print "Sending Message of category "+cate
iu_top.payload = {'data': 'HalloTest.us'} print " with payload "+str(pl)
#iu_top.payload = {'data': 'smile_7sec.us'}
ob = ipaaca.OutputBuffer('IUInjector')
ob.register_handler(my_update_handler)
iu_top = ipaaca.Message(cate)
iu_top.payload = pl
ob.add(iu_top) ob.add(iu_top)
print "Message sent."
time.sleep(1) time.sleep(0.3)
print "Done" print "done."
...@@ -3,16 +3,21 @@ ...@@ -3,16 +3,21 @@
import time import time
import logging import logging
import ipaaca import ipaaca
import sys
def my_update_handler(iu, event_type, local): def my_update_handler(iu, event_type, local):
t=time.localtime() t=time.localtime()
print str(t.tm_hour)+':'+str(t.tm_min)+':'+str(t.tm_sec), print str(t.tm_hour)+':'+str(t.tm_min)+':'+str(t.tm_sec),
print(event_type+': '+unicode(iu)) print(event_type+': '+unicode(iu))
ib = ipaaca.InputBuffer('SnifferIn', ['']) cats = []
if len(sys.argv)>1:
cats = sys.argv[1:]
ib = ipaaca.InputBuffer('SnifferIn', [''] if len(cats)==0 else cats)
ib.register_handler(my_update_handler) ib.register_handler(my_update_handler)
print("Listening for IU events of any category...") print("Listening for IU events of "+("any category..." if len(cats)==0 else "categories: "+' '.join(cats)))
print('') print('')
while True: while True:
time.sleep(1) time.sleep(1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment