Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sets the support level to python 3.6 or above #88

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RecCeiver Usage

The RecCeiver server in the `server/` directory is a
Python script using the [Twisted][twisted] networking
library. It requires Python 2.7 and Twisted >= 12.0.
library. It requires Python 3.6 or above and Twisted >= 12.0.

[twisted]: http://twistedmatrix.com/

Expand Down
18 changes: 5 additions & 13 deletions server/recceiver/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ class Log2Twisted(logging.StreamHandler):
def __init__(self):
super(Log2Twisted,self).__init__(stream=self)
# The Twisted log publisher adds a newline, so strip the newline added by the Python log handler.
if sys.version_info < (3,2):
self.write = lambda *args, **kwargs: log.msg(*[ str(a).strip() for a in args ], **kwargs)
else:
self.terminator = "" # the 'terminator' attribute was added to StreamHandler in Python v3.2
self.write = log.msg
self.terminator = ""
self.write = log.msg
def flush(self):
pass

Expand Down Expand Up @@ -137,14 +134,9 @@ def makeService(self, opts):

lvlname = conf.get('loglevel', 'WARN')
lvl = logging.getLevelName(lvlname)
if sys.version_info[0] < 3:
if not isinstance(lvl, (int, long)):
print("Invalid loglevel", lvlname)
lvl = logging.WARN
else:
if not isinstance(lvl, (int, )):
print("Invalid loglevel", lvlname)
lvl = logging.WARN
if not isinstance(lvl, (int, )):
print("Invalid loglevel", lvlname)
lvl = logging.WARN

fmt = conf.get('logformat', "%(levelname)s:%(name)s %(message)s")

Expand Down
14 changes: 3 additions & 11 deletions server/recceiver/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@
from zope.interface import implementer
from zope.interface import provider

if sys.version_info[0] < 3:
import ConfigParser
from ConfigParser import SafeConfigParser as Parser
else:
from configparser import ConfigParser as Parser
import configparser as ConfigParser
from configparser import ConfigParser as Parser
import configparser as ConfigParser

from os.path import expanduser

Expand Down Expand Up @@ -67,11 +63,7 @@ def __init__(self, cfile=None):
read = parser.read(map(expanduser, self.paths))

if cfile:
# read_file replaced readfp in python 3.2
if sys.version_info[0] == 3 and sys.version_info[1] > 1:
parser.read_file(open(cfile,'r'))
else:
parser.readfp(open(cfile,'r'))
parser.read_file(open(cfile,'r'))

if not cfile and len(read)==0:
# no user configuration given so load some defaults
Expand Down
10 changes: 2 additions & 8 deletions server/recceiver/recast.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
_log = Logger(__name__)

import sys, time
if sys.version_info[0] < 3:
PYTHON3 = False
else:
PYTHON3 = True

from zope.interface import implementer

Expand Down Expand Up @@ -148,8 +144,7 @@ def recvPong(self, body):
def recvInfo(self, body):
rid, klen, vlen = _c_info.unpack(body[:_c_info.size])
text = body[_c_info.size:]
if PYTHON3:
text = text.decode()
text = text.decode()
if klen==0 or klen+vlen < len(text):
_log.error('Ignoring info update')
return self.getInitialState()
Expand All @@ -165,8 +160,7 @@ def recvInfo(self, body):
def recvAddRec(self, body):
rid, rtype, rtlen, rnlen = _c_rec.unpack(body[:_c_rec.size])
text = body[_c_rec.size:]
if PYTHON3:
text = text.decode()
text = text.decode()
if rnlen==0 or rtlen+rnlen<len(text):
_log.error('Ignoring record update')

Expand Down
Loading