diff --git a/.pyup.yml b/.pyup.yml index 6ea2065..d9be53c 100644 --- a/.pyup.yml +++ b/.pyup.yml @@ -1,4 +1,4 @@ -# autogenerated pyup.io config file +# autogenerated pyup.io config file # see https://pyup.io/docs/configuration/ for all available options schedule: every week diff --git a/.travis.yml b/.travis.yml index b17497d..deb33e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,24 @@ python: dist: +addons: + coverity_scan: + # GitHub project metadata + project: + name: reactive-firewall/python-repo + version: 1.1.0 + description: Python Repo Template + # Commands to prepare for build_command + # ** likely specific to your build ** + build_command_prepend: make clean + # The command that will be added as an argument to "cov-build" to compile your project for analysis, + # ** likely specific to your build ** + build_command: make test + # Pattern to match selecting branches that will run analysis. We recommend leaving this set to 'coverity_scan'. + # Take care in resource usage, and consider the build frequency allowances per + # https://scan.coverity.com/faq#frequency + branch_pattern: master + branches: only: - stable @@ -52,6 +70,12 @@ matrix: python: "pypy3.5-5.8.0" - os: linux python: "pypy3.5-6.0" + - os: linux + python: "pypy3.5-5.10.0" + env: TRAVIS_PYTHON_VERSION="3.5" + - os: linux + python: "pypy2.7-5.10.0" + env: TRAVIS_PYTHON_VERSION="2.7" - os: linux python: "nightly" # currently points to 3.7-dev env: TRAVIS_PYTHON_VERSION="3.7-dev" @@ -76,6 +100,12 @@ matrix: - os: osx osx_image: xcode9.3 language: generic + - os: osx + osx_image: xcode9.4 + language: generic + - os: osx + osx_image: xcode10 + language: generic allow_failures: - os: linux python: "nightly" # currently points to 3.7-dev @@ -83,6 +113,12 @@ matrix: - os: osx osx_image: xcode6.4 language: generic + - os: osx + osx_image: xcode7.2 + language: generic + - os: osx + osx_image: xcode7.3 + language: generic - os: linux python: "2.6" - os: linux @@ -106,6 +142,12 @@ matrix: python: "pypy3.5-5.8.0" - os: linux python: "pypy2.7-5.8.0" + - os: linux + python: "pypy3.5-5.10.0" + env: TRAVIS_PYTHON_VERSION="3.5" + - os: linux + python: "pypy2.7-5.10.0" + env: TRAVIS_PYTHON_VERSION="2.7" - os: linux python: "pypy3.5-6.0" - os: linux @@ -168,18 +210,18 @@ script: - if [ $TRAVIS_OS_NAME == osx ] ; then echo "SKIP make test" ; else make test || 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 $? ; - - if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP make test-tox" ; else make test-tox || exit $? ; fi ; - - make clean ; + - make clean || exit $? ; + - if [ $TRAVIS_PYTHON_VERSION == "3.2" ] || [ $TRAVIS_PYTHON_VERSION == "3.3" ] ; then echo "SKIP make test-tox" ; else make test-tox || exit $? ; fi ; + - make clean || true ; - mv -vf ".coverall.Lasting.45678.12345" .coverage 2>/dev/null || true after_failure: - 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 + - if [ $TRAVIS_OS_NAME == osx ] || [ $TRAVIS_PYTHON_VERSION == "3.2" ] || [ $TRAVIS_PYTHON_VERSION == "3.3" ] ; then echo "SKIP code climate" ; else ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT || true ; fi ; + - if [ $TRAVIS_PYTHON_VERSION == "3.2" ] || [ $TRAVIS_PYTHON_VERSION == "3.3" ] ; then echo "SKIP codecov" ; else codecov 2>/dev/null || true ; fi ; + - make clean 2>/dev/null || true after_success: - if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP coverage" ; else coverage combine 2>/dev/null || true ; fi ; @@ -188,9 +230,4 @@ after_success: - 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 ; - 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 - - cov-build --dir cov-int ./ || true - - curl --form token=${COVERTY_TOKEN} --form email=${RF_EMAIL} --form file=@./coverty.tar.gz --form version=1.0 --form description="Python Repo - (Travis CI Build)" https://scan.coverity.com/builds?project=reactive-firewall%2Fpython-repo || true diff --git a/LICENSE b/LICENSE new file mode 120000 index 0000000..1ed0f97 --- /dev/null +++ b/LICENSE @@ -0,0 +1 @@ +./LICENSE.md \ No newline at end of file diff --git a/README.md b/README.md index b274868..94e47ff 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,15 @@ 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/) -![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) [![coverity](https://scan.coverity.com/projects/13847/badge.svg)](https://scan.coverity.com/projects/reactive-firewall-python-repo) -![commits-since](https://img.shields.io/github/commits-since/reactive-firewall/python-repo/stable.svg?maxAge=9000) [![Code Climate](https://codeclimate.com/github/reactive-firewall/python-repo/badges/gpa.svg)](https://codeclimate.com/github/reactive-firewall/python-repo) +[![CodeFactor](https://www.codefactor.io/repository/github/reactive-firewall/python-repo/badge)](https://www.codefactor.io/repository/github/reactive-firewall/python-repo) +[![codebeat badge](https://codebeat.co/badges/da1d8064-5736-49fd-9d61-d046aca38afb)](https://codebeat.co/projects/github-com-reactive-firewall-python-repo-master) +![Size](https://img.shields.io/github/languages/code-size/reactive-firewall/python-repo.svg) +![commits-since](https://img.shields.io/github/commits-since/reactive-firewall/python-repo/stable.svg?maxAge=9000) ### Stable: [![status](https://travis-ci.org/reactive-firewall/python-repo.svg?branch=stable)](https://travis-ci.org/reactive-firewall/python-repo) @@ -28,7 +30,7 @@ By default this template will assume that the Travis CI Service and Circle-CI Se [![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) - +[![codebeat badge](https://codebeat.co/badges/87520e4a-6d24-4e98-a61e-6e9efc58f783)](https://codebeat.co/projects/github-com-reactive-firewall-python-repo-stable) # How do I use this to create a new project repo? diff --git a/docs/conf.py b/docs/conf.py index a9c4e48..3eae510 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -42,7 +42,7 @@ # General information about the project. project = u'python_template' -copyright = u'2017, reactive-firewall' +copyright = u'2017-2018, reactive-firewall' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -65,7 +65,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ['_build', 'tests'] # The reST default role (used for this markup: `text`) to use for all documents. # default_role = None diff --git a/pythonrepo/__init__.py b/pythonrepo/__init__.py index 3608f2f..275d1eb 100644 --- a/pythonrepo/__init__.py +++ b/pythonrepo/__init__.py @@ -20,11 +20,15 @@ __version__ = """1.1.0""" """This is version 1.1.0 of pythonrepo Template""" + try: import sys import os if 'pythonrepo' in __file__: - sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) + __parentPath = os.path.join( + os.path.dirname(__file__), '..' + ) + sys.path.insert(0, os.path.abspath(__parentPath)) except Exception as ImportErr: print(str(type(ImportErr))) print(str(ImportErr)) diff --git a/pythonrepo/pythonrepo.py b/pythonrepo/pythonrepo.py index 37b6932..fdad69f 100644 --- a/pythonrepo/pythonrepo.py +++ b/pythonrepo/pythonrepo.py @@ -3,13 +3,13 @@ # 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. # You may obtain a copy of the License at # .......................................... -# http://www.github.com/reactive-firewall/python-repo/LICENSE.md +# https://www.github.com/reactive-firewall/python-repo/LICENSE.md # .......................................... # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -19,15 +19,8 @@ try: - import os import sys import argparse - sys.path.insert( - 0, - os.path.abspath( - os.path.join(os.path.dirname(__file__), '..') - ) - ) except Exception as err: # Show Error Info print(str(type(err))) @@ -57,7 +50,7 @@ """Contains the short epilog of the program CLI help text.""" -__version__ = """1.0.0""" +__version__ = """1.1.0""" """The version of this program.""" @@ -103,20 +96,24 @@ def parseArgs(arguments=None): return parser.parse_known_args(arguments) +def __checkToolArgs(args=None): + """Handles None case for arguments as a helper function.""" + if args is None: + args = [None] + return args + + 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(): + arguments = __checkToolArgs(arguments) + if (tool is not None) and (tool in TASK_OPTIONS.keys()): try: # print(str("launching: " + tool)) TASK_OPTIONS[tool](arguments) except Exception: print(str( "WARNING - An error occured while" + - "handling the shell. Cascading failure." + "handling the tool. Cascading failure." )) else: return None @@ -147,6 +144,5 @@ def main(argv=None): if __name__ == '__main__': - if (sys.argv is not None) and (sys.argv is not []): - if (len(sys.argv) > 1): - main(sys.argv[1:]) + if (sys.argv is not None) and (len(sys.argv) >= 1): + main(sys.argv[1:]) diff --git a/setup.cfg b/setup.cfg index 9ba2bd2..4aecba0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = pythonrepo -version = 1.0.2 +version = 1.1.1 author = Mr. Walls author-email = reactive-firewall@users.noreply.github.com summary = python-repo template diff --git a/setup.py b/setup.py index d67fa78..8ab954d 100755 --- a/setup.py +++ b/setup.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. @@ -48,7 +48,7 @@ def readFile(filename="""./README.md"""): setup( name="""pythonrepo""", - version="""1.0.2""", + version="""1.1.0""", description="""Python Repo""", long_description=readme, install_requires=requirements, diff --git a/tests/__init__.py b/tests/__init__.py index 1ed0bfd..ea1e6ce 100644 --- a/tests/__init__.py +++ b/tests/__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. diff --git a/tests/test_usage.py b/tests/test_usage.py index e8bb980..15d7bb3 100644 --- a/tests/test_usage.py +++ b/tests/test_usage.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. @@ -51,30 +51,40 @@ def getPythonCommand(): return str(thepython) +def buildPythonCommand(args=None): + """Function for building backend subprocess command line""" + theArgs = args + # you need to change this to the name of your project + __project__ = str("pythonrepo") + try: + if args is None or args is [None]: + theArgs = ["exit 1 ; #"] + else: + theArgs = args + if str("coverage ") in str(theArgs[0]): + if str("{} -m coverage ").format(str(sys.executable)) in str(theArgs[0]): + theArgs[0] = str(sys.executable) + theArgs.insert(1, str("-m")) + theArgs.insert(2, str("coverage")) + theArgs.insert(3, str("run")) + theArgs.insert(4, str("-p")) + theArgs.insert(4, str("--source={}").format(__project__)) + else: + theArgs[0] = str("coverage") + theArgs.insert(1, str("run")) + theArgs.insert(2, str("-p")) + theArgs.insert(2, str("--source={}").format(__project__)) + except Exception: + theArgs = ["exit 1 ; #"] + return theArgs + + 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 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]): - args[0] = str(sys.executable) - args.insert(1, str("-m")) - args.insert(2, str("coverage")) - args.insert(3, str("run")) - args.insert(4, str("-p")) - args.insert(4, str("--source=pythonrepo")) - else: - args[0] = str("coverage") - args.insert(1, str("run")) - args.insert(2, str("-p")) - args.insert(2, str("--source=pythonrepo")) - theOutput = subprocess.check_output(args, stderr=stderr) + taintArgs = buildPythonCommand(args) + theOutput = subprocess.check_output(taintArgs, stderr=stderr) except Exception: theOutput = None try: @@ -98,28 +108,8 @@ 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 str(args[0]): - import sys - if sys.__name__ is None: - raise ImportError("Failed to import system. WTF?!!") - if str("{} -m coverage ").format(str(sys.executable)) in str(args[0]): - args[0] = str(sys.executable) - args.insert(1, str("-m")) - args.insert(2, str("coverage")) - args.insert(3, str("run")) - args.insert(4, str("-p")) - # you need to change this to the name of your project - args.insert(4, str("--source=pythonrepo")) - else: - args[0] = str("coverage") - args.insert(1, str("run")) - args.insert(2, str("-p")) - args.insert(2, str("--source=pythonrepo")) - theOutput = subprocess.check_output(args, stderr=stderr) + taintArgs = buildPythonCommand(args) + theOutput = subprocess.check_output(taintArgs, stderr=stderr) if isinstance(theOutput, bytes): # default to utf8 your milage may vary theOutput = theOutput.decode('utf8') @@ -138,7 +128,7 @@ def debugBlob(blob=None): print(str(blob)) print(str("""\"""")) print(str("")) - print(str("CODE:")) + print(str("Raw:")) print(str("""\"""")) print(repr(blob)) print(str("""\"""")) @@ -148,15 +138,36 @@ def debugBlob(blob=None): return True +def debugIfNoneResult(thepython, theArgs, theOutput): + """In case you need it.""" + try: + if (str(theOutput) is not None): + theResult = True + else: + theResult = False + print(str("")) + print(str("python exe is {}").format(str(sys.executable))) + print(str("python cmd used is {}").format(str(thepython))) + print(str("arguments used were {}").format(str(theArgs))) + print(str("")) + print(str("actual output was...")) + print(str("")) + print(str("{}").format(str(theOutput))) + print(str("")) + except Exception: + theResult = False + return theResult + + class BasicUsageTestSuite(unittest.TestCase): """Basic functional test cases.""" def test_absolute_truth_and_meaning(self): - """Insanity Test.""" + """Insanity Test. if ( is true ) """ assert True def test_syntax(self): - """Test case importing code.""" + """Test case importing code. if ( import is not None ) """ theResult = False try: from .context import pythonrepo @@ -193,19 +204,8 @@ def test_template_case(self): theOutputtext = theOutputtext.decode('utf8') except UnicodeDecodeError: theOutputtext = str(repr(bytes(theOutputtext))) - if (str(theOutputtext) is not None): - theResult = True - else: - theResult = False - print(str("")) - print(str("python exe is {}").format(str(sys.executable))) - print(str("python cmd used is {}").format(str(thepython))) - print(str("arguments used were {}").format(str(thepython))) - print(str("")) - print(str("actual output was...")) - print(str("")) - print(str("{}").format(str(theOutputtext))) - print(str("")) + # ADD REAL VERSION TEST HERE + theResult = debugIfNoneResult(thepython, args, theOutputtext) # or simply: self.assertIsNotNone(theOutputtext) except Exception as err: @@ -243,19 +243,7 @@ def test_profile_template_case(self): theOutputtext = theOutputtext.decode('utf8') except UnicodeDecodeError: theOutputtext = str(repr(bytes(theOutputtext))) - if (str(theOutputtext) is not None): - theResult = True - else: - theResult = False - print(str("")) - print(str("python exe is {}").format(str(sys.executable))) - print(str("python cmd used is {}").format(str(thepython))) - print(str("arguments used were {}").format(str(thepython))) - print(str("")) - print(str("actual output was...")) - print(str("")) - print(str("{}").format(str(theOutputtext))) - print(str("")) + theResult = debugIfNoneResult(thepython, args, theOutputtext) # or simply: self.assertIsNotNone(theOutputtext) except Exception as err: @@ -294,19 +282,7 @@ def test_fail_template_case(self): theOutputtext = theOutputtext.decode('utf8') except UnicodeDecodeError: theOutputtext = str(repr(bytes(theOutputtext))) - if (str(theOutputtext) is not None): - theResult = True - else: - theResult = False - print(str("")) - print(str("python exe is {}").format(str(sys.executable))) - print(str("python cmd used is {}").format(str(thepython))) - print(str("arguments used were {}").format(str(thepython))) - print(str("")) - print(str("actual output was...")) - print(str("")) - print(str("{}").format(str(theOutputtext))) - print(str("")) + theResult = debugIfNoneResult(thepython, args, theOutputtext) # or simply: self.assertIsNotNone(theOutputtext) except Exception as err: @@ -345,19 +321,7 @@ def test_bad_template_case(self): theOutputtext = theOutputtext.decode('utf8') except UnicodeDecodeError: theOutputtext = str(repr(bytes(theOutputtext))) - if (str(theOutputtext) is not None): - theResult = True - else: - theResult = False - print(str("")) - print(str("python exe is {}").format(str(sys.executable))) - print(str("python cmd used is {}").format(str(thepython))) - print(str("arguments used were {}").format(str(thepython))) - print(str("")) - print(str("actual output was...")) - print(str("")) - print(str("{}").format(str(theOutputtext))) - print(str("")) + theResult = debugIfNoneResult(thepython, args, theOutputtext) # or simply: self.assertIsNotNone(theOutputtext) except Exception as err: