Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 60 lines (49 sloc) 1.425 kb
06c2a51 Ivan Giuliani Added notification example application
authored
1 #!/usr/bin/env python
2 """
3 A simple notifier that shows a bubble notify when a rfid
4 tag is received
5 """
6
7 import sys
8 import pynotify
9 from rfidreader import RFIDReader
10
11 capabilities = {'actions': False,
12 'body': False,
13 'body-hyperlinks': False,
14 'body-images': False,
15 'body-markup': False,
16 'icon-multi': False,
17 'icon-static': False,
18 'sound': False,
19 'image/svg+xml': False,
20 'private-synchronous': False,
21 'append': False,
22 'private-icon-only': False}
23
24 def init_pynotify():
25 caps = pynotify.get_server_caps()
26 if not caps:
27 print "Failed to receive server caps."
28 sys.exit(True)
29
30 for cap in caps:
31 capabilities[cap] = True
32
33
34 def callback(rfid):
35 notify = pynotify.Notification(
36 "RFID tag received",
37 rfid.get_tag()
38 )
39 notify.show()
40
41 def main(args):
42 try:
43 port = args[1]
44 except IndexError:
45 print "Usage: %s <port>" % args[0]
46 return True
47
48 init_pynotify()
49 reader = RFIDReader(port)
50 reader.open()
51 try:
19de498 Ivan Giuliani Renamed run() to poll()
authored
52 reader.poll(callback)
06c2a51 Ivan Giuliani Added notification example application
authored
53 except KeyboardInterrupt:
54 reader.close()
55
56 return False
57
58 if __name__ == "__main__":
59 sys.exit(main(sys.argv))
Something went wrong with that request. Please try again.