Update evennia game-index client to work with py3.

This commit is contained in:
Griatch 2019-02-01 00:26:36 +01:00
parent fa8c7657da
commit a6ecf494d2
2 changed files with 7 additions and 6 deletions

View file

@ -77,8 +77,8 @@ class EvenniaGameIndexClient(object):
def _form_and_send_request(self): def _form_and_send_request(self):
agent = Agent(reactor, pool=self._conn_pool) agent = Agent(reactor, pool=self._conn_pool)
headers = { headers = {
'User-Agent': ['Evennia Game Index Client'], b'User-Agent': [b'Evennia Game Index Client'],
'Content-Type': ['application/x-www-form-urlencoded'], b'Content-Type': [b'application/x-www-form-urlencoded'],
} }
egi_config = self._get_config_dict() egi_config = self._get_config_dict()
# We are using `or` statements below with dict.get() to avoid sending # We are using `or` statements below with dict.get() to avoid sending
@ -110,7 +110,7 @@ class EvenniaGameIndexClient(object):
data = urllib.parse.urlencode(values) data = urllib.parse.urlencode(values)
d = agent.request( d = agent.request(
'POST', self.report_url, b'POST', bytes(self.report_url, 'utf-8'),
headers=Headers(headers), headers=Headers(headers),
bodyProducer=StringProducer(data)) bodyProducer=StringProducer(data))
@ -144,6 +144,7 @@ class SimpleResponseReceiver(protocol.Protocol):
def connectionLost(self, reason=protocol.connectionDone): def connectionLost(self, reason=protocol.connectionDone):
self.d.callback((self.status_code, self.buf)) self.d.callback((self.status_code, self.buf))
@implementer(IBodyProducer) @implementer(IBodyProducer)
class StringProducer(object): class StringProducer(object):
""" """
@ -151,7 +152,7 @@ class StringProducer(object):
""" """
def __init__(self, body): def __init__(self, body):
self.body = body self.body = bytes(body, 'utf-8')
self.length = len(body) self.length = len(body)
def startProducing(self, consumer): def startProducing(self, consumer):