Update evennia game-index client to work with py3.

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

View file

@ -135,7 +135,7 @@ on the main game index page.
Required: No
A longer, full-length description or overview of the game.
A longer, full-length description or overview of the game.
[Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)
and some of the very basic HTML tags are accepted here.
@ -175,7 +175,7 @@ the wild.
### My game doesn't appear on the listing!
If you don't see your game appear on the listing after reloading your server,
If you don't see your game appear on the listing after reloading your server,
check the server logs. You should see some error messages describing what
went wrong.

View file

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