From 2fb4f547a915755e21be401bb7fd3f4817505e89 Mon Sep 17 00:00:00 2001 From: John R Barker Date: Mon, 6 Nov 2017 15:54:37 +0000 Subject: If pip install requirements.txt fails, upgrade pip (#32399) * If pip install requirements.txt fails, upgrade pip * Use pycodestyle instead of pep8 (#25947) (cherry picked from commit 4b3d6dfa8a10188995e1b027849540e1a440e88d) * Ignore more * pylint lint fixes * Ignore more --- CODING_GUIDELINES.md | 10 +++++----- lib/ansible/modules/packaging/os/apt_repository.py | 1 + test/runner/lib/executor.py | 13 ++++--------- test/runner/lib/sanity.py | 2 +- test/runner/requirements/sanity.txt | 5 ++++- test/sanity/pep8/current-ignore.txt | 4 ++++ 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/CODING_GUIDELINES.md b/CODING_GUIDELINES.md index 60bf41ea65..f11af31d78 100644 --- a/CODING_GUIDELINES.md +++ b/CODING_GUIDELINES.md @@ -14,15 +14,15 @@ Language * While not all components of Ansible must be in Python, core contributions to the Ansible repo must be written in Python. This is to maximize the ability of everyone to contribute. * If you want to write non-Python ansible modules or inventory scripts, that's fine, but they are not going to get merged in most likely. Sorry!! -PEP8 and basic style checks +PEP 8 and basic style checks =========================== - * PEP8 is a great Python style guide, which you should read. - * PEP8 must not be strictly followed in all aspects, but most of it is good advice + * [PEP 8](https://www.python.org/dev/peps/pep-0008/) is a great Python style guide, which you should read. + * PEP 8 must not be strictly followed in all aspects, but most of it is good advice * In particular, we don't really care about line lengths. Buy a bigger monitor! - * To run checks for things we care about, run "make pep8" + * To run checks for things we care about, use [ansible-test](http://docs.ansible.com/ansible/dev_guide/testing_pep8.html#running-locally). * Similarly, additional checks can be made with "make pyflakes" - * There is no need to submit code changes for pep8 and pyflake fixes, as these break attribution history. Project leadership will make these periodically. + * There is no need to submit code changes for PEP 8 and pyflakes fixes, as these break attribution history. Project leadership will make these periodically. * Do not submit pull requests that simply adjust whitespace in the code Testing diff --git a/lib/ansible/modules/packaging/os/apt_repository.py b/lib/ansible/modules/packaging/os/apt_repository.py index b29dd69c49..6de23bb88c 100644 --- a/lib/ansible/modules/packaging/os/apt_repository.py +++ b/lib/ansible/modules/packaging/os/apt_repository.py @@ -210,6 +210,7 @@ class SourcesList(object): if filename is not None: return filename return '_'.join(re.sub('[^a-zA-Z0-9]', ' ', s).split()) + def _strip_username_password(s): if '@' in s: s = s.split('@', 1) diff --git a/test/runner/lib/executor.py b/test/runner/lib/executor.py index 848cb3adc6..b760832945 100644 --- a/test/runner/lib/executor.py +++ b/test/runner/lib/executor.py @@ -156,16 +156,11 @@ def install_command_requirements(args): try: run_command(args, cmd) - except SubprocessError as ex: - if ex.status != 2: - raise - - # If pip is too old it won't understand the arguments we passed in, so we'll need to upgrade it. + except SubprocessError: + # Gundalow/Mattclay: Revisit logic here https://github.com/ansible/ansible/issues/32398 + # If the install fails for any reason, upgrade pip and retry. + # We don't wish to unconditionally upgrade pip, as that would reduce test coverage - # Installing "coverage" on ubuntu 16.04 fails with the error: - # AttributeError: 'Requirement' object has no attribute 'project_name' - # See: https://bugs.launchpad.net/ubuntu/xenial/+source/python-pip/+bug/1626258 - # Upgrading pip works around the issue. run_command(args, ['pip', 'install', '--upgrade', 'pip']) run_command(args, cmd) diff --git a/test/runner/lib/sanity.py b/test/runner/lib/sanity.py index 93405b23ae..134111d636 100644 --- a/test/runner/lib/sanity.py +++ b/test/runner/lib/sanity.py @@ -316,7 +316,7 @@ def command_sanity_pep8(args, targets): return SanitySkipped(test) cmd = [ - 'pep8', + 'pycodestyle', '--max-line-length', '160', '--config', '/dev/null', '--ignore', ','.join(sorted(current_ignore)), diff --git a/test/runner/requirements/sanity.txt b/test/runner/requirements/sanity.txt index 98a92117c6..df8c7c0713 100644 --- a/test/runner/requirements/sanity.txt +++ b/test/runner/requirements/sanity.txt @@ -1,9 +1,12 @@ +cryptography jinja2 mock -pep8 +paramiko +pycodestyle pylint pytest rstcheck sphinx +virtualenv voluptuous yamllint diff --git a/test/sanity/pep8/current-ignore.txt b/test/sanity/pep8/current-ignore.txt index d09a3150be..e87d7d0338 100644 --- a/test/sanity/pep8/current-ignore.txt +++ b/test/sanity/pep8/current-ignore.txt @@ -22,9 +22,13 @@ E266 E301 E302 E303 +E305 +E306 E402 E502 E713 +E722 E731 +E741 W391 W503 -- cgit v1.2.1