Commits

Lars Yencken committed 8f813ed

Renames module and updates version to 0.2.0.

Comments (0)

Files changed (3)

 #
 #----------------------------------------------------------------------------#
 
-"Setup script for smartNotify module."
+"Setup script for smart_notify module."
 
 #----------------------------------------------------------------------------#
 
 import os
 from distutils.core import setup
 
-def get_hg_version():
-    version = None
-    if os.system('which hg >/dev/null 2>/dev/null') == 0:
-        version = os.popen('hg id -n 2>/dev/null').read().strip()
-    return version or 'unknown'
-
 #----------------------------------------------------------------------------#
 
+version = '0.2.0'
+
 setup(
-        name='smartNotify',
-        version='0.1.%s' % get_hg_version(),
-        py_modules=['smartNotify'],
-        scripts=['smartNotify.py']
+        name='smart_notify',
+        version='0.2.0',
+        py_modules=['smart_notify'],
+        scripts=['smart_notify.py']
     )

smartNotify.py

-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#----------------------------------------------------------------------------#
-# notify.py
-# Lars Yencken <lljy@csse.unimelb.edu.au>
-# vim: ts=4 sw=4 sts=4 et tw=78:
-# Tue Apr  8 16:15:50 EST 2008
-#
-#----------------------------------------------------------------------------#
-
-"Uses either pynotify or Growl to leave a transient note for the user."
-
-import os, sys, optparse
-
-#----------------------------------------------------------------------------#
-# PUBLIC
-#----------------------------------------------------------------------------#
- 
-def notify(title=None, message=None, appName='python shell'):
-    "Provide the user with a notification or fail silently."
-    try:
-        notifyUsingPynotify(title=title, message=message, appName=appName)
-        return
-    except ImportError:
-        pass
-
-    try:
-        notifyUsingGrowl(title=title, message=message, appName=appName)
-    except ImportError:
-        pass
-
-#----------------------------------------------------------------------------#
-
-def notifyUsingPynotify(appName=None, title=None, message=None):
-    import pynotify
-    pynotify.init(appName)
-    n = pynotify.Notification(title, message, "dialog-info")
-    n.set_urgency(pynotify.URGENCY_NORMAL)
-    n.set_timeout(pynotify.EXPIRES_DEFAULT)
-    n.show()
-    return
-
-#----------------------------------------------------------------------------#
-
-def notifyUsingGrowl(appName=None, title=None, message=None):
-    import Growl
-    n = Growl.GrowlNotifier(applicationName=appName, notifications=['info'])
-    n.register()
-    n.notify('info', title, message)
-    return
-
-#----------------------------------------------------------------------------#
-# PRIVATE
-#----------------------------------------------------------------------------#
-
-#----------------------------------------------------------------------------#
-# MODULE EPILOGUE
-#----------------------------------------------------------------------------#
-
-def _createOptionParser():
-    usage = \
-"""%prog [options] title message
-
-Uses either pynotify or Growl to display a status message to the user for a
-few seconds. If neither are available, this script fails silently."""
-
-    parser = optparse.OptionParser(usage)
-
-    parser.add_option('--debug', action='store_true', dest='debug',
-            default=False, help='Enables debugging mode [False]')
-
-    return parser
-
-#----------------------------------------------------------------------------#
-
-def main(argv):
-    parser = _createOptionParser()
-    (options, args) = parser.parse_args(argv)
-
-    try:
-        [title, message] = args
-    except:
-        parser.print_help()
-        sys.exit(1)
-
-    # Avoid psyco in debugging mode, since it merges stack frames.
-    if not options.debug:
-        try:
-            import psyco
-            psyco.profile()
-        except:
-            pass
-
-    notify(title=title, message=message, appName="Python shell")
-    
-    return
-
-#----------------------------------------------------------------------------#
-
-if __name__ == '__main__':
-    main(sys.argv[1:])
-
-#----------------------------------------------------------------------------#
-  
-# vim: ts=4 sw=4 sts=4 et tw=78:
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#----------------------------------------------------------------------------#
+# smart_notify.py
+# Lars Yencken <lljy@csse.unimelb.edu.au>
+# vim: ts=4 sw=4 sts=4 et tw=78:
+# Tue Apr  8 16:15:50 EST 2008
+#
+#----------------------------------------------------------------------------#
+
+"Uses either pynotify or Growl to leave a transient note for the user."
+
+import os, sys, optparse
+
+#----------------------------------------------------------------------------#
+# PUBLIC
+#----------------------------------------------------------------------------#
+ 
+def notify(title=None, message=None, app_name='python shell'):
+    "Provide the user with a notification or fail silently."
+    try:
+        _use_pynotify(title=title, message=message, app_name=app_name)
+        return
+    except ImportError:
+        pass
+
+    try:
+        _use_growl(title=title, message=message, app_name=app_name)
+    except ImportError:
+        pass
+
+#----------------------------------------------------------------------------#
+
+def _use_pynotify(app_name=None, title=None, message=None):
+    import pynotify
+    pynotify.init(app_name)
+    n = pynotify.Notification(title, message, "dialog-info")
+    n.set_urgency(pynotify.URGENCY_NORMAL)
+    n.set_timeout(pynotify.EXPIRES_DEFAULT)
+    n.show()
+    return
+
+#----------------------------------------------------------------------------#
+
+def _use_growl(app_name=None, title=None, message=None):
+    import Growl
+    n = Growl.GrowlNotifier(applicationName=app_name, notifications=['info'])
+    n.register()
+    n.notify('info', title, message)
+    return
+
+#----------------------------------------------------------------------------#
+# PRIVATE
+#----------------------------------------------------------------------------#
+
+#----------------------------------------------------------------------------#
+# MODULE EPILOGUE
+#----------------------------------------------------------------------------#
+
+def _createOptionParser():
+    usage = \
+"""%prog [options] title message
+
+Uses either pynotify or Growl to display a status message to the user for a
+few seconds. If neither are available, this script fails silently."""
+
+    parser = optparse.OptionParser(usage)
+
+    parser.add_option('--debug', action='store_true', dest='debug',
+            default=False, help='Enables debugging mode [False]')
+
+    return parser
+
+#----------------------------------------------------------------------------#
+
+def main(argv):
+    parser = _createOptionParser()
+    (options, args) = parser.parse_args(argv)
+
+    try:
+        [title, message] = args
+    except:
+        parser.print_help()
+        sys.exit(1)
+
+    notify(title=title, message=message, app_name="Python shell")
+    
+    return
+
+#----------------------------------------------------------------------------#
+
+if __name__ == '__main__':
+    main(sys.argv[1:])
+
+#----------------------------------------------------------------------------#
+  
+# vim: ts=4 sw=4 sts=4 et tw=78: