Skip to content

Commit

Permalink
fixes for docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Floskinner committed May 20, 2023
1 parent b64374a commit eb46022
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- run: pip install pdoc
# ADJUST THIS: build your documentation into docs/.
# We use a custom build script for pdoc itself, ideally you just run `pdoc -o docs/ ...` here.
- run: pdoc -o ./docs/ src/client.py src/server.py src/services.py src/transport_message.py
- run: pdoc -o ./docs/ src/client.py src/server.py src/transport_message.py

- uses: actions/upload-pages-artifact@v1
with:
Expand Down
17 changes: 11 additions & 6 deletions src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
import logging
import time
import functools
from argparse import ArgumentParser
from datetime import datetime
from threading import Lock, Thread
Expand Down Expand Up @@ -61,16 +62,18 @@ def _check_data_none_decorator(func):
"""Decorator for checking if data is None.
If data is None, the client will receive an error message.
"""

async def wrapper(self, sid, data=None):
@functools.wraps(func)
async def wrapper(self, *args, **kwargs):
sid = args[0]
data = args[1] if len(args) > 1 else None
if data is None:
response = TransportMessage(
timestamp=int(time.time()), payload="Missing payload of type TransportMessage."
)
await self.sio.emit("PRINT_MESSAGE_AND_EXIT", response.json(), room=sid)
logging.error(response.payload)
return None
return await func(self, sid, data)
return await func(self, *args, **kwargs)

return wrapper

Expand All @@ -79,8 +82,10 @@ def _check_topic_decorator(func):
"""Decorator for checking if topic exists.
If topic does not exist, the client will receive an error message.
"""

async def wrapper(self, sid, data):
@functools.wraps(func)
async def wrapper(self, *args, **kwargs):
sid = args[0]
data = args[1] if len(args) > 1 else None
try:
parsed_data = TransportMessage.parse_raw(data)
except Exception:
Expand All @@ -95,7 +100,7 @@ async def wrapper(self, sid, data):
await self.sio.emit("PRINT_MESSAGE_AND_EXIT", response.json(), room=sid)
logging.error(response.payload)
return None
return await func(self, sid, data)
return await func(self, *args, **kwargs)

return wrapper

Expand Down
10 changes: 0 additions & 10 deletions src/services.py

This file was deleted.

0 comments on commit eb46022

Please sign in to comment.