Skip to content

Commit eb345c6

Browse files
author
saville
committed
Remove py 3.6/3.7 support and add 3.11
1 parent 5cf37d0 commit eb345c6

16 files changed

+140
-206
lines changed

.github/workflows/build.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
python-version:
15-
- 3.7
1615
- 3.8
1716
- 3.9
1817
- '3.10'
18+
- '3.11'
1919
steps:
2020
- uses: actions/checkout@v2
2121
- name: Set up Python ${{ matrix.python-version }}

.pylintrc

+3-83
Original file line numberDiff line numberDiff line change
@@ -65,87 +65,7 @@ confidence=
6565
# --enable=similarities". If you want to run only the classes checker, but have
6666
# no Warning level messages displayed, use "--disable=all --enable=classes
6767
# --disable=W".
68-
disable=print-statement,
69-
parameter-unpacking,
70-
unpacking-in-except,
71-
old-raise-syntax,
72-
backtick,
73-
long-suffix,
74-
old-ne-operator,
75-
old-octal-literal,
76-
import-star-module-level,
77-
non-ascii-bytes-literal,
78-
raw-checker-failed,
79-
bad-inline-option,
80-
locally-disabled,
81-
file-ignored,
82-
suppressed-message,
83-
useless-suppression,
84-
deprecated-pragma,
85-
use-symbolic-message-instead,
86-
apply-builtin,
87-
basestring-builtin,
88-
buffer-builtin,
89-
cmp-builtin,
90-
coerce-builtin,
91-
execfile-builtin,
92-
file-builtin,
93-
long-builtin,
94-
raw_input-builtin,
95-
reduce-builtin,
96-
standarderror-builtin,
97-
unicode-builtin,
98-
xrange-builtin,
99-
coerce-method,
100-
delslice-method,
101-
getslice-method,
102-
setslice-method,
103-
no-absolute-import,
104-
old-division,
105-
dict-iter-method,
106-
dict-view-method,
107-
next-method-called,
108-
metaclass-assignment,
109-
indexing-exception,
110-
raising-string,
111-
reload-builtin,
112-
oct-method,
113-
hex-method,
114-
nonzero-method,
115-
cmp-method,
116-
input-builtin,
117-
round-builtin,
118-
intern-builtin,
119-
unichr-builtin,
120-
map-builtin-not-iterating,
121-
zip-builtin-not-iterating,
122-
range-builtin-not-iterating,
123-
filter-builtin-not-iterating,
124-
using-cmp-argument,
125-
eq-without-hash,
126-
div-method,
127-
idiv-method,
128-
rdiv-method,
129-
exception-message-attribute,
130-
invalid-str-codec,
131-
sys-max-int,
132-
bad-python3-import,
133-
deprecated-string-function,
134-
deprecated-str-translate-call,
135-
deprecated-itertools-function,
136-
deprecated-types-field,
137-
next-method-defined,
138-
dict-items-not-iterating,
139-
dict-keys-not-iterating,
140-
dict-values-not-iterating,
141-
deprecated-operator-function,
142-
deprecated-urllib-function,
143-
xreadlines-attribute,
144-
deprecated-sys-function,
145-
exception-escape,
146-
comprehension-escape,
147-
bare-except,
148-
logging-fstring-interpolation,
68+
disable=logging-fstring-interpolation,
14969
unnecessary-pass,
15070
wrong-import-order,
15171
too-few-public-methods,
@@ -595,5 +515,5 @@ min-public-methods=2
595515

596516
# Exceptions that will emit a warning when being caught. Defaults to
597517
# "BaseException, Exception".
598-
overgeneral-exceptions=BaseException,
599-
Exception
518+
overgeneral-exceptions=builtins.BaseException,
519+
builtins.Exception

CHANGELOG.rst

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
.. contents::
66
:local:
77

8+
3.0
9+
###
10+
11+
* 3.0
12+
13+
* Add python 3.11 support
14+
* Remove python 3.6 and 3.7 support
15+
816
2.0
917
###
1018

buildrunner/__init__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def __init__(
219219

220220
# print out env vars
221221
# pylint: disable=consider-iterating-dictionary
222-
key_len = max([len(key) for key in self.env.keys()])
222+
key_len = max(len(key) for key in self.env.keys())
223223
for key in sorted(self.env.keys()):
224224
val = self.env[key]
225225
LOGGER.debug(f'Environment: {key!s:>{key_len}}: {val}')
@@ -274,7 +274,8 @@ def log(self):
274274

275275
try:
276276
log_file_path = os.path.join(self.build_results_dir, 'build.log')
277-
self._log_file = open(log_file_path, 'w')
277+
# pylint: disable=consider-using-with
278+
self._log_file = open(log_file_path, 'w', encoding='utf8')
278279
self._log = ConsoleLogger(self.colorize_log, self._log_file)
279280

280281
self.add_artifact(
@@ -385,6 +386,7 @@ def get_local_files_from_alias(self, file_alias):
385386
return local_path
386387

387388
# need to put the contents in a tmp file and return the path
389+
# pylint: disable=consider-using-with
388390
_fileobj = tempfile.NamedTemporaryFile(
389391
delete=False,
390392
dir=self.global_config.get_temp_dir(),
@@ -470,6 +472,7 @@ def _exclude_working_dir(tarinfo):
470472
self.log.write('Creating source archive\n')
471473
_fileobj = None
472474
try:
475+
# pylint: disable=consider-using-with
473476
_fileobj = tempfile.NamedTemporaryFile(
474477
delete=False,
475478
dir=self.global_config.get_temp_dir(),

buildrunner/config.py

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def _raise_exception_jinja(message):
5454
"""
5555
Raises an exception from a jinja template.
5656
"""
57+
# pylint: disable=broad-exception-raised
5758
raise Exception(message)
5859

5960
@staticmethod

buildrunner/docker/builder.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def __init__(
4343
if os.path.exists(dockerfile):
4444
self.dockerfile = dockerfile
4545
else:
46+
# pylint: disable=consider-using-with
4647
df_file = tempfile.NamedTemporaryFile(delete=False, dir=self.temp_dir)
4748
try:
4849
df_file.write(dockerfile.encode('utf-8'))
@@ -88,16 +89,16 @@ def build(self, console=None, nocache=False, cache_from=None, rm=True, pull=True
8889
if buildargs is None:
8990
buildargs = {}
9091
# create our own tar file, injecting the appropriate paths
92+
# pylint: disable=consider-using-with
9193
_fileobj = tempfile.NamedTemporaryFile(dir=self.temp_dir)
92-
tfile = tarfile.open(mode='w', fileobj=_fileobj)
93-
if self.path:
94-
tfile.add(self.path, arcname='.')
95-
if self.inject:
96-
for to_inject, dest in self.inject.items():
97-
tfile.add(to_inject, arcname=dest)
98-
if self.dockerfile:
99-
tfile.add(self.dockerfile, arcname='./Dockerfile')
100-
tfile.close()
94+
with tarfile.open(mode='w', fileobj=_fileobj) as tfile:
95+
if self.path:
96+
tfile.add(self.path, arcname='.')
97+
if self.inject:
98+
for to_inject, dest in self.inject.items():
99+
tfile.add(to_inject, arcname=dest)
100+
if self.dockerfile:
101+
tfile.add(self.dockerfile, arcname='./Dockerfile')
101102
_fileobj.seek(0)
102103

103104
# Always add default registry to build args

buildrunner/fetch/github.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def v3_fetch_file(parsed_url, config):
3535
'users',
3636
username,
3737
))
38-
resp = requests.get(url, auth=auth)
38+
resp = requests.get(url, auth=auth, timeout=180)
3939
if resp.status_code != 200:
4040
raise BuildRunnerProtocolError(f'Failed authenticating {username} on {endpoint}')
4141

@@ -46,7 +46,7 @@ def v3_fetch_file(parsed_url, config):
4646
ubuild = [endpoint, version, 'repos', fpath[1], fpath[2], 'contents']
4747
ubuild.extend(fpath[3:])
4848
url = '/'.join(ubuild)
49-
resp = requests.get(url, auth=auth)
49+
resp = requests.get(url, auth=auth, timeout=180)
5050
if resp.status_code != 200:
5151
raise BuildRunnerProtocolError(f'Failed fetching URL: {url}')
5252
json_c = resp.json()

buildrunner/provisioners/salt.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def provision(self, runner):
3232
# see if salt is installed, bootstrap if it isn't
3333
if runner.run('salt-call -h') != 0:
3434
# pull bootstrap and run as a script
35-
bootstrap_response = requests.get('http://bootstrap.saltstack.org')
35+
bootstrap_response = requests.get('http://bootstrap.saltstack.org', timeout=600)
3636
if bootstrap_response.status_code != 200:
3737
raise BuildRunnerProvisionerError(
3838
"Unable to get salt bootstrap"

buildrunner/sshagent/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
SSHException,
2525
)
2626
from paramiko.agent import AgentSSH
27-
from paramiko.common import asbytes, io_sleep
27+
from paramiko.common import io_sleep
28+
from paramiko.util import asbytes
2829
from paramiko.message import Message
2930

3031
from buildrunner.errors import (
@@ -224,6 +225,7 @@ def _try_connect(self, ssh_host, ssh_port):
224225
time.sleep(backoff)
225226
else:
226227
self.log.write(f'Unable to successfully connect to {ssh_host}')
228+
# pylint: disable=broad-exception-raised
227229
raise Exception(f'Unable to successfully connect to {ssh_host}')
228230

229231
def stop(self):

buildrunner/steprunner/tasks/run.py

+3
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ def _retrieve_artifacts(self, console=None): # pylint: disable=too-many-locals
226226
log=self.step_runner.log,
227227
)
228228
if exit_code != 0:
229+
# pylint: disable=broad-exception-raised
229230
raise Exception(
230231
"Error gathering artifacts--unable to change ownership"
231232
)
@@ -274,6 +275,7 @@ def _archive_dir(
274275
log=self.step_runner.log,
275276
)
276277
if exit_code != 0:
278+
# pylint: disable=broad-exception-raised
277279
raise Exception(
278280
f"Error gathering artifact {artifact_file}",
279281
)
@@ -383,6 +385,7 @@ def _archive_file(
383385
workdir=workdir,
384386
)
385387
if exit_code != 0:
388+
# pylint: disable=broad-exception-raised
386389
raise Exception(
387390
f"Error gathering artifact {artifact_file}",
388391
)

buildrunner/utils.py

+2
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ def write(self, output: Union[bytes, str], color=None):
201201
# colorize stdout
202202
if color and self.colorize_log:
203203
# Colorize stdout
204+
# pylint: disable=invalid-character-esc
204205
_stdout = f'[01;3{color}m{_stdout}\033[00;00m'
205206
self.stdout.write(_stdout)
206207

@@ -339,6 +340,7 @@ def _acquire_flock_open(
339340
:param exclusive: config exclusive lock (True) or shared lock (False), defaults to True
340341
:return: opened file object if successful else None
341342
"""
343+
# pylint: disable=unspecified-encoding,consider-using-with
342344
file_obj = open(lock_file, mode)
343345
pid = os.getpid()
344346
lock_file_obj = None

requirements.in

+9-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
# Last version to support python 3.6
2-
GitPython<=3.1.18
3-
Jinja2==2.11.2
4-
MarkupSafe==1.1.1
5-
PyYAML==6.0
6-
bcrypt==3.2.0
7-
decorator==5.1.0
8-
docker==4.4.4
9-
fabric==2.5.0
10-
paramiko==2.10.3
11-
requests==2.27.0
12-
twine==3.2.0
1+
Jinja2>=2.11.2
2+
PyYAML>=6.0
3+
bcrypt>=3.2.0
4+
decorator>=5.1.0
5+
docker>=6.1.2
6+
fabric>=2.5.0
7+
paramiko>=2.10.3
8+
requests>=2.27.0
9+
twine>=3.2.0
1310
vcsinfo>=2.1.105
1411
graphlib-backport>=1.0.3
15-
# Needed for python 3.6
16-
typing-extensions<4.2.0
1712
timeout-decorator>=0.5.0

0 commit comments

Comments
 (0)