Commits

Stefan Scherfke committed 6685720

Growl issue resolved.

Comments (0)

Files changed (7)

Tea Timer.wdgt/Scripts/Timer.js

         $('#soundPlayer').get(0).Play();
 	}
 	if (window.widget && (!type || type == 'growl') && alarm.growl) {
-		widget.system('/usr/bin/env python2.5 growl.py "' + title + '" "' 
+		widget.system('/usr/bin/env python growl.py "' + title + '" "' 
 				+ message + '"', null);
 	}
 	if (window.widget && (!type || type == 'voice') && alarm.voice != 'none') {

Tea Timer.wdgt/growl.py

-#!/usr/bin/env python2.5
+#!/usr/bin/env python
 # encoding: utf-8
+
 """
 growl.py
 
 Notify the user via Growl that his tea (or what else) is ready. There is a
 fallback with AppleScript if the Growl python binding somehow can’t be imported.
+
 """
 
 import sys
-import os
 
-pyGrowl = False
+
+py_growl = False
 try:
-	from lib import Growl
-	pyGrowl = True
+    from lib import Growl
+    py_growl = True
 except ImportError:
 	pass
 
 
-def pyNotify(title, message, icon):
-	"""
-	Notifies the user via the Growl python binding.
-	
-	@param title: The title for the notification.
-	@type title:  string
-	@param message: The message/description for the notification.
-	@type message:  string
-	@param icon: The path of the notification icon relativ to this script.
-	@type icon:  string
-	"""
-	icon = Growl.Image.imageFromPath(icon)
-	notifier = Growl.GrowlNotifier(
-			applicationName = 'Tea Timer', 
-			notifications = ['TimerTargetReached'], 
-			applicationIcon = icon)
-	notifier.register()
-	notifier.notify('TimerTargetReached', title, message)
-	
-def asNotify(title, message, icon):
-	"""
-	Notifies the user via an AppleScript.
-	
-	@param title: The title for the notification.
-	@type title:  string
-	@param message: The message/description for the notification.
-	@type message:  string
-	@param icon: The path of the notification icon relativ to this script.
-	@type icon:  string
-	"""
-	iconPath = os.getcwd() + '/' + icon
-	os.system('/usr/bin/osascript growl.scpt "' + title + '" "' + message 	
-			+ '" "' + os.getcwd() + '/' + icon + '"')
+def py_notify(title, message, icon):
+    """Notifies the user via the Growl python binding."""
+    icon = Growl.Image.imageFromPath(icon)
+    notifier = Growl.GrowlNotifier(
+            applicationName = 'Tea Timer',
+            notifications = ['TimerTargetReached'],
+            applicationIcon = icon
+    )
+    notifier.register()
+    notifier.notify('TimerTargetReached', title, message)
+
+def as_notify(title, message, icon):
+    """Notifies the user via an AppleScript."""
+    from os import getcwd
+    from os.path import join
+    import subprocess
+
+    icon = join(getcwd(), icon)
+    cmd = ['/usr/bin/osascript', 'growl.scpt', title, message, icon]
+    subprocess.call(cmd)
 
 def main(argv):
-	"""
-	Notify the user via the Growl python binding if the module could be loaded
-	or via an AppleScript.
-	
-	@param argv: The command line args.
-	@type argv:  list of string
-	"""
-	print 'py' if pyGrowl else 'as'
-	icon = 'Images/alarmclock.png'
-	if pyGrowl:
-		pyNotify(argv[1], argv[2], icon)
-	else:
-		asNotify(argv[1], argv[2], icon)
+    """
+    Notify the user via the Growl python binding if the module could be loaded
+    or via an AppleScript.
+
+    """
+    icon = 'Images/alarmclock.png'
+    fn = py_notify if py_growl else as_notify
+    fn(argv[1], argv[2], icon)
 
 
 if __name__ == '__main__':
-	if len(sys.argv) > 1:
-		exit(main(sys.argv))
-	else:
-		exit(2)
+    if len(sys.argv) > 1:
+      exit(main(sys.argv))
+    else:
+      exit(2)
 	

Tea Timer.wdgt/growl.scpt

Binary file modified.

Tea Timer.wdgt/lib/Growl.pyc

Binary file modified.

Tea Timer.wdgt/lib/__init__.pyc

Binary file modified.

Tea Timer.wdgt/lib/_growl.so

Binary file modified.

Tea Timer.wdgt/lib/_growlImage.so

Binary file modified.