Skip to content

Commit

Permalink
Fix TODO's
Browse files Browse the repository at this point in the history
  • Loading branch information
Moosems committed Jul 29, 2024
1 parent 03b4272 commit ab28d03
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
21 changes: 4 additions & 17 deletions collegamento/simple_client_server/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class SimpleClient:
- SimpleClient.notify_server()
- SimpleClient.request()
- SimpleClient.add_command()
- SimpleClient.cancel_request()
- SimpleClient.kill_IPC()
"""

Expand Down Expand Up @@ -107,9 +106,10 @@ def request(
"""Sends the main_server a request of type command with given kwargs - external API"""
self.logger.debug("Beginning request")

# TODO: Should this just be a walrus operator? "(command := request_dict["command"])"
command: str = request_details["command"]
if command not in self.commands:
# NOTE: this variable could've been a standalone line but I thought it would just be better
# to use the walrus operator. No point in a language feature if its never used. Plus,
# it also looks quite nice :D
if (command := request_details["command"]) not in self.commands:
self.logger.exception(
f"Command {command} not in builtin commands. Those are {self.commands}!"
)
Expand All @@ -133,19 +133,6 @@ def request(
self.requests_queue.put(final_request)
self.logger.info("Message sent")

def cancel_request(self, command: str) -> None:
"""Cancels a request of type command - external API"""
if command not in self.commands:
self.logger.exception(
f"Cannot cancel command {command}, valid commands are {self.commands}"
)
raise CollegamentoError(
f"Cannot cancel command {command}, valid commands are {self.commands}"
)

self.logger.info(f"Cancelled command: {command}")
self.current_ids[command] = 0

def parse_response(self, res: Response) -> None:
"""Parses main_server output line and discards useless responses - internal API"""
self.logger.debug("Parsing server response")
Expand Down
2 changes: 0 additions & 2 deletions docs/source/classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ The ``SimpleClient`` class can do:
- ``SimpleClient.notify_server(notification_dict: dict)`` (as a base class, this has no use case, but it will likely be used by any given subclass)
- ``SimpleClient.request(request_details: dict)`` (all details in request_details are specific to the command in the request_details)
- ``SimpleClient.add_command(name: str, command: USER_FUNCTION)`` (adds the function with the name provided that takes input of ``Request`` and returns anything``
- ``SimpleClient.cancel_request(command: str)`` (will not give output for any requests of type command. When is this ever used? No idea! Why? Because it doesn't actually stop the server from completing it)
TODO: remove this stupid feature. No point in it.
- ``SimpleClient.kill_IPC()`` (kills the IPC server)

.. _FileClient Overview:
Expand Down

0 comments on commit ab28d03

Please sign in to comment.