From 97dd36827ea7373c03bb031179573a7aa26a0c32 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 29 Nov 2019 20:05:10 +0100 Subject: [PATCH] Commands, commands, commands! --- pycharm_templates/command.vm | 13 +++++++++++++ pycharm_templates/event.vm | 10 ++++++++++ royalnet/commands/command.py | 3 +++ royalnet/constellation/constellation.py | 4 ++-- 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 pycharm_templates/command.vm create mode 100644 pycharm_templates/event.vm diff --git a/pycharm_templates/command.vm b/pycharm_templates/command.vm new file mode 100644 index 00000000..c021ec79 --- /dev/null +++ b/pycharm_templates/command.vm @@ -0,0 +1,13 @@ +import royalnet +from royalnet.commands import * + +#set($CAPITALIZED_NAME = $NAME.substring(0,1).toUpperCase() + $NAME.substring(1)) +class ${CAPITALIZED_NAME}Command(Command): + name: str = "$NAME" + + description: str = "" + + syntax: str = "" + + async def run(self, args: CommandArgs, data: CommandData) -> None: + ... diff --git a/pycharm_templates/event.vm b/pycharm_templates/event.vm new file mode 100644 index 00000000..6919d0c4 --- /dev/null +++ b/pycharm_templates/event.vm @@ -0,0 +1,10 @@ +from typing import * +from royalnet.commands import * + + +#set($CAPITALIZED_NAME = $NAME.substring(0,1).toUpperCase() + $NAME.substring(1)) +class ${CAPITALIZED_NAME}Event(Event): + name = "$NAME" + + async def run(self, **kwargs) -> dict: + ... diff --git a/royalnet/commands/command.py b/royalnet/commands/command.py index aaf7065e..e91b0119 100644 --- a/royalnet/commands/command.py +++ b/royalnet/commands/command.py @@ -27,6 +27,9 @@ class Command: def __init__(self, interface: CommandInterface): self.interface = interface + def __str__(self): + return f"[c]{self.interface.prefix}{self.name}[/c]" + @property def serf(self): """A shortcut for :attr:`.interface.serf`.""" diff --git a/royalnet/constellation/constellation.py b/royalnet/constellation/constellation.py index bb0c4de2..61fb40a7 100644 --- a/royalnet/constellation/constellation.py +++ b/royalnet/constellation/constellation.py @@ -269,8 +269,8 @@ class Constellation: log.info(f"Running Constellation on https://{self.address}:{self.port}/...") loop: aio.AbstractEventLoop = aio.get_event_loop() self.running = True - # FIXME: might not work as expected - loop.create_task(self.herald.run()) + # TODO: figure out how to run the correct event loop + # loop.create_task(self.herald.run()) try: uvicorn.run(self.starlette, host=self.address, port=self.port, log_config=UVICORN_LOGGING_CONFIG) finally: