forked from refractionPOINT/python-limacharlie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_spout.py
30 lines (23 loc) · 847 Bytes
/
demo_spout.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import limacharlie
import json
import signal
import sys
import getpass
if __name__ == "__main__":
def signal_handler(signal, frame):
global sp
print( 'You pressed Ctrl+C!' )
sp.shutdown()
sys.exit( 0 )
signal.signal( signal.SIGINT, handler=signal_handler )
def debugPrint( msg ):
print( msg )
# This example uses interactive credentials, but see the README for alternative
# ways of getting credentials.
man = limacharlie.Manager( oid = raw_input( 'Enter OID: ' ),
secret_api_key = getpass.getpass( prompt = 'Enter secret API key: ' ),
print_debug_fn = debugPrint )
sp = limacharlie.Spout( man, 'event' )
while True:
data = sp.queue.get()
print( json.dumps( data, indent = 2 ) + "\n\n" )