summaryrefslogtreecommitdiff
path: root/weechat_notify.py
diff options
context:
space:
mode:
Diffstat (limited to 'weechat_notify.py')
-rwxr-xr-xweechat_notify.py49
1 files changed, 0 insertions, 49 deletions
diff --git a/weechat_notify.py b/weechat_notify.py
deleted file mode 100755
index 897f26d..0000000
--- a/weechat_notify.py
+++ /dev/null
@@ -1,49 +0,0 @@
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4import json
5import urllib2
6import sched
7import sys
8import time
9
10import pynotify
11
12POLLING_FREQUENCY = 10
13NOTIFICATION_URL = 'https://simeon.simeonov.no:40004/notifications/'
14TIMEOUT_SEC = 3
15
16
17def poll_notifications(scheduler):
18 """
19 """
20 try:
21 req = urllib2.Request(NOTIFICATION_URL)
22 response = urllib2.urlopen(req)
23 response_str = response.read()
24
25 entries = json.loads(response_str)
26 for entry in entries:
27 n = pynotify.Notification('IRC', entry, 'dialog-information')
28 n.set_timeout(TIMEOUT_SEC)
29 n.show()
30
31 except Exception as e:
32 sys.stderr.write("Client error: {0}".format(e))
33 sys.exit(1)
34
35 scheduler.enter(POLLING_FREQUENCY, 1, poll_notifications, (scheduler,))
36
37
38def main():
39
40 if not pynotify.init("Weechat Notify"):
41 sys.stderr.write("There was a problem with libnotify")
42 sys.exit(1)
43
44 sc = sched.scheduler(time.time, time.sleep)
45 sc.enter(POLLING_FREQUENCY, 1, poll_notifications, (sc,))
46 sc.run()
47
48if __name__ == '__main__':
49 main()