Skip to content

Commit

Permalink
Merge pull request #1126 from biozz/drop-py27-py34
Browse files Browse the repository at this point in the history
Drop support for Python versions 2.7 and 3.4
  • Loading branch information
k4nar authored Apr 6, 2020
2 parents bfa2189 + 48dadba commit aa1bca9
Show file tree
Hide file tree
Showing 51 changed files with 137 additions and 1,055 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ jobs:
env: TOX_ENV=py36
- python: 3.5
env: TOX_ENV=py35
- python: 3.4
env: TOX_ENV=py34
- python: 2.7
env: TOX_ENV=py27

script:
- tox -v -e $TOX_ENV
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ clean:
rm -rf bin .tox include/ lib/ man/ circus.egg-info/ build/
find . -name "*.pyc" | xargs rm -f
find . -name "*.un~" | xargs rm -f
find . -name "__pycache__" | xargs rm -rf
5 changes: 1 addition & 4 deletions bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@
except ImportError:
ez = {}

try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
from urllib.request import urlopen

exec(urlopen('http://python-distribute.org/distribute_setup.py').read(), ez)
setup_args = dict(to_dir=tmpeggs, download_delay=0, no_fake=True)
Expand Down
13 changes: 0 additions & 13 deletions circus/_patch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import threading
from threading import _active_limbo_lock, _active, _sys
from .util import get_python_version


debugger = False
Expand Down Expand Up @@ -33,15 +32,3 @@ def _delete(self): # NOQA
raise

threading.Thread._delete = _delete

# see http://bugs.python.org/issue14308
if get_python_version() < (2, 7, 0):
def _stop(self):
# DummyThreads delete self.__block, but they have no waiters to
# notify anyway (join() is forbidden on them).
if not hasattr(self, '_Thread__block'):
return
self._Thread__stop_old()

threading.Thread._Thread__stop_old = threading.Thread._Thread__stop
threading.Thread._Thread__stop = _stop
1 change: 0 additions & 1 deletion circus/circusctl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -
import argparse
import cmd
import getopt
Expand Down
13 changes: 5 additions & 8 deletions circus/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

# -*- coding: utf-8 -
import errno
import uuid

Expand All @@ -9,8 +7,7 @@
import tornado

from circus.exc import CallError
from circus.py3compat import string_types, b
from circus.util import DEFAULT_ENDPOINT_DEALER, get_connection
from circus.util import DEFAULT_ENDPOINT_DEALER, get_connection, to_bytes


def make_message(command, **props):
Expand All @@ -31,7 +28,7 @@ def __init__(self, context=None, endpoint=DEFAULT_ENDPOINT_DEALER,
timeout=5.0, ssh_server=None, ssh_keyfile=None):
self._init_context(context)
self.endpoint = endpoint
self._id = b(uuid.uuid4().hex)
self._id = to_bytes(uuid.uuid4().hex)
self.socket = self.context.socket(zmq.DEALER)
self.socket.setsockopt(zmq.IDENTITY, self._id)
self.socket.setsockopt(zmq.LINGER, 0)
Expand All @@ -57,7 +54,7 @@ def send_message(self, command, **props):

@tornado.gen.coroutine
def call(self, cmd):
if isinstance(cmd, string_types):
if isinstance(cmd, str):
raise DeprecationWarning('call() takes a mapping')

call_id = uuid.uuid4().hex
Expand Down Expand Up @@ -90,7 +87,7 @@ def __init__(self, context=None, endpoint=DEFAULT_ENDPOINT_DEALER,
timeout=5.0, ssh_server=None, ssh_keyfile=None):
self._init_context(context)
self.endpoint = endpoint
self._id = b(uuid.uuid4().hex)
self._id = to_bytes(uuid.uuid4().hex)
self.socket = self.context.socket(zmq.DEALER)
self.socket.setsockopt(zmq.IDENTITY, self._id)
self.socket.setsockopt(zmq.LINGER, 0)
Expand All @@ -116,7 +113,7 @@ def send_message(self, command, **props):
return self.call(make_message(command, **props))

def call(self, cmd):
if isinstance(cmd, string_types):
if isinstance(cmd, str):
raise DeprecationWarning('call() takes a mapping')

call_id = uuid.uuid4().hex
Expand Down
5 changes: 2 additions & 3 deletions circus/commands/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from circus.exc import ArgumentError, MessageError
from circus.py3compat import string_types
from circus import util
import warnings
try:
Expand Down Expand Up @@ -124,7 +123,7 @@ def _valid_prefix():
raise MessageError("%r isn't a number" % key)

elif key in ('uid', 'gid',):
if not isinstance(val, int) and not isinstance(val, string_types):
if not isinstance(val, int) and not isinstance(val, str):
raise MessageError("%r isn't an integer or string" % key)

elif key in ('send_hup', 'shell', 'copy_env', 'respawn', 'stop_children',
Expand All @@ -138,7 +137,7 @@ def _valid_prefix():
raise MessageError("%r isn't a valid object" % key)

for k, v in val.items():
if not isinstance(v, string_types):
if not isinstance(v, str):
raise MessageError("%r isn't a string" % k)

elif key == 'hooks':
Expand Down
13 changes: 6 additions & 7 deletions circus/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import glob
import operator
import os
import signal
import warnings
Expand All @@ -8,10 +9,7 @@
except ImportError:
resource = None # NOQA

import six

from circus import logger
from circus.py3compat import sort_by_field
from circus.util import (DEFAULT_ENDPOINT_DEALER, DEFAULT_ENDPOINT_SUB,
DEFAULT_ENDPOINT_MULTICAST, DEFAULT_ENDPOINT_STATS,
StrictConfigParser, replace_gnu_args, to_signum,
Expand Down Expand Up @@ -281,9 +279,10 @@ def get_config(config_file):
watchers.append(watcher)

# making sure we return consistent lists
sort_by_field(watchers)
sort_by_field(plugins)
sort_by_field(sockets)
name = operator.itemgetter('name')
watchers.sort(key=name)
plugins.sort(key=name)
sockets.sort(key=name)

# Second pass to make sure env sections apply to all watchers.

Expand All @@ -294,7 +293,7 @@ def _extend(target, source):
target[name] = value

def _expand_vars(target, key, env):
if isinstance(target[key], six.string_types):
if isinstance(target[key], str):
target[key] = replace_gnu_args(target[key], env=env)
elif isinstance(target[key], dict):
for k in target[key].keys():
Expand Down
5 changes: 2 additions & 3 deletions circus/consumer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import errno
import zmq

from circus.util import DEFAULT_ENDPOINT_SUB, get_connection
from circus.py3compat import b
from circus.util import DEFAULT_ENDPOINT_SUB, get_connection, to_bytes


class CircusConsumer(object):
Expand All @@ -15,7 +14,7 @@ def __init__(self, topics, context=None, endpoint=DEFAULT_ENDPOINT_SUB,
self.pubsub_socket = self.context.socket(zmq.SUB)
get_connection(self.pubsub_socket, self.endpoint, ssh_server)
for topic in self.topics:
self.pubsub_socket.setsockopt(zmq.SUBSCRIBE, b(topic))
self.pubsub_socket.setsockopt(zmq.SUBSCRIBE, to_bytes(topic))
self._init_poller()
self.timeout = timeout

Expand Down
11 changes: 3 additions & 8 deletions circus/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
import sys
import traceback
import functools
try:
from queue import Queue, Empty
from urllib.parse import urlparse
except ImportError:
from Queue import Queue, Empty # NOQA
from urlparse import urlparse # NOQA
from queue import Queue, Empty # noqa: F401
from urllib.parse import urlparse


import zmq
Expand All @@ -22,7 +18,6 @@
from circus.commands import get_commands, ok, error, errors
from circus import logger
from circus.exc import MessageError, ConflictError
from circus.py3compat import string_types
from circus.sighandler import SysHandler


Expand Down Expand Up @@ -254,7 +249,7 @@ def send_response(self, mid, cid, msg, resp, cast=False):
if cid is None:
return

if isinstance(resp, string_types):
if isinstance(resp, str):
raise DeprecationWarning('Takes only a mapping')

resp['id'] = mid
Expand Down
8 changes: 1 addition & 7 deletions circus/papa_process_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@
import psutil
import select
import time
from circus.py3compat import PY2, string_types

__author__ = 'Scott Maxwell'


if PY2:
class TimeoutError(Exception):
"""The operation timed out."""


def _bools_to_papa_out(pipe, close):
return papa.PIPE if pipe else papa.DEVNULL if close else None

Expand Down Expand Up @@ -61,7 +55,7 @@ def spawn(self):
socket_names = set(socket_name.lower()
for socket_name in self.watcher._get_sockets_fds())
self.cmd = self._fix_socket_name(self.cmd, socket_names)
if isinstance(self.args, string_types):
if isinstance(self.args, str):
self.args = self._fix_socket_name(self.args, socket_names)
else:
self.args = [self._fix_socket_name(arg, socket_names)
Expand Down
7 changes: 3 additions & 4 deletions circus/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@

from circus import logger, __version__
from circus.client import make_message, cast_message
from circus.py3compat import b, s
from circus.util import (debuglog, to_bool, resolve_name, configure_logger,
DEFAULT_ENDPOINT_DEALER, DEFAULT_ENDPOINT_SUB,
get_connection)
get_connection, to_str, to_bytes)


class CircusPlugin(object):
Expand All @@ -40,7 +39,7 @@ def __init__(self, endpoint, pubsub_endpoint, check_delay, ssh_server=None,
self.endpoint = endpoint
self.check_delay = check_delay
self.ssh_server = ssh_server
self._id = b(uuid.uuid4().hex)
self._id = to_bytes(uuid.uuid4().hex)
self.running = False
self.loop = ioloop.IOLoop()

Expand Down Expand Up @@ -151,7 +150,7 @@ def handle_init(self):
@staticmethod
def split_data(data):
topic, msg = data
topic_parts = s(topic).split(".")
topic_parts = to_str(topic).split(".")
return topic_parts[1], topic_parts[2], msg

@staticmethod
Expand Down
24 changes: 12 additions & 12 deletions circus/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from psutil import (Popen, STATUS_ZOMBIE, STATUS_DEAD, NoSuchProcess,
AccessDenied)

from circus.py3compat import bytestring, string_types, quote
from shlex import quote
from circus.sockets import CircusSocket
from circus.util import (get_info, to_uid, to_gid, debuglog, get_working_dir,
ObjectDict, replace_gnu_args, get_default_gid,
Expand Down Expand Up @@ -370,7 +370,7 @@ def format_args(self, sockets_fds=None):
""" It's possible to use environment variables and some other variables
that are available in this context, when spawning the processes.
"""
logger.debug('cmd: ' + bytestring(self.cmd))
logger.debug('cmd: ' + self.cmd)
logger.debug('args: ' + str(self.args))

current_env = ObjectDict(self.env.copy())
Expand Down Expand Up @@ -401,15 +401,15 @@ def format_args(self, sockets_fds=None):
self.cmd = cmd.replace('$WID', str(self.wid))

if self.args is not None:
if isinstance(self.args, string_types):
args = shlex.split(bytestring(replace_gnu_args(
self.args, **format_kwargs)))
if isinstance(self.args, str):
args = shlex.split(replace_gnu_args(
self.args, **format_kwargs))
else:
args = [bytestring(replace_gnu_args(arg, **format_kwargs))
args = [replace_gnu_args(arg, **format_kwargs)
for arg in self.args]
args = shlex.split(bytestring(cmd), posix=not IS_WINDOWS) + args
args = shlex.split(cmd, posix=not IS_WINDOWS) + args
else:
args = shlex.split(bytestring(cmd), posix=not IS_WINDOWS)
args = shlex.split(cmd, posix=not IS_WINDOWS)

if self.shell:
# subprocess.Popen(shell=True) implies that 1st arg is the
Expand All @@ -419,11 +419,11 @@ def format_args(self, sockets_fds=None):
if shell_args and IS_WINDOWS:
logger.warn("shell_args won't apply for "
"windows platforms: %s", shell_args)
elif isinstance(shell_args, string_types):
args += shlex.split(bytestring(replace_gnu_args(
shell_args, **format_kwargs)))
elif isinstance(shell_args, str):
args += shlex.split(replace_gnu_args(
shell_args, **format_kwargs))
elif shell_args:
args += [bytestring(replace_gnu_args(arg, **format_kwargs))
args += [replace_gnu_args(arg, **format_kwargs)
for arg in shell_args]

elif format_kwargs.get('shell_args', False):
Expand Down
Loading

0 comments on commit aa1bca9

Please sign in to comment.