Commits

pombredanne committed b5d35ee

Imported from svn by Bitbucket

Comments (0)

Files changed (61)

+=======
+Checker
+=======
+
+For full documentation please see:
+http://www.simplistix.co.uk/software/python/checker
+
+If working offline, please consult the documentation source in the
+`docs` directory.
+
+Licensing
+=========
+
+Copyright (c) 2009 Simplistix Ltd
+See docs/license.txt for details.

tags/1.0/bootstrap.py

+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id: bootstrap.py 85041 2008-03-31 15:57:30Z andreasjung $
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+try:
+    import pkg_resources
+except ImportError:
+    ez = {}
+    exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+                         ).read() in ez
+    ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+    import pkg_resources
+
+if sys.platform == 'win32':
+    def quote(c):
+        if ' ' in c:
+            return '"%s"' % c # work around spawn lamosity on windows
+        else:
+            return c
+else:
+    def quote (c):
+        return c
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+ws  = pkg_resources.working_set
+assert os.spawnle(
+    os.P_WAIT, sys.executable, quote (sys.executable),
+    '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout',
+    dict(os.environ,
+         PYTHONPATH=
+         ws.find(pkg_resources.Requirement.parse('setuptools')).location
+         ),
+    ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)

tags/1.0/buildout.cfg

+# This buildout is used for development of checker.
+# It gets the necessary eggs and creates a test runner and a python
+# interpreter.
+
+[buildout]
+develop = .
+parts = test py docs
+versions = versions
+
+[versions]
+zope.testing = 3.8.3
+
+[py]
+recipe = zc.recipe.egg
+eggs = execute
+interpreter = py
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = execute [test]
+
+[docs]
+recipe = zc.recipe.egg
+eggs =  
+  execute
+  sphinx
+  sphinx-pypi-upload
+  zc.rst2
+  pkginfo
+interpreter = docpy

tags/1.0/docs/Makefile

+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = ../bin/sphinx-build
+PAPER         =
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html      to make standalone HTML files"
+	@echo "  dirhtml   to make HTML files named index.html in directories"
+	@echo "  pickle    to make pickle files"
+	@echo "  json      to make JSON files"
+	@echo "  htmlhelp  to make HTML files and a HTML help project"
+	@echo "  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  changes   to make an overview of all changed/added/deprecated items"
+	@echo "  linkcheck to check all external links for integrity"
+	@echo "  doctest   to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	-rm -rf _build/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html
+	@echo
+	@echo "Build finished. The HTML pages are in _build/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) _build/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in _build/dirhtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) _build/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in _build/htmlhelp."
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in _build/latex."
+	@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
+	      "run these through (pdf)latex."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) _build/changes
+	@echo
+	@echo "The overview file is in _build/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) _build/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in _build/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) _build/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in _build/doctest/output.txt."

tags/1.0/docs/api.txt

+API Reference
+=============
+
+.. automodule:: execute
+   :members:
+   :undoc-members:
+   :inherited-members:
+   :show-inheritance:

tags/1.0/docs/changes.txt

+Changes
+=======
+1.0 (06 Jul 2010)
+-----------------
+
+- Initial Release

tags/1.0/docs/conf.py

+# -*- coding: utf-8 -*-
+import sys, os, pkginfo, datetime
+
+pkg_info = pkginfo.Develop(os.path.join(os.path.dirname(__file__),'..'))
+
+extensions = [
+    'sphinx.ext.autodoc',
+    'sphinx.ext.intersphinx'
+    ]
+
+intersphinx_mapping = {'http://docs.python.org/dev': None}
+
+# General
+source_suffix = '.txt'
+master_doc = 'index'
+project = pkg_info.name
+copyright = '%s Simplistix Ltd' % datetime.datetime.now().year
+version = release = pkg_info.version
+exclude_trees = ['_build']
+unused_docs = ['description']
+pygments_style = 'sphinx'
+
+# Options for HTML output
+html_theme = 'default'
+htmlhelp_basename = project+'doc'
+
+# Options for LaTeX output
+latex_documents = [
+  ('index',project+'.tex', project+u' Documentation',
+   'Simplistix Ltd', 'manual'),
+]
+

tags/1.0/docs/description.txt

+=======
+Execute
+=======
+
+This is a collection of common patterns (and initially only one pattern!)
+for running executables in a sub-process using the ``subprocess``
+module.
+
+For documentation, see `http://packages.python.org/execute`__
+
+__ http://packages.python.org/execute

tags/1.0/docs/development.txt

+Development
+===========
+
+.. highlight:: bash
+
+Once you've obtained a source checkout, you can follow these
+instructions to perform various development tasks:
+
+Setting up the buildout
+-----------------------
+
+All development requires that you run the buildout::
+
+  $ python bootstrap.py
+  $ bin/buildout
+
+Running the tests
+-----------------
+
+Once you have a buildout, the tests can be run as follows::
+
+  $ bin/test
+
+Building the documentation
+--------------------------
+
+The Sphinx documentation is built by doing the following from the
+directory containg setup.py::
+
+  $ cd docs
+  $ make html
+
+Making a release
+----------------
+
+The first thing to do when making a release is to check that the ReST
+to be uploaded to PyPI is valid::
+
+  $ bin/docpy setup.py --long-description | bin/rst2 html \
+    --link-stylesheet \
+    --stylesheet=http://www.python.org/styles/styles.css > dist/desc.html
+
+Once you're certain everything is as it should be, the following will
+build the distribution, upload it to PyPI, register the metadata with
+PyPI and upload the Sphinx documentation to PyPI::
+
+  $ bin/buildout -o
+  $ bin/docpy setup.py sdist upload register upload_sphinx --upload-dir=docs/_build/html
+
+The ``bin/buildout`` will make sure the correct package information is
+used.
+
+This should all be done on a unix box so that a `.tgz` source
+distribution is produced.

tags/1.0/docs/index.txt

+Execute documentation
+=====================
+
+.. toctree::
+   :maxdepth: 2
+
+   installation.txt
+   use.txt
+   api.txt
+   development.txt
+   changes.txt
+   license.txt
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+

tags/1.0/docs/installation.txt

+Installation Instructions
+=========================
+
+The easyiest way to install Execute is::
+
+  easy_install execute
+
+Or, if you're using `zc.buildout`, just specify ``execute`` as a
+required egg. 

tags/1.0/docs/license.txt

+=======
+License
+=======
+
+Copyright (c) 2010 Simplistix Ltd
+
+Permission is hereby granted, free of charge, to any person 
+obtaining a copy of this software and associated documentation 
+files (the "Software"), to deal in the Software without restriction, 
+including without limitation the rights to use, copy, modify, merge, 
+publish, distribute, sublicense, and/or sell copies of the Software, 
+and to permit persons to whom the Software is furnished to do so, 
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be 
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 
+BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
+SOFTWARE.

tags/1.0/docs/make.bat

+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+set SPHINXBUILD=..\bin\sphinx-build
+set ALLSPHINXOPTS=-d _build/doctrees %SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+	set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+	:help
+	echo.Please use `make ^<target^>` where ^<target^> is one of
+	echo.  html      to make standalone HTML files
+	echo.  dirhtml   to make HTML files named index.html in directories
+	echo.  pickle    to make pickle files
+	echo.  json      to make JSON files
+	echo.  htmlhelp  to make HTML files and a HTML help project
+	echo.  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+	echo.  changes   to make an overview over all changed/added/deprecated items
+	echo.  linkcheck to check all external links for integrity
+	echo.  doctest   to run all doctests embedded in the documentation if enabled
+	goto end
+)
+
+if "%1" == "clean" (
+	for /d %%i in (_build\*) do rmdir /q /s %%i
+	del /q /s _build\*
+	goto end
+)
+
+if "%1" == "html" (
+	%SPHINXBUILD% -b html %ALLSPHINXOPTS% _build/html
+	echo.
+	echo.Build finished. The HTML pages are in _build/html.
+	goto end
+)
+
+if "%1" == "dirhtml" (
+	%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% _build/dirhtml
+	echo.
+	echo.Build finished. The HTML pages are in _build/dirhtml.
+	goto end
+)
+
+if "%1" == "pickle" (
+	%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% _build/pickle
+	echo.
+	echo.Build finished; now you can process the pickle files.
+	goto end
+)
+
+if "%1" == "json" (
+	%SPHINXBUILD% -b json %ALLSPHINXOPTS% _build/json
+	echo.
+	echo.Build finished; now you can process the JSON files.
+	goto end
+)
+
+if "%1" == "htmlhelp" (
+	%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% _build/htmlhelp
+	echo.
+	echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in _build/htmlhelp.
+	goto end
+)
+
+if "%1" == "latex" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% _build/latex
+	echo.
+	echo.Build finished; the LaTeX files are in _build/latex.
+	goto end
+)
+
+if "%1" == "changes" (
+	%SPHINXBUILD% -b changes %ALLSPHINXOPTS% _build/changes
+	echo.
+	echo.The overview file is in _build/changes.
+	goto end
+)
+
+if "%1" == "linkcheck" (
+	%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% _build/linkcheck
+	echo.
+	echo.Link check complete; look for any errors in the above output ^
+or in _build/linkcheck/output.txt.
+	goto end
+)
+
+if "%1" == "doctest" (
+	%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% _build/doctest
+	echo.
+	echo.Testing of doctests in the sources finished, look at the ^
+results in _build/doctest/output.txt.
+	goto end
+)
+
+:end

tags/1.0/docs/use.txt

+Using Execute
+=============
+
+Execute currently only provides one pattern of sub-process
+execution. That pattern is covered by the :func:`~execute.simple`
+function described below.
+
+Simple
+------
+
+The :func:`~execute.simple` function provides a simple way to run an
+executable in a sub-process that requires no input and where you'd
+like the output of both the standard and error output streams combined
+and returned in one string.
+
+For example, suppose you needed to execute the following python script
+in a sub-process::
+
+  import sys
+  print sys.argv[1:]
+  sys.stdout.flush()
+  sys.stderr.write('An error occurred!\n')
+
+.. -> source
+
+.. invisible-code-block: python
+
+   path = temp_dir.write('test.py',source,path=True)
+
+As an aside, it's unlikely you'd want to do this. It's much more
+likely that you'd want to use :func:`~execute.simple` to run something
+that wasn't written in python.
+
+However, if ``python`` contained the path to the python executable
+you'd want to use to run the above script, and ``path`` contained the
+path to the script on disk, you could use :func:`~execute.simple` to
+run it and capture the output as follows: 
+
+>>> from execute import simple
+>>> output = simple(' '.join((python,path,'x=1 --y=2 a b')))
+
+You now have the output in a string and you can do whatever you like
+with it:
+
+>>> print output
+['x=1', '--y=2', 'a', 'b']
+An error occurred!
+<BLANKLINE>

tags/1.0/execute/__init__.py

+# Copyright (c) 2010 Simplistix Ltd
+#
+# See license.txt for more details.
+
+from subprocess import Popen,PIPE,STDOUT
+
+def simple(command,cwd=None):
+    """Execute the command specified in a sub-process.
+
+    This command must take no input. Any output to either
+    the standard or error streams will be collected and
+    returned as a string.
+
+    :param command:
+      A string containing the command to be executed.
+
+    :param cwd:
+      An optional current working directory in which to
+      run the command. If not specified, the current working
+      directory will be left as-is.
+     
+    :returns:
+      A string containing anything written to the standard
+      or error streams by the command as it runs.
+    
+    """
+    return Popen(
+        command,
+        stderr=STDOUT,
+        stdout=PIPE,
+        universal_newlines=True,
+        cwd=cwd,
+        shell=True,
+        ).communicate()[0]

tags/1.0/execute/tests/__init__.py

Empty file added.

tags/1.0/execute/tests/test_docs.py

+# Copyright (c) 2010 Simplistix Ltd
+#
+# See license.txt for more details.
+
+import sys
+
+from doctest import REPORT_NDIFF,ELLIPSIS
+from glob import glob
+from manuel import doctest,codeblock,capture
+from manuel.testing import TestSuite
+from os.path import dirname,join,pardir
+from testfixtures import TempDirectory
+
+def setUp(test):
+    test.globs['temp_dir']=TempDirectory()
+    test.globs['python']=sys.executable
+
+def tearDown(test):
+    TempDirectory.cleanup_all()
+    
+def test_suite():
+    m =  doctest.Manuel(optionflags=REPORT_NDIFF|ELLIPSIS)
+    m += codeblock.Manuel()
+    m += capture.Manuel()
+
+    return TestSuite(
+        m,
+        setUp=setUp,
+        tearDown=tearDown,
+        *glob(join(dirname(__file__),pardir,pardir,'docs','*.txt'))
+        )

tags/1.0/execute/tests/test_simple.py

+# Copyright (c) 2010 Simplistix Ltd
+#
+# See license.txt for more details.
+from __future__ import with_statement
+
+import sys
+
+from execute import simple
+from mock import Mock
+from subprocess import PIPE,STDOUT
+from testfixtures import tempdir,compare,Replacer
+from unittest import TestSuite,TestCase,makeSuite
+
+class TestSimple(TestCase):
+
+    @tempdir()
+    def test_out_and_err(self,d):
+        # without the flushes, the order comes out wrong
+        path = d.write('test.py','\n'.join((
+                "import sys",
+                "sys.stdout.write('stdout\\n')",
+                "sys.stdout.flush()",
+                "sys.stderr.write('stderr\\n')",
+                "sys.stderr.flush()",
+                "sys.stdout.write('stdout2\\n')",
+                "sys.stdout.flush()",
+                )),path=True)
+        compare('stdout\nstderr\nstdout2\n',
+                simple(sys.executable+' '+path))
+    
+    @tempdir()
+    def test_args(self,d):
+        path = d.write('test.py','\n'.join((
+                "import sys",
+                "print sys.argv",
+                )),path=True)
+        compare("[%r, 'x=1', '--y=2', 'a', 'b']\n" % path,
+                simple(sys.executable+' '+path+' x=1 --y=2 a b'))
+    
+    @tempdir()
+    def test_working_directory(self,d):
+        dir = d.makedir('a_dir',path=True)
+        path = d.write('test.py','\n'.join((
+                "import os",
+                "print os.getcwd()",
+                )),path=True)
+        compare(dir+'\n',
+                simple(sys.executable+' '+path,cwd=dir))
+
+    def test_popen_params(self):
+        m = Mock()
+        m.Popen.return_value = m.Popeni
+        m.Popeni.communicate.return_value=('','')
+        with Replacer() as r:
+            r.replace('execute.Popen',m.Popen)
+            simple('something')
+        compare(m.method_calls,[
+                ('Popen',
+                 ('something',),
+                 {'cwd': None,
+                  'shell': True,
+                  'stderr': STDOUT,
+                  'stdout': PIPE,
+                  'universal_newlines': True}),
+                ('Popeni.communicate', (), {})
+                ])
+    
+def test_suite():
+    return TestSuite((
+        makeSuite(TestSimple),
+        ))
+# Copyright (c) 2010 Simplistix Ltd
+# See license.txt for license details.
+
+import os
+from setuptools import setup, find_packages
+
+package_name = 'execute'
+version = '1.0'
+base_dir = os.path.dirname(__file__)
+
+setup(
+    name=package_name,
+    version=version,
+    author='Chris Withers',
+    author_email='chris@simplistix.co.uk',
+    license='MIT',
+    description="Common patterns for executing commands as sub processes",
+    long_description=open(os.path.join(base_dir,'docs','description.txt')).read(),
+    url='http://packages.python.org/execute',
+    classifiers=[
+    'Development Status :: 5 - Production/Stable',
+    'Intended Audience :: Developers',
+    'License :: OSI Approved :: MIT License',
+    ],    
+    packages=find_packages(),
+    zip_safe=False,
+    extras_require=dict(
+        test=[
+            'manuel',
+            'mock',
+            'testfixtures',
+            ],
+        )
+    )
+=======
+Checker
+=======
+
+For full documentation please see:
+http://www.simplistix.co.uk/software/python/checker
+
+If working offline, please consult the documentation source in the
+`docs` directory.
+
+Licensing
+=========
+
+Copyright (c) 2009 Simplistix Ltd
+See docs/license.txt for details.

tags/1.2/bootstrap.py

+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id: bootstrap.py 85041 2008-03-31 15:57:30Z andreasjung $
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+try:
+    import pkg_resources
+except ImportError:
+    ez = {}
+    exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+                         ).read() in ez
+    ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+    import pkg_resources
+
+if sys.platform == 'win32':
+    def quote(c):
+        if ' ' in c:
+            return '"%s"' % c # work around spawn lamosity on windows
+        else:
+            return c
+else:
+    def quote (c):
+        return c
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+ws  = pkg_resources.working_set
+assert os.spawnle(
+    os.P_WAIT, sys.executable, quote (sys.executable),
+    '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout',
+    dict(os.environ,
+         PYTHONPATH=
+         ws.find(pkg_resources.Requirement.parse('setuptools')).location
+         ),
+    ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)

tags/1.2/buildout.cfg

+# This buildout is used for development of checker.
+# It gets the necessary eggs and creates a test runner and a python
+# interpreter.
+
+[buildout]
+develop = .
+parts = test py docs
+versions = versions
+
+[versions]
+zope.testing = 3.8.3
+
+[py]
+recipe = zc.recipe.egg
+eggs = execute
+interpreter = py
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = execute [test]
+
+[docs]
+recipe = zc.recipe.egg
+eggs =  
+  execute
+  sphinx
+  sphinx-pypi-upload
+  zc.rst2
+  pkginfo
+interpreter = docpy

tags/1.2/docs/Makefile

+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = ../bin/sphinx-build
+PAPER         =
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html      to make standalone HTML files"
+	@echo "  dirhtml   to make HTML files named index.html in directories"
+	@echo "  pickle    to make pickle files"
+	@echo "  json      to make JSON files"
+	@echo "  htmlhelp  to make HTML files and a HTML help project"
+	@echo "  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  changes   to make an overview of all changed/added/deprecated items"
+	@echo "  linkcheck to check all external links for integrity"
+	@echo "  doctest   to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	-rm -rf _build/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html
+	@echo
+	@echo "Build finished. The HTML pages are in _build/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) _build/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in _build/dirhtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) _build/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in _build/htmlhelp."
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in _build/latex."
+	@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
+	      "run these through (pdf)latex."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) _build/changes
+	@echo
+	@echo "The overview file is in _build/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) _build/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in _build/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) _build/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in _build/doctest/output.txt."

tags/1.2/docs/api.txt

+API Reference
+=============
+
+.. automodule:: execute
+   :members:
+   :undoc-members:
+   :inherited-members:
+   :show-inheritance:

tags/1.2/docs/changes.txt

+Changes
+=======
+
+1.2 (02 Aug 2010)
+-----------------
+
+- Add :func:`~execute.both` function.
+ 
+1.1 (07 Jul 2010)
+-----------------
+
+- Add :func:`~execute.returncode` function.
+ 
+1.0 (06 Jul 2010)
+-----------------
+
+- Initial Release

tags/1.2/docs/conf.py

+# -*- coding: utf-8 -*-
+import sys, os, pkginfo, datetime
+
+pkg_info = pkginfo.Develop(os.path.join(os.path.dirname(__file__),'..'))
+
+extensions = [
+    'sphinx.ext.autodoc',
+    'sphinx.ext.intersphinx'
+    ]
+
+intersphinx_mapping = {'http://docs.python.org/dev': None}
+
+# General
+source_suffix = '.txt'
+master_doc = 'index'
+project = pkg_info.name
+copyright = '%s Simplistix Ltd' % datetime.datetime.now().year
+version = release = pkg_info.version
+exclude_trees = ['_build']
+unused_docs = ['description']
+pygments_style = 'sphinx'
+
+# Options for HTML output
+html_theme = 'default'
+htmlhelp_basename = project+'doc'
+
+# Options for LaTeX output
+latex_documents = [
+  ('index',project+'.tex', project+u' Documentation',
+   'Simplistix Ltd', 'manual'),
+]
+

tags/1.2/docs/description.txt

+=======
+Execute
+=======
+
+This is a collection of common patterns (and initially only one pattern!)
+for running executables in a sub-process using the ``subprocess``
+module.
+
+For documentation, see `http://packages.python.org/execute`__
+
+__ http://packages.python.org/execute

tags/1.2/docs/development.txt

+Development
+===========
+
+.. highlight:: bash
+
+Once you've obtained a source checkout, you can follow these
+instructions to perform various development tasks:
+
+Setting up the buildout
+-----------------------
+
+All development requires that you run the buildout::
+
+  $ python bootstrap.py
+  $ bin/buildout
+
+Running the tests
+-----------------
+
+Once you have a buildout, the tests can be run as follows::
+
+  $ bin/test
+
+Building the documentation
+--------------------------
+
+The Sphinx documentation is built by doing the following from the
+directory containg setup.py::
+
+  $ cd docs
+  $ make html
+
+Making a release
+----------------
+
+The first thing to do when making a release is to check that the ReST
+to be uploaded to PyPI is valid::
+
+  $ bin/docpy setup.py --long-description | bin/rst2 html \
+    --link-stylesheet \
+    --stylesheet=http://www.python.org/styles/styles.css > dist/desc.html
+
+Once you're certain everything is as it should be, the following will
+build the distribution, upload it to PyPI, register the metadata with
+PyPI and upload the Sphinx documentation to PyPI::
+
+  $ bin/buildout -o
+  $ bin/docpy setup.py sdist upload register upload_sphinx --upload-dir=docs/_build/html
+
+The ``bin/buildout`` will make sure the correct package information is
+used.
+
+This should all be done on a unix box so that a `.tgz` source
+distribution is produced.

tags/1.2/docs/index.txt

+Execute documentation
+=====================
+
+.. toctree::
+   :maxdepth: 2
+
+   installation.txt
+   use.txt
+   api.txt
+   development.txt
+   changes.txt
+   license.txt
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+

tags/1.2/docs/installation.txt

+Installation Instructions
+=========================
+
+The easyiest way to install Execute is::
+
+  easy_install execute
+
+Or, if you're using `zc.buildout`, just specify ``execute`` as a
+required egg. 

tags/1.2/docs/license.txt

+=======
+License
+=======
+
+Copyright (c) 2010 Simplistix Ltd
+
+Permission is hereby granted, free of charge, to any person 
+obtaining a copy of this software and associated documentation 
+files (the "Software"), to deal in the Software without restriction, 
+including without limitation the rights to use, copy, modify, merge, 
+publish, distribute, sublicense, and/or sell copies of the Software, 
+and to permit persons to whom the Software is furnished to do so, 
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be 
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 
+BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
+SOFTWARE.

tags/1.2/docs/make.bat

+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+set SPHINXBUILD=..\bin\sphinx-build
+set ALLSPHINXOPTS=-d _build/doctrees %SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+	set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+	:help
+	echo.Please use `make ^<target^>` where ^<target^> is one of
+	echo.  html      to make standalone HTML files
+	echo.  dirhtml   to make HTML files named index.html in directories
+	echo.  pickle    to make pickle files
+	echo.  json      to make JSON files
+	echo.  htmlhelp  to make HTML files and a HTML help project
+	echo.  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+	echo.  changes   to make an overview over all changed/added/deprecated items
+	echo.  linkcheck to check all external links for integrity
+	echo.  doctest   to run all doctests embedded in the documentation if enabled
+	goto end
+)
+
+if "%1" == "clean" (
+	for /d %%i in (_build\*) do rmdir /q /s %%i
+	del /q /s _build\*
+	goto end
+)
+
+if "%1" == "html" (
+	%SPHINXBUILD% -b html %ALLSPHINXOPTS% _build/html
+	echo.
+	echo.Build finished. The HTML pages are in _build/html.
+	goto end
+)
+
+if "%1" == "dirhtml" (
+	%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% _build/dirhtml
+	echo.
+	echo.Build finished. The HTML pages are in _build/dirhtml.
+	goto end
+)
+
+if "%1" == "pickle" (
+	%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% _build/pickle
+	echo.
+	echo.Build finished; now you can process the pickle files.
+	goto end
+)
+
+if "%1" == "json" (
+	%SPHINXBUILD% -b json %ALLSPHINXOPTS% _build/json
+	echo.
+	echo.Build finished; now you can process the JSON files.
+	goto end
+)
+
+if "%1" == "htmlhelp" (
+	%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% _build/htmlhelp
+	echo.
+	echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in _build/htmlhelp.
+	goto end
+)
+
+if "%1" == "latex" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% _build/latex
+	echo.
+	echo.Build finished; the LaTeX files are in _build/latex.
+	goto end
+)
+
+if "%1" == "changes" (
+	%SPHINXBUILD% -b changes %ALLSPHINXOPTS% _build/changes
+	echo.
+	echo.The overview file is in _build/changes.
+	goto end
+)
+
+if "%1" == "linkcheck" (
+	%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% _build/linkcheck
+	echo.
+	echo.Link check complete; look for any errors in the above output ^
+or in _build/linkcheck/output.txt.
+	goto end
+)
+
+if "%1" == "doctest" (
+	%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% _build/doctest
+	echo.
+	echo.Testing of doctests in the sources finished, look at the ^
+results in _build/doctest/output.txt.
+	goto end
+)
+
+:end

tags/1.2/docs/use.txt

+Using Execute
+=============
+
+Execute provides handy functions for several patterns of sub-process
+execution. Each of these patterns is described below.
+
+Simple
+------
+
+The :func:`~execute.simple` function provides a simple way to run an
+executable in a sub-process that requires no input and where you'd
+like the output of both the standard and error output streams combined
+and returned in one string.
+
+For example, suppose you needed to execute the following python script
+in a sub-process::
+
+  import sys
+  print sys.argv[1:]
+  sys.stdout.flush()
+  sys.stderr.write('An error occurred!\n')
+
+.. -> source
+
+.. invisible-code-block: python
+
+   path = temp_dir.write('test.py',source,path=True)
+
+As an aside, it's unlikely you'd want to do this. It's much more
+likely that you'd want to use :func:`~execute.simple` to run something
+that wasn't written in python.
+
+However, if ``python`` contained the path to the python executable
+you'd want to use to run the above script, and ``path`` contained the
+path to the script on disk, you could use :func:`~execute.simple` to
+run it and capture the output as follows: 
+
+>>> from execute import simple
+>>> output = simple(' '.join((python,path,'x=1 --y=2 a b')))
+
+You now have the output in a string and you can do whatever you like
+with it:
+
+>>> print output
+['x=1', '--y=2', 'a', 'b']
+An error occurred!
+<BLANKLINE>
+
+Return Code
+-----------
+
+The :func:`~execute.returncode` function provides a simple way to get 
+the return code set by the command executed. 
+The command is run in a sub-process and must require no input.
+
+For example, suppose you needed to get the return code set by the 
+following python script::
+
+  import sys
+  sys.exit(4)
+
+.. -> source
+
+.. invisible-code-block: python
+
+   path = temp_dir.write('test.py',source,path=True)
+
+If ``python`` contained the path to the python executable
+you'd want to use to run the above script, and ``path`` contained the
+path to the script on disk, you could use :func:`~execute.returncode` 
+to obtain the return code as follows:
+
+>>> from execute import returncode
+>>> code = returncode(python+' '+path)
+
+You now have the return code and can do whatever you like
+with it:
+
+>>> print code
+4
+
+Both
+----
+
+The :func:`~execute.both` function provides a simple way to get the
+output and return code of the command executed.
+The command is run in a sub-process and must require no input.
+The output of both the standard and error output streams will be combined
+and returned in one string.
+
+For example, suppose you needed to execute the following python script
+in a sub-process, want its output and want to know if it succeeded by
+way of its return code::
+
+  import sys
+  print sys.argv[1:]
+  sys.stdout.flush()
+  sys.stderr.write('An error occurred!\n')
+  sys.exit(13)
+
+.. -> source
+
+.. invisible-code-block: python
+
+   path = temp_dir.write('test.py',source,path=True)
+
+If ``python`` contained the path to the python executable
+you'd want to use to run the above script, and ``path`` contained the
+path to the script on disk, you could use :func:`~execute.both` to
+run it, capturing the output and the return code as follows: 
+
+>>> from execute import both
+>>> output, returncode = both(' '.join((python,path,'x=1 --y=2 a b')))
+
+You can now do whatever you like with either the output or the return code:
+
+>>> print output
+['x=1', '--y=2', 'a', 'b']
+An error occurred!
+<BLANKLINE>
+>>> print returncode
+13

tags/1.2/execute/__init__.py

+# Copyright (c) 2010 Simplistix Ltd
+#
+# See license.txt for more details.
+
+from subprocess import Popen,PIPE,STDOUT
+
+def _popen(command,cwd):
+    return Popen(
+        command,
+        stderr=STDOUT,
+        stdout=PIPE,
+        universal_newlines=True,
+        cwd=cwd,
+        shell=True,
+        )
+
+def simple(command,cwd=None):
+    """Execute the command specified in a sub-process.
+
+    This command must take no input. Any output to either
+    the standard or error streams will be collected and
+    returned as a string.
+
+    :param command:
+      A string containing the command to be executed.
+
+    :param cwd:
+      An optional current working directory in which to
+      run the command. If not specified, the current working
+      directory will be left as-is.
+     
+    :returns:
+      A string containing anything written to the standard
+      or error streams by the command as it runs.
+    
+    """
+    return _popen(command,cwd).communicate()[0]
+
+def returncode(command,cwd=None):
+    """Execute the command specified in a sub-process.
+
+    This command must take no input. The exit code set
+    by the command will be returned. Any output from the
+    command to either the standard or error streams will
+    be discarded.
+
+    :param command:
+      A string containing the command to be executed.
+
+    :param cwd:
+      An optional current working directory in which to
+      run the command. If not specified, the current working
+      directory will be left as-is.
+     
+    :returns:
+      The exit code set by the command that was run.
+    
+    """
+    p = _popen(command,cwd)
+    p.communicate()
+    return p.returncode
+
+def both(command,cwd=None):
+    """Execute the command specified in a sub-process.
+
+    This command must take no input.
+    A 2-tuple will be returned. Any output to either
+    the standard or error streams will be collected and
+    returned as the first element of the tuple.The exit code set
+    by the command will be returned as the second element of the
+    tuple.
+
+    :param command:
+      A string containing the command to be executed.
+
+    :param cwd:
+      An optional current working directory in which to
+      run the command. If not specified, the current working
+      directory will be left as-is.
+     
+    :returns:
+      The output and exit code of the command that was run.
+    
+    """
+    p = _popen(command,cwd)
+    output = p.communicate()[0]
+    return output,p.returncode

tags/1.2/execute/tests/__init__.py

Empty file added.

tags/1.2/execute/tests/test_both.py

+# Copyright (c) 2010 Simplistix Ltd
+#
+# See license.txt for more details.
+from __future__ import with_statement
+
+import os,sys
+
+from execute import both
+from mock import Mock
+from subprocess import PIPE,STDOUT
+from testfixtures import tempdir,compare,Replacer
+from unittest import TestSuite,TestCase,makeSuite
+
+class TestBoth(TestCase):
+
+    @tempdir()
+    def test_out_and_err(self,d):
+        # without the flushes, the order comes out wrong
+        path = d.write('test.py','\n'.join((
+                "import sys",
+                "sys.stdout.write('stdout\\n')",
+                "sys.stdout.flush()",
+                "sys.stderr.write('stderr\\n')",
+                "sys.stderr.flush()",
+                "sys.stdout.write('stdout2\\n')",
+                "sys.stdout.flush()",
+                )),path=True)
+        compare(('stdout\nstderr\nstdout2\n',0),
+                both(sys.executable+' '+path))
+    
+    @tempdir()
+    def test_args(self,d):
+        path = d.write('test.py','\n'.join((
+                "import sys",
+                "print sys.argv",
+                )),path=True)
+        compare(("[%r, 'x=1', '--y=2', 'a', 'b']\n" % path,0),
+                both(sys.executable+' '+path+' x=1 --y=2 a b'))
+    
+    @tempdir()
+    def test_working_directory(self,d):
+        dir = d.makedir('a_dir',path=True)
+        path = d.write('test.py','\n'.join((
+                "import os",
+                "print os.getcwd()",
+                )),path=True)
+
+        # tempdirs on Mac OS X give a different path
+        # after you've os.chdir's into them!
+        cur = os.getcwd()
+        try:
+            os.chdir(dir)
+            expected = os.getcwd()+'\n',0
+        finally:
+            os.chdir(cur)
+            
+        compare(expected,
+                both(sys.executable+' '+path,cwd=dir))
+
+    def test_popen_params(self):
+        m = Mock()
+        m.Popen.return_value = m.Popeni
+        m.Popeni.communicate.return_value=('','')
+        with Replacer() as r:
+            r.replace('execute.Popen',m.Popen)
+            both('something')
+        compare(m.method_calls,[
+                ('Popen',
+                 ('something',),
+                 {'cwd': None,
+                  'shell': True,
+                  'stderr': STDOUT,
+                  'stdout': PIPE,
+                  'universal_newlines': True}),
+                ('Popeni.communicate', (), {})
+                ])
+    
+def test_suite():
+    return TestSuite((
+        makeSuite(TestBoth),
+        ))

tags/1.2/execute/tests/test_docs.py

+# Copyright (c) 2010 Simplistix Ltd
+#
+# See license.txt for more details.
+
+import sys
+
+from doctest import REPORT_NDIFF,ELLIPSIS
+from glob import glob
+from manuel import doctest,codeblock,capture
+from manuel.testing import TestSuite
+from os.path import dirname,join,pardir
+from testfixtures import TempDirectory
+
+def setUp(test):
+    test.globs['temp_dir']=TempDirectory()
+    test.globs['python']=sys.executable
+
+def tearDown(test):
+    TempDirectory.cleanup_all()
+    
+def test_suite():
+    m =  doctest.Manuel(optionflags=REPORT_NDIFF|ELLIPSIS)
+    m += codeblock.Manuel()
+    m += capture.Manuel()
+
+    return TestSuite(
+        m,
+        setUp=setUp,
+        tearDown=tearDown,
+        *glob(join(dirname(__file__),pardir,pardir,'docs','*.txt'))
+        )

tags/1.2/execute/tests/test_returncode.py

+# Copyright (c) 2010 Simplistix Ltd
+#
+# See license.txt for more details.
+from __future__ import with_statement
+
+import os,sys
+
+from execute import returncode
+from testfixtures import tempdir,compare
+from unittest import TestSuite,TestCase,makeSuite
+
+class TestReturnCode(TestCase):
+
+    @tempdir()
+    def test_okay(self,d):
+        path = d.write('test.py','\n'.join((
+                "import sys",
+                "sys.stdout.write('stdout\\n')",
+                "sys.stderr.write('stderr\\n')",
+                "sys.exit(0)",
+                )),path=True)
+        compare(0,returncode(sys.executable+' '+path))
+    
+    @tempdir()
+    def test_error(self,d):
+        path = d.write('test.py','\n'.join((
+                "import sys",
+                "sys.stdout.write('stdout\\n')",
+                "sys.stderr.write('stderr\\n')",
+                "sys.exit(1)",
+                )),path=True)
+        compare(1,returncode(sys.executable+' '+path))
+        
+    @tempdir()
+    def test_working_directory(self,d):
+        dir = d.makedir('a_dir',path=True)
+        
+        # tempdirs on Mac OS X give a different path
+        # after you've os.chdir's into them!
+        cur = os.getcwd()
+        try:
+            os.chdir(dir)
+            expected = os.getcwd()
+        finally:
+            os.chdir(cur)
+            
+        path = d.write('test.py','\n'.join((
+                "import os,sys",
+                "dir = os.getcwd()",
+                "if dir==%r:"% expected,
+                "  sys.exit(3)",
+                "else:",
+                "  sys.exit(2)",
+                )),path=True)
+
+        compare(3,returncode(sys.executable+' '+path,cwd=dir))
+    
+    
+def test_suite():
+    return TestSuite((
+        makeSuite(TestReturnCode),
+        ))

tags/1.2/execute/tests/test_simple.py

+# Copyright (c) 2010 Simplistix Ltd
+#
+# See license.txt for more details.
+from __future__ import with_statement
+
+import os,sys
+
+from execute import simple
+from mock import Mock
+from subprocess import PIPE,STDOUT
+from testfixtures import tempdir,compare,Replacer
+from unittest import TestSuite,TestCase,makeSuite
+
+class TestSimple(TestCase):
+
+    @tempdir()
+    def test_out_and_err(self,d):
+        # without the flushes, the order comes out wrong
+        path = d.write('test.py','\n'.join((
+                "import sys",
+                "sys.stdout.write('stdout\\n')",
+                "sys.stdout.flush()",
+                "sys.stderr.write('stderr\\n')",
+                "sys.stderr.flush()",
+                "sys.stdout.write('stdout2\\n')",
+                "sys.stdout.flush()",
+                )),path=True)
+        compare('stdout\nstderr\nstdout2\n',
+                simple(sys.executable+' '+path))
+    
+    @tempdir()
+    def test_args(self,d):
+        path = d.write('test.py','\n'.join((
+                "import sys",
+                "print sys.argv",
+                )),path=True)
+        compare("[%r, 'x=1', '--y=2', 'a', 'b']\n" % path,
+                simple(sys.executable+' '+path+' x=1 --y=2 a b'))
+    
+    @tempdir()
+    def test_working_directory(self,d):
+        dir = d.makedir('a_dir',path=True)
+        path = d.write('test.py','\n'.join((
+                "import os",
+                "print os.getcwd()",
+                )),path=True)
+
+        # tempdirs on Mac OS X give a different path
+        # after you've os.chdir's into them!
+        cur = os.getcwd()
+        try:
+            os.chdir(dir)
+            expected = os.getcwd()+'\n'
+        finally:
+            os.chdir(cur)
+            
+        compare(expected,
+                simple(sys.executable+' '+path,cwd=dir))
+
+    def test_popen_params(self):
+        m = Mock()
+        m.Popen.return_value = m.Popeni
+        m.Popeni.communicate.return_value=('','')
+        with Replacer() as r:
+            r.replace('execute.Popen',m.Popen)
+            simple('something')
+        compare(m.method_calls,[
+                ('Popen',
+                 ('something',),
+                 {'cwd': None,
+                  'shell': True,
+                  'stderr': STDOUT,
+                  'stdout': PIPE,
+                  'universal_newlines': True}),
+                ('Popeni.communicate', (), {})
+                ])
+    
+def test_suite():
+    return TestSuite((
+        makeSuite(TestSimple),
+        ))
+# Copyright (c) 2010 Simplistix Ltd
+# See license.txt for license details.
+
+import os
+from setuptools import setup, find_packages
+
+package_name = 'execute'
+version = '1.2'
+base_dir = os.path.dirname(__file__)
+
+setup(
+    name=package_name,
+    version=version,
+    author='Chris Withers',
+    author_email='chris@simplistix.co.uk',
+    license='MIT',
+    description="Common patterns for executing commands as sub processes",
+    long_description=open(os.path.join(base_dir,'docs','description.txt')).read(),
+    url='http://packages.python.org/execute',
+    classifiers=[
+    'Development Status :: 5 - Production/Stable',
+    'Intended Audience :: Developers',
+    'License :: OSI Approved :: MIT License',
+    ],    
+    packages=find_packages(),
+    zip_safe=False,
+    extras_require=dict(
+        test=[
+            'manuel',
+            'mock',
+            'testfixtures',
+            ],
+        )
+    )
+=======
+Checker
+=======
+
+For full documentation please see:
+http://www.simplistix.co.uk/software/python/checker
+
+If working offline, please consult the documentation source in the
+`docs` directory.
+
+Licensing
+=========
+
+Copyright (c) 2009 Simplistix Ltd
+See docs/license.txt for details.
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id: bootstrap.py 85041 2008-03-31 15:57:30Z andreasjung $
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+try:
+    import pkg_resources
+except ImportError:
+    ez = {}
+    exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+                         ).read() in ez
+    ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+    import pkg_resources
+
+if sys.platform == 'win32':
+    def quote(c):
+        if ' ' in c:
+            return '"%s"' % c # work around spawn lamosity on windows
+        else:
+            return c
+else:
+    def quote (c):
+        return c
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+ws  = pkg_resources.working_set
+assert os.spawnle(
+    os.P_WAIT, sys.executable, quote (sys.executable),
+    '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout',
+    dict(os.environ,
+         PYTHONPATH=
+         ws.find(pkg_resources.Requirement.parse('setuptools')).location
+         ),
+    ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)
+# This buildout is used for development of checker.
+# It gets the necessary eggs and creates a test runner and a python
+# interpreter.
+
+[buildout]
+develop = .
+parts = test py docs
+versions = versions
+
+[versions]
+zope.testing = 3.8.3
+
+[py]
+recipe = zc.recipe.egg
+eggs = execute
+interpreter = py
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = execute [test]
+
+[docs]
+recipe = zc.recipe.egg
+eggs =  
+  execute
+  sphinx
+  sphinx-pypi-upload
+  zc.rst2
+  pkginfo
+interpreter = docpy
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = ../bin/sphinx-build
+PAPER         =
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html      to make standalone HTML files"
+	@echo "  dirhtml   to make HTML files named index.html in directories"
+	@echo "  pickle    to make pickle files"
+	@echo "  json      to make JSON files"
+	@echo "  htmlhelp  to make HTML files and a HTML help project"
+	@echo "  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  changes   to make an overview of all changed/added/deprecated items"
+	@echo "  linkcheck to check all external links for integrity"
+	@echo "  doctest   to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	-rm -rf _build/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html
+	@echo
+	@echo "Build finished. The HTML pages are in _build/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) _build/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in _build/dirhtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) _build/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in _build/htmlhelp."
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in _build/latex."
+	@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
+	      "run these through (pdf)latex."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) _build/changes
+	@echo
+	@echo "The overview file is in _build/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) _build/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in _build/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) _build/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in _build/doctest/output.txt."
+API Reference
+=============
+
+.. automodule:: execute
+   :members:
+   :undoc-members:
+   :inherited-members:
+   :show-inheritance:

trunk/docs/changes.txt

+Changes
+=======
+
+1.2 (02 Aug 2010)
+-----------------
+
+- Add :func:`~execute.both` function.
+ 
+1.1 (07 Jul 2010)
+-----------------
+
+- Add :func:`~execute.returncode` function.
+ 
+1.0 (06 Jul 2010)
+-----------------
+
+- Initial Release
+# -*- coding: utf-8 -*-
+import sys, os, pkginfo, datetime
+
+pkg_info = pkginfo.Develop(os.path.join(os.path.dirname(__file__),'..'))
+
+extensions = [
+    'sphinx.ext.autodoc',
+    'sphinx.ext.intersphinx'
+    ]
+
+intersphinx_mapping = {'http://docs.python.org/dev': None}
+
+# General
+source_suffix = '.txt'
+master_doc = 'index'
+project = pkg_info.name
+copyright = '%s Simplistix Ltd' % datetime.datetime.now().year
+version = release = pkg_info.version
+exclude_trees = ['_build']
+unused_docs = ['description']
+pygments_style = 'sphinx'
+
+# Options for HTML output
+html_theme = 'default'
+htmlhelp_basename = project+'doc'
+
+# Options for LaTeX output
+latex_documents = [
+  ('index',project+'.tex', project+u' Documentation',
+   'Simplistix Ltd', 'manual'),
+]
+

trunk/docs/description.txt

+=======
+Execute
+=======