diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..12002af --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.tox/ +*.egg-info/ +AUTHORS +ChangeLog +*.csv diff --git a/LICENSE b/LICENSE index ad410e1..67db858 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,5 @@ -Apache License + + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -172,30 +173,3 @@ Apache License defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/README.md b/README.md index be7c44b..21240d0 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,41 @@ giftwrap ======== + +Usage +===== + + $ pip install giftwrap + $ giftwrap -h + +Dependencies +============ + +* `fpm` + +Testing +======= + + $ sudo pip install tox + $ tox + +License +======= +| | | +|:---------------------|:---------------------------------------------------| +| **Authors** | John Dewey () | +| | Craig Tracey () | +| | | +| **Copyright** | Copyright (c) 2014, John Dewey | +| | Copyright (c) 2014, Craig Tracey | + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/giftwrap/__init__.py b/giftwrap/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/giftwrap/tests/__init__.py b/giftwrap/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/giftwrap/tests/test_util.py b/giftwrap/tests/test_util.py new file mode 100644 index 0000000..1790fbf --- /dev/null +++ b/giftwrap/tests/test_util.py @@ -0,0 +1,40 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2014, John Dewey +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import unittest2 as unittest + +from giftwrap import util + + +class TestUtil(unittest.TestCase): + def test_execute_returns_exitcode_tuple(self): + cmd = '/bin/test true' + result, _, _ = util.execute(cmd) + + self.assertEquals(0, result) + + def test_execute_returns_stdout_tuple(self): + cmd = 'echo stdout' + _, out, _ = util.execute(cmd) + + self.assertEquals('stdout\n', out) + + def test_execute_returns_stderr_tuple(self): + cmd = 'echo stderr >&2' + _, _, err = util.execute(cmd) + + self.assertEquals('stderr\n', err) diff --git a/giftwrap/util.py b/giftwrap/util.py new file mode 100644 index 0000000..68c6556 --- /dev/null +++ b/giftwrap/util.py @@ -0,0 +1,38 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2014, John Dewey +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os +import subprocess + + +def execute(command): + """ + Executes a command in a subprocess. Returns a tuple of + (exitcode, out, err). + + :param command: Command string to execute. + """ + process = subprocess.Popen(command, + cwd=os.getcwd(), + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + shell=True) + (out, err) = process.communicate() + exitcode = process.wait() + + return exitcode, out, err diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1d45dc6 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pbr diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..8057092 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,32 @@ +[metadata] +name = giftwrap +version = 0.1.0 +summary = giftwrap - A tool to build full-stack native system packages. +description-file = + README.md +author = John Dewey +author-email = jodewey@cisco.com +home-page = https://github.com/cloudcadre/giftwrap +classifier = + Intended Audience :: Information Technology + Intended Audience :: Developers + License :: OSI Approved :: Apache Software License + Operating System :: POSIX :: Linux + Programming Language :: Python + +[global] +setup-hooks = + pbr.hooks.setup_hook + +# [entry_points] +# console_scripts = +# giftwrap = giftwrap.shell:main + +[files] +packages = + giftwrap + +[build_sphinx] +all_files = 1 +build-dir = doc/build +source-dir = doc/source diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..60c45c4 --- /dev/null +++ b/setup.py @@ -0,0 +1,21 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2014, John Dewey +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations + +import setuptools + +setuptools.setup( + setup_requires=['pbr'], + pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..4fd7287 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,5 @@ +nose +mock +unittest2 +flake8 +pep8 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..26fb756 --- /dev/null +++ b/tox.ini @@ -0,0 +1,33 @@ +# Tox (http://tox.testrun.org/) is a tool for running tests +# in multiple virtualenvs. This configuration file will run the +# test suite on all supported python versions. To use it, "pip install tox" +# and then run "tox" from this directory. + +[tox] +envlist = py27,pep8 + +[testenv] +usedevelop = True +setenv = VIRTUAL_ENV={envdir} +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +commands = nosetests +sitepackages = False +downloadcache = {toxworkdir}/_download + +[testenv:pep8] +commands = + flake8 {posargs} + +[testenv:venv] +commands = {posargs} + +[testenv:pyflakes] +deps = flake8 +commands = flake8 + +[flake8] +ignore = H301,H306 +builtins = _ +exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg +show-source = True