Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove growlnotify dependency, use gntplib, bump version

  • Loading branch information...
commit 7a431eff500b19661a4115558938b5c4034a1676 1 parent 5fdc312
@j4mie authored
Showing with 39 additions and 73 deletions.
  1. +4 −6 README.md
  2. +22 −56 nosegrowl2/__init__.py
  3. +13 −11 setup.py
View
10 README.md
@@ -2,18 +2,16 @@
**A simple Nose plugin for Growl notifications**
-Existing Growl plugins for Nose can be difficult to install, due to packaging problems
-and a dependency on the PyGrowl library, which is out of date on PyPI.
+Existing Growl plugins for Nose can be difficult to install, due to packaging problems and a dependency on the PyGrowl library, which is out of date on PyPI.
-This extremely simple plugin uses the command-line **growlnotify** tool to send its
-notifications. This should be installed from either
-[the official Growl site](http://growl.info/extras.php#growlnotify) or with
-[Homebrew](http://mxcl.github.com/homebrew/) (just run `brew install growlnotify`).
+This extremely simple plugin uses [gntplib](http://packages.python.org/gntplib/) to send its notifications.
To use this plugin, install with `pip install nosegrowl2`, then run `nosetests --with-growl`.
You may need to remove existing Nose Growl packages first.
+*Note*: prior to version 0.3, the `growlnotify` command-line tool was used to send notifications. As this is now deprecated and has been removed from Homebrew, nosegrowl2 now uses gntplib.
+
## (Un)license
This is free and unencumbered software released into the public domain.
View
78 nosegrowl2/__init__.py
@@ -1,51 +1,26 @@
import datetime
-import subprocess
-from warnings import warn
+from gntplib import Publisher, Resource
from nose.plugins import Plugin
-from pkg_resources import resource_filename
+from pkg_resources import resource_stream
-__version__ = '0.2'
-
+__version__ = '0.3'
+START_EVENT = 'Tests Starting'
START_TITLE = 'Starting tests...'
-START_ICON = resource_filename('nosegrowl2', 'start.png')
+START_ICON = Resource(resource_stream('nosegrowl2', 'start.png').read())
+SUCCESS_EVENT = 'Tests Passed'
SUCCESS_TITLE = '%s tests run OK'
SUCCESS_MESSAGE = 'Completed in %s.%s seconds'
-SUCCESS_ICON = resource_filename('nosegrowl2', 'success.png')
+SUCCESS_ICON = Resource(resource_stream('nosegrowl2', 'success.png').read())
+FAILURE_EVENT = 'Test Failures'
FAILURE_TITLE = '%s tests run. %s failures, %s errors'
-FAILURE_ICON = resource_filename('nosegrowl2', 'failure.png')
-
-
-def _check_growlnotify():
- """Check whether the growlnotify command-line tool is installed"""
- try:
- subprocess.check_call(
- ['growlnotify', '--version'],
- stderr=subprocess.STDOUT,
- stdout=subprocess.PIPE
- )
- return True
- except:
- warn(
- "Plugin NoseGrowl2 requires the command-line tool growlnotify. "
- "Please install from http://growl.info/extras.php#growlnotify "
- "or with `brew install growlnotify`."
- )
- return False
+FAILURE_ICON = Resource(resource_stream('nosegrowl2', 'failure.png').read())
-
-def _growl(title, message, icon):
- args = [
- 'growlnotify',
- '--title', title,
- '--message', message,
- '--image', icon,
- '--name', 'nosegrowl2',
- ]
- subprocess.call(args)
+publisher = Publisher('nosegrowl2', [START_EVENT, SUCCESS_EVENT, FAILURE_EVENT], icon=START_ICON)
+publisher.register()
class NoseGrowl(Plugin):
@@ -54,35 +29,26 @@ class NoseGrowl(Plugin):
def configure(self, options, conf):
super(NoseGrowl, self).configure(options, conf)
- self.enabled = _check_growlnotify()
def begin(self):
self.start_time = datetime.datetime.now()
- _growl(START_TITLE, '', START_ICON)
+ publisher.publish(START_EVENT, START_TITLE, '', icon=START_ICON)
def finalize(self, result):
self.end_time = datetime.datetime.now()
if result.wasSuccessful():
time_taken = self.end_time - self.start_time
- _growl(
- SUCCESS_TITLE % result.testsRun,
- SUCCESS_MESSAGE % (
- time_taken.seconds,
- time_taken.microseconds,
- ),
- SUCCESS_ICON
- )
+ title = SUCCESS_TITLE % result.testsRun
+ message = SUCCESS_MESSAGE % (time_taken.seconds,
+ time_taken.microseconds)
+ publisher.publish(SUCCESS_EVENT, title, message, icon=SUCCESS_ICON)
else:
failures = '\n'.join(["Failures: %s" % name for name, ex in result.failures])
errors = '\n'.join(["Errors: %s" % name for name, ex in result.errors])
- failure_message = '\n'.join([failures, errors])
- _growl(
- FAILURE_TITLE % (
- result.testsRun,
- len(result.failures),
- len(result.errors),
- ),
- failure_message,
- FAILURE_ICON
- )
+ message = '\n'.join([failures, errors])
+ title = FAILURE_TITLE % (result.testsRun,
+ len(result.failures),
+ len(result.errors))
+
+ publisher.publish(FAILURE_EVENT, title, message, icon=FAILURE_ICON)
View
24 setup.py
@@ -4,6 +4,7 @@
rel_file = lambda *args: os.path.join(os.path.dirname(os.path.abspath(__file__)), *args)
+
def read_from(filename):
fp = open(filename)
try:
@@ -11,31 +12,32 @@ def read_from(filename):
finally:
fp.close()
+
def get_version():
data = read_from(rel_file('nosegrowl2', '__init__.py'))
return re.search(r"__version__ = '([^']+)'", data).group(1)
setup(
name='nosegrowl2',
- description = 'A simple Nose plugin for Growl notifications. Requires the command-line growlnotify tool.',
+ description='A simple Nose plugin for Growl notifications.',
version=get_version(),
- packages = ['nosegrowl2'],
- include_package_data = True,
- package_data = {
+ packages=['nosegrowl2'],
+ include_package_data=True,
+ package_data={
'': ['*.png'],
},
author='Jamie Matthews',
- author_email = 'jamie.matthews@gmail.com',
- install_requires=['nose>=0.10'],
- url = 'https://github.com/j4mie/nosegrowl2',
- license = 'Public Domain',
- zip_safe = False,
- entry_points = {
+ author_email='jamie.matthews@gmail.com',
+ install_requires=['nose>=0.10', 'gntplib'],
+ url='https://github.com/j4mie/nosegrowl2',
+ license='Public Domain',
+ zip_safe=False,
+ entry_points={
'nose.plugins': [
'growl = nosegrowl2:NoseGrowl'
]
},
- classifiers = [
+ classifiers=[
'Programming Language :: Python',
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
Please sign in to comment.
Something went wrong with that request. Please try again.