Skip to content

Commit

Permalink
drop python2 support, fix bug in parent_is_inet
Browse files Browse the repository at this point in the history
  • Loading branch information
schlitzered committed Feb 28, 2024
1 parent de392a5 commit df066b9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
25 changes: 9 additions & 16 deletions pep3143daemon/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand Down
6 changes: 1 addition & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_PidFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit df066b9

Please sign in to comment.