From 089e9eee1e1fc3935a13d6f35c254de5da7f0ad0 Mon Sep 17 00:00:00 2001 From: reactive-firewall Date: Sat, 26 May 2018 16:12:28 -0700 Subject: [PATCH 01/13] fix badges --- LICENSE | 1 + README.md | 8 ++- tests/test_usage.py | 160 +++++++++++++++++--------------------------- 3 files changed, 68 insertions(+), 101 deletions(-) create mode 120000 LICENSE 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/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: From d66152aff8d368f729c0f43002a936c9da49e6ac Mon Sep 17 00:00:00 2001 From: reactive-firewall Date: Wed, 30 May 2018 00:25:12 -0700 Subject: [PATCH 02/13] fix for whitespace --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b17497d..17dcc9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -168,7 +168,7 @@ 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 $? ; + - make clean || 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 From 69d305c0e2d6217e80d2b1197db2dbcf07937bd9 Mon Sep 17 00:00:00 2001 From: reactive-firewall Date: Thu, 16 Aug 2018 19:54:09 -0700 Subject: [PATCH 03/13] minor fixes to copyright --- docs/conf.py | 4 ++-- pythonrepo/pythonrepo.py | 4 ++-- setup.py | 2 +- tests/__init__.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) 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/pythonrepo.py b/pythonrepo/pythonrepo.py index 37b6932..498278f 100644 --- a/pythonrepo/pythonrepo.py +++ b/pythonrepo/pythonrepo.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. @@ -57,7 +57,7 @@ """Contains the short epilog of the program CLI help text.""" -__version__ = """1.0.0""" +__version__ = """1.1.0""" """The version of this program.""" diff --git a/setup.py b/setup.py index d67fa78..5ba7429 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. 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. From b914f9d165de5e390055ffc8d835415bb6906804 Mon Sep 17 00:00:00 2001 From: reactive-firewall Date: Thu, 16 Aug 2018 19:55:01 -0700 Subject: [PATCH 04/13] version bump --- setup.cfg | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 5ba7429..8ab954d 100755 --- a/setup.py +++ b/setup.py @@ -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, From 077b445eb96622bf5efcc42979baf32449c7cc16 Mon Sep 17 00:00:00 2001 From: reactive-firewall Date: Fri, 17 Aug 2018 20:13:40 -0700 Subject: [PATCH 05/13] workaround for broken python 3.3 env on travis --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 17dcc9c..3cce52e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -169,16 +169,16 @@ script: - 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 ; + - 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 ; + - 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/nul || true after_success: From da7139ac2fd5d6605149b501430cbc9f4570abef Mon Sep 17 00:00:00 2001 From: reactive-firewall Date: Sat, 18 Aug 2018 10:50:12 -0700 Subject: [PATCH 06/13] #23 reduced code duplication as recommended by code climate --- pythonrepo/__init__.py | 6 +++++- pythonrepo/pythonrepo.py | 6 ------ 2 files changed, 5 insertions(+), 7 deletions(-) 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 498278f..58a14f1 100644 --- a/pythonrepo/pythonrepo.py +++ b/pythonrepo/pythonrepo.py @@ -22,12 +22,6 @@ 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))) From 4842bf4e0d4aa2e7a55c048943273d001db6557a Mon Sep 17 00:00:00 2001 From: reactive-firewall Date: Sat, 18 Aug 2018 10:55:05 -0700 Subject: [PATCH 07/13] #23 fix for regression bug --- pythonrepo/pythonrepo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pythonrepo/pythonrepo.py b/pythonrepo/pythonrepo.py index 58a14f1..62b74ac 100644 --- a/pythonrepo/pythonrepo.py +++ b/pythonrepo/pythonrepo.py @@ -19,7 +19,6 @@ try: - import os import sys import argparse except Exception as err: From 72b82fa908b60e731c922c79758b5f897e0dc144 Mon Sep 17 00:00:00 2001 From: reactive-firewall Date: Sun, 19 Aug 2018 21:33:09 -0700 Subject: [PATCH 08/13] #23 - minor typo fix --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3cce52e..e89be30 100644 --- a/.travis.yml +++ b/.travis.yml @@ -179,7 +179,7 @@ after_failure: - 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" ] || [ $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/nul || true + - 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 ; From 6e35e6a9c4570fe97be5cd4b5abb22908b39986b Mon Sep 17 00:00:00 2001 From: reactive-firewall Date: Mon, 20 Aug 2018 13:43:14 -0700 Subject: [PATCH 09/13] #24 Fixed Trailing Space --- .pyup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 2940548f3f9e6a291fdd20956638ee6856b0b91e Mon Sep 17 00:00:00 2001 From: reactive-firewall Date: Mon, 20 Aug 2018 14:54:08 -0700 Subject: [PATCH 10/13] #25 Fixed Exsesive Cognitive Complexity --- pythonrepo/pythonrepo.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pythonrepo/pythonrepo.py b/pythonrepo/pythonrepo.py index 62b74ac..b6768b2 100644 --- a/pythonrepo/pythonrepo.py +++ b/pythonrepo/pythonrepo.py @@ -9,7 +9,7 @@ # 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, @@ -100,16 +100,14 @@ 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(): + 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 @@ -140,6 +138,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:]) From 25f0b585b60b65f8d4721a31c3c02b18d754344c Mon Sep 17 00:00:00 2001 From: reactive-firewall Date: Wed, 22 Aug 2018 13:07:14 -0700 Subject: [PATCH 11/13] #25 Reduced cognitive complexity by breaking up function into checks and work slightly --- pythonrepo/pythonrepo.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pythonrepo/pythonrepo.py b/pythonrepo/pythonrepo.py index b6768b2..fdad69f 100644 --- a/pythonrepo/pythonrepo.py +++ b/pythonrepo/pythonrepo.py @@ -96,10 +96,16 @@ 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] + arguments = __checkToolArgs(arguments) if (tool is not None) and (tool in TASK_OPTIONS.keys()): try: # print(str("launching: " + tool)) From 2fc1229e30280a5562cf1a767f8b4aae7c259b9b Mon Sep 17 00:00:00 2001 From: reactive-firewall Date: Wed, 22 Aug 2018 14:01:02 -0700 Subject: [PATCH 12/13] Posible fix for coverity scans and CI env updates --- .travis.yml | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index e89be30..eb3fbd2 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 @@ -55,12 +73,6 @@ matrix: - os: linux python: "nightly" # currently points to 3.7-dev env: TRAVIS_PYTHON_VERSION="3.7-dev" - - os: osx - osx_image: xcode7.2 - language: generic - - os: osx - osx_image: xcode7.3 - language: generic - os: osx osx_image: xcode8 language: generic @@ -76,6 +88,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 +101,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 +130,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 @@ -188,9 +218,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 From ff11403f73f5fa4f346fe29ba2027a6fde2bcb77 Mon Sep 17 00:00:00 2001 From: reactive-firewall Date: Wed, 22 Aug 2018 14:15:38 -0700 Subject: [PATCH 13/13] Fixed regression in CI env updates --- .travis.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.travis.yml b/.travis.yml index eb3fbd2..deb33e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,9 +70,21 @@ 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" + - os: osx + osx_image: xcode7.2 + language: generic + - os: osx + osx_image: xcode7.3 + language: generic - os: osx osx_image: xcode8 language: generic