Skip to content

Commit

Permalink
Improved command-line utility
Browse files Browse the repository at this point in the history
  • Loading branch information
BattlefieldDuck committed Feb 24, 2024
1 parent 89ea90c commit 9197b0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions opengsq/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import argparse
import asyncio
import inspect
Expand Down Expand Up @@ -32,7 +34,9 @@ def register(self, parser: argparse.ArgumentParser):

# Load all protocols from __init__.py
with open(os.path.join(opengsq_path, "protocols", "__init__.py")) as f:
for protocol_path, protocol_classnames in re.findall(pattern, f.read()):
matches: list[str, str] = re.findall(pattern, f.read())

for protocol_path, protocol_classnames in matches:
for protocol_classname in protocol_classnames.split(","):
name, fullpath, parameters = self.__extract(
protocol_path, protocol_classname
Expand Down Expand Up @@ -130,9 +134,7 @@ def __add_arguments(


def main():
loop = asyncio.get_event_loop()
loop.run_until_complete(main_async())
loop.close()
asyncio.run(main_async())


async def main_async():
Expand All @@ -152,6 +154,9 @@ async def main_async():
except asyncio.exceptions.TimeoutError:
sys.stderr.write("opengsq: error: timed out\n")
sys.exit(-2)
except asyncio.exceptions.CancelledError:
sys.stderr.write("opengsq: error: cancelled\n")
sys.exit(-3)

sys.exit(0)

Expand Down
2 changes: 1 addition & 1 deletion opengsq/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.1.0'
__version__ = '3.1.1'

0 comments on commit 9197b0c

Please sign in to comment.