Skip to content

Commit d478c4f

Browse files
authored
Bump to 2.1.0 (#85)
* API changes: async calls * Code style changed * Docs and types explanations fixed * Require `threaded>=2.0` as properly typed
1 parent 0d3d16c commit d478c4f

File tree

6 files changed

+76
-107
lines changed

6 files changed

+76
-107
lines changed

exec_helpers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"ExecResult",
5050
)
5151

52-
__version__ = "2.0.2"
52+
__version__ = "2.1.0"
5353
__author__ = "Alexey Stepanov"
5454
__author_email__ = "penguinolog@gmail.com"
5555
__maintainers__ = {

exec_helpers/_ssh_client_base.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ def __repr__(self) -> str:
359359

360360
def __str__(self) -> str: # pragma: no cover
361361
"""Representation for debug purposes."""
362-
return "{cls}(host={self.hostname}, port={self.port}) for user {self.auth.username}".format(
363-
cls=self.__class__.__name__, self=self
362+
return "{cls}(host={self.hostname}, port={self.port}) for user {username}".format(
363+
cls=self.__class__.__name__, self=self, username=self.auth.username
364364
)
365365

366366
@property
@@ -827,13 +827,13 @@ def get_result(remote: "SSHClientBase") -> exec_result.ExecResult:
827827
cmd_for_log = remote._mask_command(cmd=command, log_mask_re=kwargs.get("log_mask_re", None))
828828
# pylint: enable=protected-access
829829

830-
result = exec_result.ExecResult(cmd=cmd_for_log)
831-
result.read_stdout(src=async_result.stdout)
832-
result.read_stderr(src=async_result.stderr)
833-
result.exit_code = exit_code
830+
res = exec_result.ExecResult(cmd=cmd_for_log)
831+
res.read_stdout(src=async_result.stdout)
832+
res.read_stderr(src=async_result.stderr)
833+
res.exit_code = exit_code
834834

835835
async_result.interface.close()
836-
return result
836+
return res
837837

838838
expected = expected or [proc_enums.ExitCodes.EX_OK]
839839
expected = proc_enums.exit_codes_to_enums(expected)

exec_helpers/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def mask(text: str, rules: str) -> str:
122122
end = indexes[idx + 1]
123123
masked += text[start:end] + "<*masked*>"
124124

125+
# noinspection PyPep8
125126
masked += text[indexes[-2] : indexes[-1]] # final part
126127
return masked
127128

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
paramiko>=2.4 # LGPLv2.1+
22
tenacity>=4.4.0 # Apache-2.0
33
six>=1.10.0 # MIT
4-
threaded>=1.0 # Apache-2.0
4+
threaded>=2.0 # Apache-2.0
55
PyYAML>=3.12 # MIT
66
advanced-descriptors>=1.0 # Apache-2.0
77
typing >= 3.6 ; python_version < "3.8"

setup.py

Lines changed: 65 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -30,65 +30,61 @@
3030
import sys
3131

3232
try:
33+
# noinspection PyPackageRequirements
3334
from Cython.Build import cythonize
3435
except ImportError:
3536
cythonize = None
3637

3738
import setuptools
3839

39-
with open(
40-
os.path.join(
41-
os.path.dirname(__file__),
42-
'exec_helpers', '__init__.py'
43-
)
44-
) as f:
40+
with open(os.path.join(os.path.dirname(__file__), "exec_helpers", "__init__.py")) as f:
4541
source = f.read()
4642

47-
with open('requirements.txt') as f:
43+
with open("requirements.txt") as f:
4844
required = f.read().splitlines()
4945

50-
with open('README.rst',) as f:
46+
with open("README.rst") as f:
5147
long_description = f.read()
5248

5349

5450
def _extension(modpath):
5551
"""Make setuptools.Extension."""
56-
source_path = modpath.replace('.', '/') + '.py'
52+
source_path = modpath.replace(".", "/") + ".py"
5753
return setuptools.Extension(modpath, [source_path])
5854

5955

6056
requires_optimization = [
61-
_extension('exec_helpers.api'),
62-
_extension('exec_helpers.constants'),
63-
_extension('exec_helpers._log_templates'),
64-
_extension('exec_helpers.exceptions'),
65-
_extension('exec_helpers.exec_result'),
66-
_extension('exec_helpers.proc_enums'),
67-
_extension('exec_helpers._ssh_client_base'),
68-
_extension('exec_helpers.ssh_auth'),
69-
_extension('exec_helpers.ssh_client'),
70-
_extension('exec_helpers.subprocess_runner'),
57+
_extension("exec_helpers.api"),
58+
_extension("exec_helpers.constants"),
59+
_extension("exec_helpers._log_templates"),
60+
_extension("exec_helpers.exceptions"),
61+
_extension("exec_helpers.exec_result"),
62+
_extension("exec_helpers.proc_enums"),
63+
_extension("exec_helpers._ssh_client_base"),
64+
_extension("exec_helpers.ssh_auth"),
65+
_extension("exec_helpers.ssh_client"),
66+
_extension("exec_helpers.subprocess_runner"),
7167
]
7268

73-
if 'win32' != sys.platform:
74-
requires_optimization.append(
75-
_extension('exec_helpers.__init__')
76-
)
69+
if "win32" != sys.platform:
70+
requires_optimization.append(_extension("exec_helpers.__init__"))
7771

78-
ext_modules = cythonize(
79-
requires_optimization,
80-
compiler_directives=dict(
81-
always_allow_keywords=True,
82-
binding=True,
83-
embedsignature=True,
84-
overflowcheck=True,
85-
language_level=3,
72+
# noinspection PyCallingNonCallable
73+
ext_modules = (
74+
cythonize(
75+
requires_optimization,
76+
compiler_directives=dict(
77+
always_allow_keywords=True, binding=True, embedsignature=True, overflowcheck=True, language_level=3
78+
),
8679
)
87-
) if cythonize is not None else []
80+
if cythonize is not None
81+
else []
82+
)
8883

8984

9085
class BuildFailed(Exception):
9186
"""For install clear scripts."""
87+
9288
pass
9389

9490

@@ -102,12 +98,10 @@ def run(self):
10298

10399
# Copy __init__.py back to repair package.
104100
build_dir = os.path.abspath(self.build_lib)
105-
root_dir = os.path.abspath(os.path.join(__file__, '..'))
101+
root_dir = os.path.abspath(os.path.join(__file__, ".."))
106102
target_dir = build_dir if not self.inplace else root_dir
107103

108-
src_files = (
109-
os.path.join('exec_helpers', '__init__.py'),
110-
)
104+
src_files = (os.path.join("exec_helpers", "__init__.py"),)
111105

112106
for src_file in src_files:
113107
src = os.path.join(root_dir, src_file)
@@ -117,7 +111,7 @@ def run(self):
117111
shutil.copyfile(src, dst)
118112
except (
119113
distutils.errors.DistutilsPlatformError,
120-
getattr(globals()['__builtins__'], 'FileNotFoundError', OSError)
114+
getattr(globals()["__builtins__"], "FileNotFoundError", OSError),
121115
):
122116
raise BuildFailed()
123117

@@ -129,7 +123,7 @@ def build_extension(self, ext):
129123
distutils.errors.CCompilerError,
130124
distutils.errors.DistutilsExecError,
131125
distutils.errors.DistutilsPlatformError,
132-
ValueError
126+
ValueError,
133127
):
134128
raise BuildFailed()
135129

@@ -181,11 +175,7 @@ def get_simple_vars_from_src(src):
181175
>>> get_simple_vars_from_src(multiple_assign)
182176
OrderedDict([('e', 1), ('f', 1), ('g', 1)])
183177
"""
184-
ast_data = (
185-
ast.Str, ast.Num,
186-
ast.List, ast.Set, ast.Dict, ast.Tuple,
187-
ast.Bytes, ast.NameConstant,
188-
)
178+
ast_data = (ast.Str, ast.Num, ast.List, ast.Set, ast.Dict, ast.Tuple, ast.Bytes, ast.NameConstant)
189179

190180
tree = ast.parse(src)
191181

@@ -197,9 +187,7 @@ def get_simple_vars_from_src(src):
197187
try:
198188
if isinstance(node.value, ast_data):
199189
value = ast.literal_eval(node.value)
200-
elif isinstance( # NameConstant in python < 3.4
201-
node.value, ast.Name
202-
) and isinstance(
190+
elif isinstance(node.value, ast.Name) and isinstance( # NameConstant in python < 3.4
203191
node.value.ctx, ast.Load # Read constant
204192
):
205193
value = ast.literal_eval(node.value)
@@ -208,84 +196,64 @@ def get_simple_vars_from_src(src):
208196
except ValueError:
209197
continue
210198
for tgt in node.targets:
211-
if isinstance(
212-
tgt, ast.Name
213-
) and isinstance(
214-
tgt.ctx, ast.Store
215-
):
199+
if isinstance(tgt, ast.Name) and isinstance(tgt.ctx, ast.Store):
216200
result[tgt.id] = value
217201
return result
218202

219203

220204
variables = get_simple_vars_from_src(source)
221205

222206
classifiers = [
223-
'Development Status :: 5 - Production/Stable',
224-
225-
'Intended Audience :: Developers',
226-
'Topic :: Software Development :: Libraries :: Python Modules',
227-
228-
'License :: OSI Approved :: Apache Software License',
229-
230-
'Programming Language :: Python :: 3',
231-
'Programming Language :: Python :: 3.4',
232-
'Programming Language :: Python :: 3.5',
233-
'Programming Language :: Python :: 3.6',
234-
'Programming Language :: Python :: 3.7',
235-
236-
'Programming Language :: Python :: Implementation :: CPython',
237-
'Programming Language :: Python :: Implementation :: PyPy',
207+
"Development Status :: 5 - Production/Stable",
208+
"Intended Audience :: Developers",
209+
"Topic :: Software Development :: Libraries :: Python Modules",
210+
"License :: OSI Approved :: Apache Software License",
211+
"Programming Language :: Python :: 3",
212+
"Programming Language :: Python :: 3.4",
213+
"Programming Language :: Python :: 3.5",
214+
"Programming Language :: Python :: 3.6",
215+
"Programming Language :: Python :: 3.7",
216+
"Programming Language :: Python :: Implementation :: CPython",
217+
"Programming Language :: Python :: Implementation :: PyPy",
238218
]
239219

240-
keywords = [
241-
'logging',
242-
'debugging',
243-
'development',
244-
]
220+
keywords = ["logging", "debugging", "development"]
245221

246222
setup_args = dict(
247-
name='exec-helpers',
248-
author=variables['__author__'],
249-
author_email=variables['__author_email__'],
250-
maintainer=', '.join(
251-
'{name} <{email}>'.format(name=name, email=email)
252-
for name, email in variables['__maintainers__'].items()
223+
name="exec-helpers",
224+
author=variables["__author__"],
225+
author_email=variables["__author_email__"],
226+
maintainer=", ".join(
227+
"{name} <{email}>".format(name=name, email=email) for name, email in variables["__maintainers__"].items()
253228
),
254-
url=variables['__url__'],
255-
version=variables['__version__'],
256-
license=variables['__license__'],
257-
description=variables['__description__'],
229+
url=variables["__url__"],
230+
version=variables["__version__"],
231+
license=variables["__license__"],
232+
description=variables["__description__"],
258233
long_description=long_description,
259234
classifiers=classifiers,
260235
keywords=keywords,
261-
python_requires='>=3.4',
236+
python_requires=">=3.4",
262237
# While setuptools cannot deal with pre-installed incompatible versions,
263238
# setting a lower bound is not harmful - it makes error messages cleaner. DO
264239
# NOT set an upper bound on setuptools, as that will lead to uninstallable
265240
# situations as progressive releases of projects are done.
266241
# Blacklist setuptools 34.0.0-34.3.2 due to https://github.com/pypa/setuptools/issues/951
267242
# Blacklist setuptools 36.2.0 due to https://github.com/pypa/setuptools/issues/1086
268243
setup_requires="setuptools >= 21.0.0,!=24.0.0,"
269-
"!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,"
270-
"!=36.2.0",
244+
"!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,"
245+
"!=36.2.0",
271246
install_requires=required,
272-
package_data={
273-
'exec_helpers': ['py.typed'],
274-
},
247+
package_data={"exec_helpers": ["py.typed"]},
275248
)
276249
if cythonize is not None:
277-
setup_args['ext_modules'] = ext_modules
278-
setup_args['cmdclass'] = dict(build_ext=AllowFailRepair)
250+
setup_args["ext_modules"] = ext_modules
251+
setup_args["cmdclass"] = dict(build_ext=AllowFailRepair)
279252

280253
try:
281254
setuptools.setup(**setup_args)
282255
except BuildFailed:
283-
print(
284-
'*' * 80 + '\n'
285-
'* Build Failed!\n'
286-
'* Use clear scripts version.\n'
287-
'*' * 80 + '\n'
288-
)
289-
del setup_args['ext_modules']
290-
del setup_args['cmdclass']
256+
print("*" * 80 + "\n" "* Build Failed!\n" "* Use clear scripts version.\n" "*" * 80 + "\n")
257+
del setup_args["ext_modules"]
258+
del setup_args["cmdclass"]
291259
setuptools.setup(**setup_args)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
[tox]
77
minversion = 2.0
8-
envlist = pep8, pylint, mypy, bandit, pep257, py{34,35,36,37,py3}, docs, py{34,35,36,37}-nocov
8+
envlist = black, pep8, pylint, mypy, bandit, pep257, py{34,35,36,37,py3}, docs, py{34,35,36,37}-nocov
99
skipsdist = True
1010
skip_missing_interpreters = True
1111

0 commit comments

Comments
 (0)