Skip to content

Commit

Permalink
Set the support level to python 3.6 or above
Browse files Browse the repository at this point in the history
Removes from the server support for python 3.2 and below
Sets the suggested python version to 3.6 or above
  • Loading branch information
jacomago committed May 22, 2024
1 parent 4bbf2cb commit f9f0c47
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 33 deletions.
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

0 comments on commit f9f0c47

Please sign in to comment.