-
Notifications
You must be signed in to change notification settings - Fork 3
/
rts2-unity-indicator-gi
executable file
·74 lines (60 loc) · 2.44 KB
/
rts2-unity-indicator-gi
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python
import sys
from gi.repository import Notify, Gtk, GLib
from gi.repository import AppIndicator3 as AppIndicator
import rts2.rtsapi
#from espeak import espeak
#espeak.set_parameter(rate, 120, False)
#espeak.Gender='f'
alarm='/root/meteostation/aaa.mp3'
server='http://lsstccd:8889'
jsonProxy = rts2.rtsapi.JSONProxy(server, 'petr', 'test')
PING_FREQUENCY = 10 # milliseconds
class Check_rts2_aag:
def __init__(self):
self.ind = AppIndicator.Indicator.new('rts2-unity-indicator', '/home/selen/Desktop/meteo-icon.png', AppIndicator.IndicatorCategory.OTHER)
self.ind.set_status(AppIndicator.IndicatorStatus.ACTIVE)
self.ind.set_attention_icon("/home/selen/Desktop/meteo-icon_bad.png")
self.n = None
Notify.init("RTS2 weather monitor")
self.menu_setup()
self.ind.set_menu(self.menu)
def callback_function(self, notification=None, action=None, data=None):
print "It worked"
espeak.cancel()
notification.close()
#return Gtk.ResponseType.CANCEL
return True
def menu_setup(self):
self.menu = Gtk.Menu()
self.quit_item = Gtk.MenuItem("Quit")
self.quit_item.connect("activate", self.quit)
self.quit_item.show()
self.menu.append(self.quit_item)
def main(self):
self.check_rts2meteo()
GLib.timeout_add(PING_FREQUENCY * 100, self.check_rts2meteo)
GLib.MainLoop().run()
def quit(self, widget):
sys.exit(0)
def check_rts2meteo(self):
self.ind.set_status(AppIndicator.IndicatorStatus.ATTENTION)
jsonProxy.refresh()
#wind_err=jsonProxy.getValueError("AAG", 'WIND_SPEED')
jsonProxy.refresh()
#if wind_err:
# self.ind.set_status(AppIndicator.IndicatorStatus.ATTENTION)
# #espeak.synth('Meteo Alarm: Wind Speed too high!')
# if self.n is None:
# self.n = Notify.Notification.new("METEO ALERT", "Wind Speed to high!","dialog-warning")
# self.n.set_urgency(Notify.Urgency.CRITICAL)
# self.n.set_timeout(Notify.EXPIRES_NEVER)
# self.n.add_action("reset_alarm","Reset Alarm", self.callback_function, None, None)
# self.n.show()
# print "After show"
#else:
# self.ind.set_status(appindicator.STATUS_ACTIVE)
return True
if __name__ == "__main__":
indicator = Check_rts2_aag()
indicator.main()