mirror of
https://github.com/onyx-and-iris/q3rcon-cli.git
synced 2026-04-13 04:23:38 +00:00
updates to the Console classes:
- added ErrConsole - import console as namespace throughout the package - swap out the static methods for instance methods. Wrap the entry point in try/except. Note, catching IncorrectPasswordError is currently not working. See https://github.com/Iapetus-11/aio-q3-rcon/issues/4
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import clypi
|
||||
from aioq3rcon import Client
|
||||
from aioq3rcon import Client, IncorrectPasswordError
|
||||
from clypi import Command, arg
|
||||
from typing_extensions import override
|
||||
|
||||
from . import console
|
||||
from .commands import (
|
||||
Fastrestart,
|
||||
Gametype,
|
||||
@@ -14,7 +15,6 @@ from .commands import (
|
||||
Plugins,
|
||||
Status,
|
||||
)
|
||||
from .console import Console
|
||||
|
||||
Subcommands = (
|
||||
Fastrestart
|
||||
@@ -96,16 +96,20 @@ class Q3rconCli(Command):
|
||||
) as client:
|
||||
try:
|
||||
if response := await client.send_command(command):
|
||||
Console.print_response(response)
|
||||
console.out.print_response(response)
|
||||
except TimeoutError:
|
||||
print(
|
||||
clypi.style(
|
||||
'Timeout waiting for response for command:', fg='red'
|
||||
),
|
||||
clypi.style(command, fg='yellow'),
|
||||
console.err.print(
|
||||
f"Timeout waiting for response for command: '{command}'"
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
cli = Q3rconCli().parse()
|
||||
cli.start()
|
||||
try:
|
||||
cli = Q3rconCli().parse()
|
||||
cli.start()
|
||||
except IncorrectPasswordError:
|
||||
console.err.print('Incorrect password provided.')
|
||||
except TimeoutError:
|
||||
console.err.print(
|
||||
f"Timeout waiting for response for command: '{type(cli.subcommand).__name__.lower()}'"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user