Properly miss when the web api returns 404

main
kaiyou 6 years ago committed by Alexander Graf
parent d2b98ae323
commit 814bb1f36d
No known key found for this signature in database
GPG Key ID: B8A9DC143E075629

@ -81,11 +81,10 @@ class DictProtocol(asyncio.Protocol):
logging.debug("Looking up {}".format(key))
# Priv and shared keys are handled slighlty differently
key_type, key = key.decode("utf8").split("/", 1)
try:
result = await self.dict.get(
key, ns=(self.user if key_type == "priv" else None)
)
# Handle various response types
if result is not None:
if type(result) is str:
response = result.encode("utf8")
elif type(result) is bytes:
@ -93,7 +92,7 @@ class DictProtocol(asyncio.Protocol):
else:
response = json.dumps(result).encode("ascii")
return self.reply(b"O", response)
else:
except KeyError:
return self.reply(b"N")
def process_begin(self, transaction_id):

@ -58,6 +58,7 @@ class NetstringProtocol(asyncio.Protocol):
def send_string(self, string):
""" Send a netstring
"""
logging.debug("Replying {}".format(string))
self.transport.write(str(len(string)).encode('ascii'))
self.transport.write(b':')
self.transport.write(string)
@ -85,6 +86,7 @@ class SocketmapProtocol(NetstringProtocol):
def string_received(self, string):
# The postfix format contains a space for separating the map name and
# the key
logging.debug("Received {}".format(string))
space = string.find(0x20)
if space != -1:
name = string[:space].decode('ascii')

@ -28,6 +28,10 @@ class UrlTable(object):
result = await request.json()
logging.debug("Table get {} is {}".format(key, result))
return result
elif request.status == 404:
raise KeyError()
else:
raise Exception(request.status)
async def set(self, key, value, ns=None):
""" Set a value for the given key in the provided namespace

@ -7,7 +7,7 @@ with open("README.md", "r") as fh:
setup(
name="podop",
version="0.2.2",
version="0.2.3",
description="Postfix and Dovecot proxy",
long_description=long_description,
long_description_content_type="text/markdown",

Loading…
Cancel
Save