diff --git a/.coveragerc b/.coveragerc index 501f84f..9562565 100644 --- a/.coveragerc +++ b/.coveragerc @@ -19,7 +19,7 @@ exclude_lines = except OSError # Don't complain if non-runnable code isn't run: - if __name__ in u'__main__': + if __name__ in '__main__': ignore_errors = True diff --git a/.travis.yml b/.travis.yml index 34694b5..b17497d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,9 @@ matrix: python: "2.7" env: TRAVIS_PYTHON_VERSION="2.7" dist: trusty + - os: linux + python: "3.2" + env: TRAVIS_PYTHON_VERSION="3.2" - os: linux python: "3.3" env: TRAVIS_PYTHON_VERSION="3.3" @@ -44,11 +47,11 @@ matrix: python: "3.8-dev" env: TRAVIS_PYTHON_VERSION="3.8" - os: linux - python: "pypy" # PyPy2 2.5.0 + python: "pypy2.7-5.8.0" - os: linux - python: "pypy3" + python: "pypy3.5-5.8.0" - os: linux - python: "pypy-5.3.1" + python: "pypy3.5-6.0" - os: linux python: "nightly" # currently points to 3.7-dev env: TRAVIS_PYTHON_VERSION="3.7-dev" @@ -67,6 +70,12 @@ matrix: - os: osx osx_image: xcode9 language: generic + - os: osx + osx_image: xcode9.2 + language: generic + - os: osx + osx_image: xcode9.3 + language: generic allow_failures: - os: linux python: "nightly" # currently points to 3.7-dev @@ -94,7 +103,11 @@ matrix: - os: linux python: "pypy3" - os: linux - python: "pypy-5.3.1" + python: "pypy3.5-5.8.0" + - os: linux + python: "pypy2.7-5.8.0" + - os: linux + python: "pypy3.5-6.0" - os: linux python: "nightly" # currently points to 3.7-dev env: TRAVIS_PYTHON_VERSION="3.7-dev" @@ -153,27 +166,28 @@ before_script: script: - make clean ; - if [ $TRAVIS_OS_NAME == osx ] ; then echo "SKIP make test" ; else make test || exit $? ; fi ; - - if [ $TRAVIS_OS_NAME == osx ] ; then echo "SKIP codecov" ; else codecov || exit $? ; fi ; + - if [ $TRAVIS_OS_NAME == osx ] || [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP codecov" ; else codecov || exit $? ; fi ; - cp -vf .coverage ".coverall.Lasting.45678.12345" 2>/dev/null || true - make clean || exit $? ; - - make test-tox || exit $? ; + - if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP make test-tox" ; else make test-tox || exit $? ; fi ; - make clean ; - mv -vf ".coverall.Lasting.45678.12345" .coverage 2>/dev/null || true after_failure: - - coverage combine 2>/dev/null || true - - coverage xml 2>/dev/null || true - - if [ $TRAVIS_OS_NAME == osx ] ; then echo "SKIP code climate" ; else ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT || true ; fi ; - - codecov 2>/dev/null || true + - if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP coverage" ; else coverage combine 2>/dev/null || true ; fi ; + - if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP coverage xml" ; else coverage xml 2>/dev/null || true ; fi ; + - if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP codecov" ; else codecov 2>/dev/null || true ; fi ; + - if [ $TRAVIS_OS_NAME == osx ] || [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP code climate" ; else ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT || true ; fi ; + - if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP codecov" ; else codecov 2>/dev/null || true ; fi ; - make clean 2>/dev/nul || true after_success: - - coverage combine || true - - coverage xml || true - - if [ $TRAVIS_OS_NAME == osx ] ; then echo "SKIP code climate" ; else ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT || true ; fi ; - - codecov || true + - if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP coverage" ; else coverage combine 2>/dev/null || true ; fi ; + - if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP coverage xml" ; else coverage xml 2>/dev/null || true ; fi ; + - if [ $TRAVIS_OS_NAME == osx ] || [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP code climate" ; else ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT || true ; fi ; + - if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP codecov" ; else codecov || true ; fi ; - travis_retry python3 -m pip install python-coveralls || python3 -m pip install python-coveralls || true ; - - coveralls 2>/dev/null || true + - if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP codecov" ; else coveralls 2>/dev/null || true ; fi ; - travis_wait 35 curl --url "https://scan.coverity.com/download/linux64?token=${COVERTY_TOKEN}&project=reactive-firewall%2Fpython-repo" -o coverity_tool.tgz || true - travis_wait tar xzf coverity_tool.tgz || true - rm -fr cov-int || true diff --git a/README.md b/README.md index 1f8ffe7..b274868 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,7 @@ By default this template will assume that the Travis CI Service and Circle-CI Se [![Appveyor](https://ci.appveyor.com/api/projects/status/6gggp1wpbnnjokm4/branch/master?svg=true)](https://ci.appveyor.com/project/reactive-firewall/python-repo/branch/master) [![Python 3](https://pyup.io/repos/github/reactive-firewall/python-repo/python-3-shield.svg)](https://pyup.io/repos/github/reactive-firewall/PiAP-python-tools/) [![Updates](https://pyup.io/repos/github/reactive-firewall/python-repo/shield.svg)](https://pyup.io/repos/github/reactive-firewall/python-repo/) -[![Dependency Status](https://gemnasium.com/badges/github.com/reactive-firewall/python-repo.svg)](https://gemnasium.com/github.com/reactive-firewall/python-repo) -[![Dependency Status](https://www.versioneye.com/user/projects/59cc1dc1368b0831e6126dc6/badge.svg?style=flat-round)](https://www.versioneye.com/user/projects/59cc1dc1368b0831e6126dc6) +![Size](https://img.shields.io/github/languages/code-size/reactive-firewall/python-repo.svg) [![Test Coverage](https://api.codeclimate.com/v1/badges/f76f4e7e2eae6bff9b6a/test_coverage)](https://codeclimate.com/github/reactive-firewall/python-repo/test_coverage) [![code coverage](https://codecov.io/gh/reactive-firewall/python-repo/branch/master/graph/badge.svg)](https://codecov.io/gh/reactive-firewall/python-repo/branch/master/) [![Coverage Status](https://coveralls.io/repos/github/reactive-firewall/python-repo/badge.svg?branch=master)](https://coveralls.io/github/reactive-firewall/python-repo?branch=master) @@ -25,10 +24,10 @@ By default this template will assume that the Travis CI Service and Circle-CI Se ### Stable: [![status](https://travis-ci.org/reactive-firewall/python-repo.svg?branch=stable)](https://travis-ci.org/reactive-firewall/python-repo) [![CircleCI](https://circleci.com/gh/reactive-firewall/python-repo/tree/stable.svg?style=svg)](https://circleci.com/gh/reactive-firewall/python-repo/tree/stable) +[![Appveyor](https://ci.appveyor.com/api/projects/status/6gggp1wpbnnjokm4/branch/stable?svg=true)](https://ci.appveyor.com/project/reactive-firewall/python-repo/branch/stable) [![code coverage](https://codecov.io/gh/reactive-firewall/python-repo/branch/stable/graph/badge.svg)](https://codecov.io/gh/reactive-firewall/python-repo/branch/stable/) [![code coverage](https://codecov.io/gh/reactive-firewall/python-repo/branch/stable/graph/badge.svg)](https://codecov.io/gh/reactive-firewall/python-repo/branch/stable/) [![Coverage Status](https://coveralls.io/repos/github/reactive-firewall/python-repo/badge.svg?branch=stable)](https://coveralls.io/github/reactive-firewall/python-repo?branch=stable) -[![Dependency Status](https://www.versioneye.com/user/projects/59cc1dce368b083214208a72/badge.svg?style=flat-round)](https://www.versioneye.com/user/projects/59cc1dce368b083214208a72) # How do I use this to create a new project repo? diff --git a/pythonrepo/__init__.py b/pythonrepo/__init__.py index 26f9d1c..3608f2f 100644 --- a/pythonrepo/__init__.py +++ b/pythonrepo/__init__.py @@ -2,7 +2,7 @@ # Python Repo Template # .................................. -# Copyright (c) 2017, Kendrick Walls +# Copyright (c) 2017-2018, Kendrick Walls # .................................. # Licensed under MIT (the "License"); # you may not use this file except in compliance with the License. @@ -17,8 +17,8 @@ # limitations under the License. -__version__ = """1.0.1""" -"""This is version 1.0.1 of pythonrepo Template""" +__version__ = """1.1.0""" +"""This is version 1.1.0 of pythonrepo Template""" try: import sys @@ -38,10 +38,10 @@ from . import pythonrepo as pythonrepo except Exception as importErr: del importErr - import pythonrepo as pythonrepo + import pythonrepo.pythonrepo as pythonrepo -if __name__ in u'__main__': +if __name__ in '__main__': if pythonrepo.__name__ is None: raise ImportError(str("Failed to open pythonrepo")) pythonrepo.main(sys.argv[1:]) diff --git a/pythonrepo/pythonrepo.py b/pythonrepo/pythonrepo.py index dc44e85..37b6932 100644 --- a/pythonrepo/pythonrepo.py +++ b/pythonrepo/pythonrepo.py @@ -103,8 +103,10 @@ def parseArgs(arguments=None): return parser.parse_known_args(arguments) -def useTool(tool, arguments=[None]): +def useTool(tool, arguments=None): """Handler for launching the functions.""" + if arguments is None: + arguments = [None] if tool is None: return None if tool in TASK_OPTIONS.keys(): diff --git a/tests/profiling.py b/tests/profiling.py index 53d4368..0c55245 100644 --- a/tests/profiling.py +++ b/tests/profiling.py @@ -3,7 +3,7 @@ # Python Repo Template # .................................. -# Copyright (c) 2017, Kendrick Walls +# Copyright (c) 2017-2018, Kendrick Walls # .................................. # Licensed under MIT (the "License"); # you may not use this file except in compliance with the License. @@ -31,38 +31,18 @@ try: import os - if os.__name__ is None: - raise NotImplementedError("OMG! We could not import the os. We're like in the matrix!") -except Exception as err: - raise ImportError(err) - exit(3) - - -try: import sys - if sys.__name__ is None: - raise NotImplementedError("OMG! We could not import the sys. We're like in the matrix!") -except Exception as err: - raise ImportError(err) - exit(3) - - -try: import time - if time.__name__ is None: - raise NotImplementedError("OMG! We could not import time. We're like in the speed-force!") -except Exception as err: - raise ImportError(err) - exit(3) - - -try: import cProfile - if cProfile.__name__ is None: - raise NotImplementedError("OMG! We could not import cProfile. ABORT!") + for keyModule in [os, sys, time, cProfile]: + if keyModule.__name__ is None: + raise NotImplementedError( + str("OMG! We could not import the {}!").format( + str(keyModule) + ) + ) except Exception as err: raise ImportError(err) - exit(3) try: @@ -106,7 +86,6 @@ def __enter__(self): def __exit__(self, type, value, traceback): self.checkpoint(str("finished")) - pass def do_time_profile(func, timer_name="time_profile"): @@ -143,7 +122,10 @@ def profiled_func(*args, **kwargs): try: # noqa from line_profiler import LineProfiler - def do_profile(follow=[]): + def do_profile(follow=None): + if follow is None: + follow = [] + def inner(func): def profiled_func(*args, **kwargs): try: @@ -159,8 +141,11 @@ def profiled_func(*args, **kwargs): return inner except ImportError: - def do_profile(follow=[]): + def do_profile(follow=None): "Helpful if you accidentally leave in production!" + if follow is None: + follow = [] + def inner(func): def nothing(*args, **kwargs): return func(*args, **kwargs) @@ -173,10 +158,11 @@ def main(argv=None): raise NotImplementedError("CRITICAL - test profiling main() not implemented. yet?") -if __name__ in u'__main__': +if __name__ in '__main__': + exitcode = 3 try: - exit(main(sys.argv[1:])) - except Exception: - exit(3) + exitcode = main(sys.argv[1:]) + finally: + exit(exitcode) diff --git a/tests/test_usage.py b/tests/test_usage.py index 6390f63..e8bb980 100644 --- a/tests/test_usage.py +++ b/tests/test_usage.py @@ -21,7 +21,7 @@ import unittest import subprocess import sys -import profiling as profiling +import tests.profiling as profiling def getPythonCommand(): @@ -51,14 +51,15 @@ def getPythonCommand(): return str(thepython) -def checkPythonCommand(args=[None], stderr=None): +def checkPythonCommand(args=None, stderr=None): """Function for backend subprocess check_output command like testing with coverage support""" theOutput = None try: if args is None or args is [None]: + args = [None] theOutput = subprocess.check_output(["exit 1 ; #"]) else: - if str("coverage ") in args[0]: + if str("coverage ") in str(args[0]): if sys.__name__ is None: raise ImportError("Failed to import system. WTF?!!") if str("{} -m coverage ").format(str(sys.executable)) in str(args[0]): @@ -85,20 +86,23 @@ def checkPythonCommand(args=[None], stderr=None): @profiling.do_cprofile -def timePythonCommand(args=[None], stderr=None): +def timePythonCommand(args=None, stderr=None): """Function for backend subprocess check_output command with support for coverage and profiling.""" + if args is None: + args = [None] return checkPythonCommand(args, stderr) -def checkPythonErrors(args=[None], stderr=None): +def checkPythonErrors(args=None, stderr=None): """Function like checkPythonCommand, but with error passing.""" theOutput = None try: if args is None or args is [None]: + args = [None] theOutput = subprocess.check_output(["exit 1 ; #"]) else: - if str("coverage ") in args[0]: + if str("coverage ") in str(args[0]): import sys if sys.__name__ is None: raise ImportError("Failed to import system. WTF?!!")