Skip to content

Commit b26b1c6

Browse files
committed
Backport from newer pythons
* `usedevelop = False`, do not use pip for develop install due to PEP0517 * fix codestyle * fresh mypy * travis movement Signed-off-by: Aleksei Stepanov <penguinolog@gmail.com>
1 parent 5d17bd4 commit b26b1c6

18 files changed

+273
-239
lines changed

.editorconfig

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ root = true
33
[*]
44
charset = utf-8
55
end_of_line = lf
6-
indent_size = 4
6+
indent_size = 2
77
indent_style = space
88
insert_final_newline = true
99
trim_trailing_whitespace = true
1010

11-
[*.{py,ini}]
11+
[*.{py,pyx,pxd,pyi}]
12+
indent_size = 4
1213
max_line_length = 120
1314

14-
[*.{yml,yaml,rst}]
15-
indent_size = 2
15+
[*.rst]
16+
max_line_length = 150
1617

1718
[Makefile]
1819
indent_style = tab

.travis.yml

Lines changed: 87 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -2,108 +2,108 @@ sudo: false
22
language: python
33
os: linux
44
install:
5-
- &upgrade_python_toolset pip install --upgrade pip setuptools wheel
6-
- pip install --upgrade pytest pytest-mock pytest-sugar
7-
- &install_deps pip install -r CI_REQUIREMENTS.txt
8-
- pip install --upgrade pytest-cov coveralls
5+
- &upgrade_python_toolset pip install --upgrade pip setuptools wheel
6+
- pip install --upgrade pytest pytest-mock pytest-sugar
7+
- &install_deps pip install -r CI_REQUIREMENTS.txt
8+
- pip install --upgrade pytest-cov coveralls
99

1010
_python:
11-
- &python27
12-
name: "Python 2.7"
13-
python: "2.7"
14-
- &pypy
15-
name: "PyPy"
16-
python: "pypy"
17-
- &python37
18-
name: "Python 3.7"
19-
python: "3.7"
20-
dist: xenial
21-
sudo: true
11+
- &python27
12+
name: "Python 2.7"
13+
python: "2.7"
14+
- &pypy
15+
name: "PyPy"
16+
python: "pypy"
17+
- &python37
18+
name: "Python 3.7"
19+
python: "3.7"
20+
dist: xenial
21+
sudo: true
2222

2323
_helpers:
24-
- &build_package python setup.py bdist_wheel
24+
- &build_package python setup.py bdist_wheel
2525

26-
- &static_analysis
27-
stage: Static analysis
28-
<<: *python27
29-
after_success: skip
26+
- &static_analysis
27+
stage: Static analysis
28+
<<: *python27
29+
after_success: skip
3030

31-
- &code_style_check
32-
stage: Code style check
33-
<<: *python27
34-
after_success: skip
31+
- &code_style_check
32+
stage: Code style check
33+
<<: *python27
34+
after_success: skip
3535

3636
script:
37-
- pip install -e .
38-
- py.test -vv --cov-config .coveragerc --cov-report= --cov=exec_helpers test
39-
- coverage report -m --fail-under 87
37+
- python setup.py develop -v
38+
- py.test -vvv --cov-config .coveragerc --cov-report= --cov=exec_helpers test
39+
- coverage report -m --fail-under 87
4040
after_success:
41-
- coveralls
41+
- coveralls
4242

4343
jobs:
4444
include:
45-
- <<: *static_analysis
46-
name: "PyLint"
47-
install:
48-
- *upgrade_python_toolset
49-
- *install_deps
50-
- pip install --upgrade "pylint < 2.0"
51-
script:
52-
- pylint exec_helpers
53-
- <<: *static_analysis
54-
name: "Bandit"
55-
install:
56-
- *upgrade_python_toolset
57-
- pip install --upgrade bandit
58-
script:
59-
- bandit -r exec_helpers
60-
- <<: *static_analysis
61-
name: "PEP8"
62-
install:
63-
- *upgrade_python_toolset
64-
- pip install --upgrade flake8
65-
script:
66-
- flake8
45+
- <<: *static_analysis
46+
name: "PyLint"
47+
install:
48+
- *upgrade_python_toolset
49+
- *install_deps
50+
- pip install --upgrade "pylint < 2.0"
51+
script:
52+
- pylint exec_helpers
53+
- <<: *static_analysis
54+
name: "Bandit"
55+
install:
56+
- *upgrade_python_toolset
57+
- pip install --upgrade bandit
58+
script:
59+
- bandit -r exec_helpers
60+
- <<: *static_analysis
61+
name: "PEP8"
62+
install:
63+
- *upgrade_python_toolset
64+
- pip install --upgrade flake8
65+
script:
66+
- flake8
6767

68-
# - <<: *code_style_check
69-
# name: "PEP257"
70-
# install:
71-
# - *upgrade_python_toolset
72-
# - pip install --upgrade pydocstyle
73-
# script:
74-
# - pydocstyle -v exec_helpers
68+
# - <<: *code_style_check
69+
# name: "PEP257"
70+
# install:
71+
# - *upgrade_python_toolset
72+
# - pip install --upgrade pydocstyle
73+
# script:
74+
# - pydocstyle -v exec_helpers
7575

76-
- stage: test
77-
<<: *python27
78-
- stage: test
79-
<<: *pypy
76+
- stage: test
77+
<<: *python27
78+
- stage: test
79+
<<: *pypy
8080

81-
- stage: deploy
82-
# This prevents job from appearing in test plan unless commit is tagged:
83-
if: tag IS present
84-
<<: *pypy
85-
name: Build universal bdist_wheel. Deploy bdist and sdist.
86-
services: []
87-
install:
88-
- *upgrade_python_toolset
89-
- pip install -r build_requirements.txt
90-
script:
91-
- *build_package
92-
before_deploy: []
93-
deploy:
94-
- provider: pypi
95-
# `skip_cleanup: true` is required to preserve binary wheels, built
96-
# inside of manylinux1 docker container during `script` step above.
97-
skip_cleanup: true
98-
user: penguinolog
99-
password:
100-
secure: "maml4+SU/6NtRf7JIwWhVyXkesE9Gk5Umdo3txOjcrcvt84S3NlN/hFgdNclMUpJ3b+rOFEpiZOamtDKbP67uhlA6yJ364SxW5T3ZQJ8tjFFzMHcaM38HgGbgLR8AxK8fdZKRg9gVMnGofeiusB5aNsKmn9XnvESc8dNv0Umdmi83wXxm+DfVRXL8VTFgwsH3BxQy/Kdv6upRrXyNWkyoi8Zk8PkrFFDpFoW9WK1fRBqnvCw1Wt8nEAJah7y2b7vj52eM+MfT3IL+jpocZqOJQlFPdWkTonX7mAP9nB97kk4DMbm3ZqUw2Qr9pM0nKK9HhrXhsSSUGa1w95zmw9nbXLrpfnQ61Lyk9pGcVh60WbrVKstE/x9Lq3pqGsA/YKqsIZK3OAqRfBHNG9L7lekP05hXyDNHJXGoEyGQjVA/666S2ZCjM10XaaUmZ5P1kPGocCnEjv86dKdINTkFM6L0n4oIu1nyftBhVu9jz0xQaxute4LZNJiQtE6x8NX3WuSO68UhWjDqevYdRgW55Gp1OD4ilfA/SVNPpsHJfB2baue1fi9m8Rn3bWQSJoZ8twYHoIxEOAIXyMBhYnmldvsuUY6h5p+/hk6kpJAsTXZFjUSa/FPIH84QvDkNCoZxwInSkjEN1tj9PBep2vYcLMd92+g6udtin8FbYMZItiDl1M="
101-
on:
102-
tags: true
103-
distributions: sdist
104-
skip_upload_docs: true
105-
skip_existing: true
81+
- stage: deploy
82+
# This prevents job from appearing in test plan unless commit is tagged:
83+
if: tag IS present
84+
<<: *pypy
85+
name: Build universal bdist_wheel. Deploy bdist and sdist.
86+
services: []
87+
install:
88+
- *upgrade_python_toolset
89+
- pip install -r build_requirements.txt
90+
script:
91+
- *build_package
92+
before_deploy: []
93+
deploy:
94+
- provider: pypi
95+
# `skip_cleanup: true` is required to preserve binary wheels, built
96+
# inside of manylinux1 docker container during `script` step above.
97+
skip_cleanup: true
98+
user: penguinolog
99+
password:
100+
secure: "maml4+SU/6NtRf7JIwWhVyXkesE9Gk5Umdo3txOjcrcvt84S3NlN/hFgdNclMUpJ3b+rOFEpiZOamtDKbP67uhlA6yJ364SxW5T3ZQJ8tjFFzMHcaM38HgGbgLR8AxK8fdZKRg9gVMnGofeiusB5aNsKmn9XnvESc8dNv0Umdmi83wXxm+DfVRXL8VTFgwsH3BxQy/Kdv6upRrXyNWkyoi8Zk8PkrFFDpFoW9WK1fRBqnvCw1Wt8nEAJah7y2b7vj52eM+MfT3IL+jpocZqOJQlFPdWkTonX7mAP9nB97kk4DMbm3ZqUw2Qr9pM0nKK9HhrXhsSSUGa1w95zmw9nbXLrpfnQ61Lyk9pGcVh60WbrVKstE/x9Lq3pqGsA/YKqsIZK3OAqRfBHNG9L7lekP05hXyDNHJXGoEyGQjVA/666S2ZCjM10XaaUmZ5P1kPGocCnEjv86dKdINTkFM6L0n4oIu1nyftBhVu9jz0xQaxute4LZNJiQtE6x8NX3WuSO68UhWjDqevYdRgW55Gp1OD4ilfA/SVNPpsHJfB2baue1fi9m8Rn3bWQSJoZ8twYHoIxEOAIXyMBhYnmldvsuUY6h5p+/hk6kpJAsTXZFjUSa/FPIH84QvDkNCoZxwInSkjEN1tj9PBep2vYcLMd92+g6udtin8FbYMZItiDl1M="
101+
on:
102+
tags: true
103+
distributions: sdist
104+
skip_upload_docs: true
105+
skip_existing: true
106106

107107
cache: pip
108108
before_cache:
109-
- rm -f $HOME/.cache/pip/log/debug.log
109+
- rm -f $HOME/.cache/pip/log/debug.log

README.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
exec-helpers
22
============
33

4-
.. image:: https://travis-ci.org/python-useful-helpers/exec-helpers.svg?branch=master
5-
:target: https://travis-ci.org/python-useful-helpers/exec-helpers
4+
.. image:: https://travis-ci.com/python-useful-helpers/exec-helpers.svg?branch=master
5+
:target: https://travis-ci.com/python-useful-helpers/exec-helpers
66
.. image:: https://coveralls.io/repos/github/python-useful-helpers/exec-helpers/badge.svg?branch=master
77
:target: https://coveralls.io/github/python-useful-helpers/exec-helpers?branch=master
88
.. image:: https://readthedocs.org/projects/exec-helpers/badge/?version=latest
@@ -25,8 +25,10 @@ you can call command with timeout, but without receiving return code,
2525
or call command and wait for return code, but without timeout processing.
2626

2727
In the most cases, we are need just simple SSH client with comfortable API for calls, calls via SSH proxy and checking return code/stderr.
28-
This library offers this functionality with connection memorizing, deadlock free polling and friendly result objects (with inline decoding of YAML, JSON, binary or just strings).
29-
In addition this library offers the same API for subprocess calls, but with specific limitation: no parallel calls (for protection from race conditions).
28+
This library offers this functionality with connection memorizing, deadlock free polling and friendly result objects
29+
(with inline decoding of YAML, JSON, binary or just strings).
30+
In addition this library offers the same API for subprocess calls, but with specific limitation: no parallel calls
31+
(for protection from race conditions).
3032

3133
Pros:
3234

@@ -96,7 +98,7 @@ Creation from scratch:
9698
)
9799
98100
Key is a main connection key (always tried first) and keys are alternate keys.
99-
Key filename is a filename or list of filenames with keys, which should be loaded.
101+
Key filename is afilename or list of filenames with keys, which should be loaded.
100102
Passphrase is an alternate password for keys, if it differs from main password.
101103
If main key now correct for username - alternate keys tried, if correct key found - it became main.
102104
If no working key - password is used and None is set as main key.
@@ -116,7 +118,7 @@ Base methods
116118
------------
117119
Main methods are `execute`, `check_call` and `check_stderr` for simple executing, executing and checking return code
118120
and executing, checking return code and checking for empty stderr output.
119-
This methods are almost the same for `SSHCleint` and `Subprocess`, except specific flags.
121+
This methods are almost the same for `SSHClient` and `Subprocess`, except specific flags.
120122

121123
.. note:: By default ALL methods have timeout 1 hour, infinite waiting can be enabled, but it's special case.
122124

@@ -166,7 +168,7 @@ If no STDOUT or STDERR required, it is possible to disable this FIFO pipes via `
166168
The next command level uses lower level and kwargs are forwarded, so expected exit codes are forwarded from `check_stderr`.
167169
Implementation specific flags are always set via kwargs.
168170

169-
If required to mask part of command from logging, `log_mask_re` attribute can be set global over instance or providden with command.
171+
If required to mask part of command from logging, `log_mask_re` attribute can be set global over instance or provided with command.
170172
All regex matched groups will be replaced by `'<*masked*>'`.
171173

172174
.. code-block:: python
@@ -327,6 +329,6 @@ CI systems
327329
==========
328330
For code checking several CI systems is used in parallel:
329331

330-
1. `Travis CI: <https://travis-ci.org/python-useful-helpers/exec-helpers>`_ is used for checking: PEP8, pylint, bandit, installation possibility and unit tests. Also it's publishes coverage on coveralls.
332+
1. `Travis CI: <https://travis-ci.com/python-useful-helpers/exec-helpers>`_ is used for checking: PEP8, pylint, bandit, installation possibility and unit tests. Also it's publishes coverage on coveralls.
331333

332334
2. `coveralls: <https://coveralls.io/github/python-useful-helpers/exec-helpers>`_ is used for coverage display.

exec_helpers/__init__.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,25 @@
1616

1717
from __future__ import absolute_import
1818

19+
# External Dependencies
1920
import pkg_resources
2021

21-
from .proc_enums import ExitCodes
22-
23-
from .exceptions import (
24-
ExecHelperError,
25-
ExecCalledProcessError,
26-
CalledProcessError,
27-
ParallelCallProcessError,
28-
ParallelCallExceptions,
29-
ExecHelperNoKillError,
30-
ExecHelperTimeoutError,
31-
)
32-
22+
# Local Implementation
23+
from ._ssh_client_base import SshExecuteAsyncResult
3324
from .api import ExecHelper
25+
from .exceptions import CalledProcessError
26+
from .exceptions import ExecCalledProcessError
27+
from .exceptions import ExecHelperError
28+
from .exceptions import ExecHelperNoKillError
29+
from .exceptions import ExecHelperTimeoutError
30+
from .exceptions import ParallelCallExceptions
31+
from .exceptions import ParallelCallProcessError
3432
from .exec_result import ExecResult
33+
from .proc_enums import ExitCodes
3534
from .ssh_auth import SSHAuth
3635
from .ssh_client import SSHClient
37-
from ._ssh_client_base import SshExecuteAsyncResult
38-
from .subprocess_runner import Subprocess, SubprocessExecuteAsyncResult # nosec # Expected
36+
from .subprocess_runner import Subprocess # nosec # Expected
37+
from .subprocess_runner import SubprocessExecuteAsyncResult # nosec # Expected
3938

4039
__all__ = (
4140
"ExecHelperError",

exec_helpers/_ssh_client_base.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
from __future__ import division
2121
from __future__ import unicode_literals
2222

23+
# Standard Library
2324
import abc
2425
import base64
25-
2626
# noinspection PyCompatibility
2727
import concurrent.futures
2828
import copy
@@ -35,19 +35,21 @@
3535
import typing # noqa: F401 # pylint: disable=unused-import
3636
import warnings
3737

38+
# External Dependencies
3839
import advanced_descriptors
3940
import paramiko # type: ignore
41+
import six
4042
import tenacity # type: ignore
4143
import threaded
42-
import six
4344

45+
# Exec-Helpers Implementation
46+
from exec_helpers import _log_templates
4447
from exec_helpers import api
4548
from exec_helpers import constants
46-
from exec_helpers import exec_result
4749
from exec_helpers import exceptions
50+
from exec_helpers import exec_result
4851
from exec_helpers import proc_enums
4952
from exec_helpers import ssh_auth
50-
from exec_helpers import _log_templates
5153

5254
__all__ = ("SSHClientBase", "SshExecuteAsyncResult")
5355

@@ -119,7 +121,7 @@ def __call__( # type: ignore
119121
password=None, # type: typing.Optional[typing.Union[str, typing.Text]]
120122
private_keys=None, # type: typing.Optional[typing.Iterable[paramiko.RSAKey]]
121123
auth=None, # type: typing.Optional[ssh_auth.SSHAuth]
122-
verbose=True # type: bool
124+
verbose=True, # type: bool
123125
): # type: (...) -> SSHClientBase
124126
"""Main memorize method: check for cached instance and return it.
125127
@@ -574,7 +576,7 @@ def execute_async(
574576
"""
575577
cmd_for_log = self._mask_command(cmd=command, log_mask_re=log_mask_re)
576578

577-
self.logger.log( # type: ignore
579+
self.logger.log(
578580
level=logging.INFO if verbose else logging.DEBUG, msg=_log_templates.CMD_EXEC.format(cmd=cmd_for_log)
579581
)
580582

@@ -740,7 +742,7 @@ def execute_through_host(
740742
.. versionchanged:: 1.2.0 log_mask_re regex rule for masking cmd
741743
"""
742744
cmd_for_log = self._mask_command(cmd=command, log_mask_re=kwargs.get("log_mask_re", None))
743-
self.logger.log( # type: ignore
745+
self.logger.log(
744746
level=logging.INFO if verbose else logging.DEBUG, msg=_log_templates.CMD_EXEC.format(cmd=cmd_for_log)
745747
)
746748

0 commit comments

Comments
 (0)