Skip to content

Commit

Permalink
Merge pull request #6997 from frenzymadness/future_is_now
Browse files Browse the repository at this point in the history
Future is now
  • Loading branch information
p12tic committed Dec 20, 2023
2 parents 2ce6c3c + 6072fc1 commit c56f870
Show file tree
Hide file tree
Showing 59 changed files with 37 additions and 266 deletions.
2 changes: 0 additions & 2 deletions .bbtravis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ matrix:
- env: PYTHON=3.9 TWISTED=latest SQLALCHEMY=latest TESTS=interop WORKER_PYTHON=3.7
- env: PYTHON=3.9 TWISTED=latest SQLALCHEMY=latest TESTS=interop WORKER_PYTHON=3.6
- env: PYTHON=3.9 TWISTED=latest SQLALCHEMY=latest TESTS=interop WORKER_PYTHON=3.5
- env: PYTHON=3.9 TWISTED=latest SQLALCHEMY=latest TESTS=interop WORKER_PYTHON=2.7

# Worker tests on python and twisted package combinations.
# We support worker on Python 2.7, on which Twisted 20.3.0 is the last version that works
- env: PYTHON=3.9 TWISTED=18.7.0 SQLALCHEMY=latest TESTS=trial_worker
- env: PYTHON=2.7 TWISTED=20.3.0 SQLALCHEMY=latest TESTS=trial_worker

# Configuration when SQLite database is persistent between running tests
# (by default in other tests in-memory SQLite database is used which is
Expand Down
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[settings]
line_length=110
known_future_library=__future__,future
known_future_library=__future__
known_standard_library=html
known_twisted=twisted,zope,autobahn,klein,txaio
known_mock=mock
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/changes/changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#
# Copyright Buildbot Team Members

import html # py2: via future
import html
import time

from twisted.internet import defer
Expand Down
2 changes: 0 additions & 2 deletions master/buildbot/test/integration/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ def setUpUpgradeTest(self):
tf.extract(inf)
prefixes.add(inf.name.split('/', 1)[0])

# (note that tf.extractall isn't available in py2.4)

# get the top-level dir from the tarball
assert len(prefixes) == 1, "tarball has multiple top-level dirs!"
self.basedir = prefixes.pop()
Expand Down
4 changes: 0 additions & 4 deletions master/buildbot/worker/upcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
# Copyright Buildbot Team Members
# -*- Coding: utf-8 -*-

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import hashlib
import socket

Expand Down
2 changes: 2 additions & 0 deletions newsfragments/worker-python27.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removed Python 2.7 support on the worker. This does not affect compatibility of connecting workers
running old versions of Buildbot to masters running new versions of Buildbot.
3 changes: 0 additions & 3 deletions pyinstaller/buildbot-worker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import absolute_import
from __future__ import print_function

from buildbot_worker.scripts.runner import run

run()
1 change: 0 additions & 1 deletion requirements-ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ docutils==0.18.1 # pyup: ignore (sphinx-rtd-theme 1.2.0 requires docutils<0.19)
extras==1.0.0
fixtures==4.1.0
funcsigs==1.0.2
future==0.18.3
graphql-core==3.2.3
greenlet==3.0.1
hvac==1.2.1
Expand Down
3 changes: 0 additions & 3 deletions worker/buildbot_worker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
# We can't put this method in utility modules, because they import dependency packages
#

from __future__ import division
from __future__ import print_function

import datetime
import os
import re
Expand Down
3 changes: 0 additions & 3 deletions worker/buildbot_worker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#
# Copyright Buildbot Team Members

from __future__ import absolute_import
from __future__ import print_function

import multiprocessing
import os.path
import socket
Expand Down
3 changes: 0 additions & 3 deletions worker/buildbot_worker/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#
# Copyright Buildbot Team Members

from __future__ import absolute_import
from __future__ import print_function

from buildbot_worker.null import LocalWorker
from buildbot_worker.pb import Worker

Expand Down
3 changes: 0 additions & 3 deletions worker/buildbot_worker/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#
# Copyright Buildbot Team Members

from __future__ import absolute_import
from __future__ import print_function

from twisted.internet import defer
from twisted.internet import reactor
from twisted.python import log
Expand Down
3 changes: 0 additions & 3 deletions worker/buildbot_worker/commands/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#
# Copyright Buildbot Team Members

from __future__ import absolute_import
from __future__ import print_function

import glob
import os
import platform
Expand Down
3 changes: 0 additions & 3 deletions worker/buildbot_worker/commands/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#
# Copyright Buildbot Team Members

from __future__ import absolute_import
from __future__ import print_function

import buildbot_worker.commands.fs
import buildbot_worker.commands.shell
import buildbot_worker.commands.transfer
Expand Down
3 changes: 0 additions & 3 deletions worker/buildbot_worker/commands/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#
# Copyright Buildbot Team Members

from __future__ import absolute_import
from __future__ import print_function

from buildbot_worker import runprocess
from buildbot_worker.commands import base

Expand Down
30 changes: 11 additions & 19 deletions worker/buildbot_worker/commands/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#
# Copyright Buildbot Team Members

from __future__ import absolute_import
from __future__ import print_function

import os
import tarfile
import tempfile
Expand Down Expand Up @@ -210,29 +207,24 @@ def start(self):
# Create temporary archive
fd, self.tarname = tempfile.mkstemp(prefix='buildbot-transfer-')
self.fp = os.fdopen(fd, "rb+")

if self.compress == 'bz2':
mode = 'w|bz2'
elif self.compress == 'gz':
mode = 'w|gz'
else:
mode = 'w'
# TODO: Use 'with' when depending on Python 2.7
# Not possible with older versions:
# exceptions.AttributeError: 'TarFile' object has no attribute '__exit__'
archive = tarfile.open(mode=mode, fileobj=self.fp)
try:
archive.add(self.path, '')
except OSError as e:
# if directory does not exist, bail out with an error
self.stderr = "Cannot read directory '{0}' for upload: {1}".format(self.path, e)
self.rc = 1
archive.close()
d = defer.succeed(False)
d.addCallback(self.finished)
return d

archive.close()
with tarfile.open(mode=mode, fileobj=self.fp) as archive:
try:
archive.add(self.path, '')
except OSError as e:
# if directory does not exist, bail out with an error
self.stderr = "Cannot read directory '{0}' for upload: {1}".format(self.path, e)
self.rc = 1
archive.close() # need to close it before self.finished() runs below
d = defer.succeed(False)
d.addCallback(self.finished)
return d

# Transfer it
self.fp.seek(0)
Expand Down
8 changes: 2 additions & 6 deletions worker/buildbot_worker/commands/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
#
# Copyright Buildbot Team Members

from __future__ import absolute_import
from __future__ import print_function
from future.utils import text_type

import os

from twisted.python import log
Expand Down Expand Up @@ -67,9 +63,9 @@ def rmdirRecursive(dir):
# Thus, if a non-unicode-named dir contains a unicode filename, that filename will get
# garbled.
# So force dir to be unicode.
if not isinstance(dir, text_type):
if not isinstance(dir, str):
try:
dir = text_type(dir, "utf-8")
dir = str(dir, "utf-8")
except UnicodeDecodeError:
log.err("rmdirRecursive: decoding from UTF-8 failed (ignoring)")

Expand Down
27 changes: 6 additions & 21 deletions worker/buildbot_worker/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,7 @@
between Python 2 and Python 3.
"""

from __future__ import absolute_import
from __future__ import print_function
from future.utils import text_type

if str != bytes:
# On Python 3 and higher, str and bytes
# are not equivalent. We must use StringIO for
# doing io on native strings.
from io import StringIO as NativeStringIO
else:
# On Python 2 and older, str and bytes
# are equivalent. We must use BytesIO for
# doing io on native strings.
from io import BytesIO as NativeStringIO
from io import StringIO as NativeStringIO


def bytes2NativeString(x, encoding='utf-8'):
Expand Down Expand Up @@ -60,13 +47,12 @@ def unicode2bytes(x, encoding='utf-8', errors='strict'):
"""
Convert a unicode string to C{bytes}.
@param x: a unicode string, of type C{unicode} on Python 2,
or C{str} on Python 3.
@param x: a unicode string, of type C{str}.
@param encoding: an optional codec, default: 'utf-8'
@param errors: error handling scheme, default 'strict'
@return: a string of type C{bytes}
"""
if isinstance(x, text_type):
if isinstance(x, str):
x = x.encode(encoding, errors)
return x

Expand All @@ -75,16 +61,15 @@ def bytes2unicode(x, encoding='utf-8', errors='strict'):
"""
Convert a C{bytes} to a unicode string.
@param x: a unicode string, of type C{unicode} on Python 2,
or C{str} on Python 3.
@param x: a unicode string, of type C{str}.
@param encoding: an optional codec, default: 'utf-8'
@param errors: error handling scheme, default 'strict'
@return: a unicode string of type C{unicode} on Python 2, or
C{str} on Python 3.
"""
if isinstance(x, (text_type, type(None))):
if isinstance(x, (str, type(None))):
return x
return text_type(x, encoding, errors)
return str(x, encoding, errors)


__all__ = [
Expand Down
3 changes: 0 additions & 3 deletions worker/buildbot_worker/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#
# Copyright Buildbot Team Members

from __future__ import absolute_import
from __future__ import print_function


class AbandonChain(Exception):

Expand Down
3 changes: 0 additions & 3 deletions worker/buildbot_worker/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
# pylint: disable=no-method-argument
# pylint: disable=inherit-non-class

from __future__ import absolute_import
from __future__ import print_function

from zope.interface import Interface


Expand Down
3 changes: 0 additions & 3 deletions worker/buildbot_worker/monkeypatches/testcase_assert.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#
# Copyright Buildbot Team Members

from __future__ import absolute_import
from __future__ import print_function

import unittest


Expand Down
3 changes: 0 additions & 3 deletions worker/buildbot_worker/msgpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#
# Copyright Buildbot Team Members

from __future__ import absolute_import
from __future__ import print_function

import base64

import msgpack
Expand Down
3 changes: 0 additions & 3 deletions worker/buildbot_worker/null.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#
# Copyright Buildbot Team Members

from __future__ import absolute_import
from __future__ import print_function

from twisted.internet import defer

from buildbot_worker.base import WorkerBase
Expand Down
3 changes: 0 additions & 3 deletions worker/buildbot_worker/pb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#
# Copyright Buildbot Team Members

from __future__ import absolute_import
from __future__ import print_function

import os.path
import shutil
import signal
Expand Down
6 changes: 1 addition & 5 deletions worker/buildbot_worker/pbutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
"""Base classes handy for use with PB clients.
"""

from __future__ import absolute_import
from __future__ import print_function
from future.utils import iteritems

from twisted.application.internet import backoffPolicy
from twisted.cred import error
from twisted.internet import defer
Expand Down Expand Up @@ -153,6 +149,6 @@ def decode(data, encoding='utf-8', errors='strict'):
return bytes2unicode(data, encoding, errors)
if data_type in (dict, list, tuple):
if data_type == dict:
data = iteritems(data)
data = data.items()
return data_type(map(decode, data))
return data

0 comments on commit c56f870

Please sign in to comment.