From 60f47b04174d016cc86c6e06fdaf0794c3d14216 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Wed, 7 May 2014 22:28:48 +0200 Subject: Git server / generic client and weechat client completed --- weechat_notify.py | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100755 weechat_notify.py (limited to 'weechat_notify.py') 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 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import json -import urllib2 -import sched -import sys -import time - -import pynotify - -POLLING_FREQUENCY = 10 -NOTIFICATION_URL = 'https://simeon.simeonov.no:40004/notifications/' -TIMEOUT_SEC = 3 - - -def poll_notifications(scheduler): - """ - """ - try: - req = urllib2.Request(NOTIFICATION_URL) - response = urllib2.urlopen(req) - response_str = response.read() - - entries = json.loads(response_str) - for entry in entries: - n = pynotify.Notification('IRC', entry, 'dialog-information') - n.set_timeout(TIMEOUT_SEC) - n.show() - - except Exception as e: - sys.stderr.write("Client error: {0}".format(e)) - sys.exit(1) - - scheduler.enter(POLLING_FREQUENCY, 1, poll_notifications, (scheduler,)) - - -def main(): - - if not pynotify.init("Weechat Notify"): - sys.stderr.write("There was a problem with libnotify") - sys.exit(1) - - sc = sched.scheduler(time.time, time.sleep) - sc.enter(POLLING_FREQUENCY, 1, poll_notifications, (sc,)) - sc.run() - -if __name__ == '__main__': - main() -- cgit v1.3