diff --git a/pep3143daemon/daemon.py b/pep3143daemon/daemon.py index 8ecf4c5..74a50a2 100644 --- a/pep3143daemon/daemon.py +++ b/pep3143daemon/daemon.py @@ -10,13 +10,6 @@ import socket import sys -# PY2 / PY3 gap -PY3 = sys.version_info[0] == 3 -if PY3: - string_types = str, -else: - string_types = basestring, - class DaemonError(Exception): """ Exception raised by DaemonContext""" @@ -154,7 +147,7 @@ def _get_signal_handler(self, handler): """ if not handler: result = signal.SIG_IGN - elif isinstance(handler, string_types): + elif isinstance(handler, str): result = getattr(self, handler) else: result = handler @@ -374,18 +367,18 @@ def parent_is_inet(): :return: bool """ - result = False - sock = socket.fromfd( - sys.__stdin__.fileno(), - socket.AF_INET, - socket.SOCK_RAW) try: + sock = socket.fromfd( + sys.__stdin__.fileno(), + socket.AF_INET, + socket.SOCK_RAW + ) sock.getsockopt(socket.SOL_SOCKET, socket.SO_TYPE) - result = True + return True except (OSError, socket.error) as err: if not err.args[0] == errno.ENOTSOCK: - result = True - return result + return True + return False def detach_required(): diff --git a/setup.py b/setup.py index 91a2a05..61298ac 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name='pep3143daemon', - version='0.0.6', + version='0.1.0', description='Implementation of PEP 3143, a unix daemon', long_description=pep3143daemon.__doc__, packages=['pep3143daemon'], @@ -19,11 +19,7 @@ 'License :: OSI Approved :: MIT License', 'Operating System :: POSIX', 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4' ], keywords=[ 'daemon', diff --git a/test/unit/test_PidFile.py b/test/unit/test_PidFile.py index ee53ecb..1c43d30 100644 --- a/test/unit/test_PidFile.py +++ b/test/unit/test_PidFile.py @@ -36,7 +36,7 @@ def test_acquire(self): self.open_mock.assert_called_with('test.pid', 'a') self.assertEqual(self.mockpidfile._pidfile, 'test.pid') - self.fcntl_mock.flock.asert_called_with( + self.fcntl_mock.flock.assert_called_with( self.mockpidfile.pidfile.fileno(), self.fcntl_mock.LOCK_EX | self.fcntl_mock.LOCK_NB)