From: Geoffrey Thomas Date: Sun, 1 Mar 2009 08:23:58 +0000 (-0500) Subject: avoid importing pynotify more than once X-Git-Url: https://snippets.scripts.mit.edu/gitweb.cgi/Scripts/git/.git/commitdiff_plain/f9d64b9ddda45bddfaf1267730b1b427de88c975 avoid importing pynotify more than once --- diff --git a/barn-growl/barn-growl.py b/barn-growl/barn-growl.py index 546cd69..799ea33 100755 --- a/barn-growl/barn-growl.py +++ b/barn-growl/barn-growl.py @@ -21,6 +21,7 @@ class Notifier(AbstractConsumer): import pynotify pynotify.init("Zephyr") self.pings = {} + self.pynotify = pynotify self.useprint = useprint return def feed(self, s): @@ -52,10 +53,9 @@ class Notifier(AbstractConsumer): g.stdin.write(message) g.stdin.close() if self.usenotify: - import pynotify if id in self.pings: self.pings[id].close() - self.pings[id] = pynotify.Notification(header, message) + self.pings[id] = self.pynotify.Notification(header, message) self.pings[id].show() def close(self): return