mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
ruff format
This commit is contained in:
@@ -8,8 +8,8 @@ from argenta.orchestrator.argparser import ArgParser
|
||||
from argenta.orchestrator.argparser.arguments import BooleanArgument
|
||||
|
||||
|
||||
arg_parser = ArgParser(processed_args=[BooleanArgument('repeat')])
|
||||
app: App = App(autocompleter=AutoCompleter('.hist'))
|
||||
arg_parser = ArgParser(processed_args=[BooleanArgument("repeat")])
|
||||
app: App = App(autocompleter=AutoCompleter(".hist"))
|
||||
orchestrator: Orchestrator = Orchestrator()
|
||||
|
||||
|
||||
@@ -22,5 +22,6 @@ def main():
|
||||
|
||||
orchestrator.start_polling(app)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
+11
-2
@@ -14,12 +14,14 @@ import socket
|
||||
# Маршрутизатор для работы с файлами
|
||||
file_router = Router("Файловые операции")
|
||||
|
||||
|
||||
@file_router.command(Command("list", "Список файлов"))
|
||||
def list_files(response: Response):
|
||||
files = os.listdir()
|
||||
for file in files:
|
||||
print(file)
|
||||
|
||||
|
||||
@file_router.command(Command("size", "Размер файла"))
|
||||
def file_size(response: Response):
|
||||
file_name = input("Введите имя файла: ")
|
||||
@@ -29,9 +31,11 @@ def file_size(response: Response):
|
||||
else:
|
||||
print(f"Файл {file_name} не найден")
|
||||
|
||||
|
||||
# Маршрутизатор для системных операций
|
||||
system_router = Router("Системные операции")
|
||||
|
||||
|
||||
@system_router.command(Command("info", "Информация о системе"))
|
||||
def system_info(response: Response):
|
||||
print(f"Система: {platform.system()}")
|
||||
@@ -39,6 +43,7 @@ def system_info(response: Response):
|
||||
print(f"Архитектура: {platform.architecture()}")
|
||||
print(f"Процессор: {platform.processor()}")
|
||||
|
||||
|
||||
@system_router.command(Command("memory", "Информация о памяти"))
|
||||
def memory_info(response: Response):
|
||||
memory = psutil.virtual_memory()
|
||||
@@ -46,27 +51,31 @@ def memory_info(response: Response):
|
||||
print(f"Доступно: {memory.available / (1024**3):.2f} ГБ")
|
||||
print(f"Использовано: {memory.used / (1024**3):.2f} ГБ ({memory.percent}%)")
|
||||
|
||||
|
||||
# Маршрутизатор для сетевых операций
|
||||
network_router = Router("Сетевые операции")
|
||||
|
||||
|
||||
@network_router.command(Command("ping", "Проверка доступности хоста"))
|
||||
def ping_host(response: Response):
|
||||
host = input("Введите имя хоста: ")
|
||||
print(f"Пингую {host}...")
|
||||
subprocess.run(["ping", "-c", "4", host])
|
||||
|
||||
|
||||
@network_router.command(Command("ip", "Показать IP-адреса"))
|
||||
def show_ip(response: Response):
|
||||
hostname = socket.gethostname()
|
||||
print(f"Имя хоста: {hostname}")
|
||||
print(f"IP-адрес: {socket.gethostbyname(hostname)}")
|
||||
|
||||
|
||||
# Создание приложения и регистрация маршрутизаторов
|
||||
app = App(
|
||||
prompt="System> ",
|
||||
initial_message="Pingator",
|
||||
dividing_line=DynamicDividingLine("*"),
|
||||
autocompleter=AutoCompleter('.hist', 'e'),
|
||||
autocompleter=AutoCompleter(".hist", "e"),
|
||||
)
|
||||
|
||||
# Добавляем все маршрутизаторы
|
||||
@@ -77,4 +86,4 @@ app.add_message_on_startup("Для просмотра доступных ком
|
||||
|
||||
# Запускаем приложение
|
||||
orchestrator = Orchestrator()
|
||||
orchestrator.start_polling(app)
|
||||
orchestrator.start_polling(app)
|
||||
|
||||
@@ -5,6 +5,8 @@ console = Console()
|
||||
|
||||
|
||||
def help_command():
|
||||
console.print("[italic bold]The main functionality of the script is to convert an expression from a string "
|
||||
"to a mathematical one and then calculate this expression. "
|
||||
"Project GitHub: https://github.com/koloideal/WordMath[/italic bold]")
|
||||
console.print(
|
||||
"[italic bold]The main functionality of the script is to convert an expression from a string "
|
||||
"to a mathematical one and then calculate this expression. "
|
||||
"Project GitHub: https://github.com/koloideal/WordMath[/italic bold]"
|
||||
)
|
||||
|
||||
@@ -7,12 +7,19 @@ from argenta.response import Response
|
||||
from argenta.router import Router
|
||||
|
||||
|
||||
work_router: Router = Router(title='Work points:')
|
||||
work_router: Router = Router(title="Work points:")
|
||||
|
||||
console = Console()
|
||||
|
||||
|
||||
@work_router.command(Command('get', 'Get Help', aliases=['help', 'Get_help'], flags=Flags(PredefinedFlags.PORT, PredefinedFlags.HOST)))
|
||||
@work_router.command(
|
||||
Command(
|
||||
"get",
|
||||
"Get Help",
|
||||
aliases=["help", "Get_help"],
|
||||
flags=Flags(PredefinedFlags.PORT, PredefinedFlags.HOST),
|
||||
)
|
||||
)
|
||||
def command_help(response: Response):
|
||||
print(response.status)
|
||||
print(response.undefined_flags.get_flags())
|
||||
@@ -20,12 +27,9 @@ def command_help(response: Response):
|
||||
print(response.invalid_value_flags.get_flags())
|
||||
|
||||
|
||||
@work_router.command('run')
|
||||
@work_router.command("run")
|
||||
def command_start_solving(response: Response):
|
||||
print(response.status)
|
||||
print(response.undefined_flags.get_flags())
|
||||
print(response.valid_flags.get_flags())
|
||||
print(response.invalid_value_flags.get_flags())
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,10 +9,12 @@ from argenta.orchestrator.argparser import ArgParser
|
||||
from argenta.orchestrator.argparser.arguments import BooleanArgument
|
||||
|
||||
|
||||
arg_parser = ArgParser(processed_args=[BooleanArgument('repeat')])
|
||||
app: App = App(dividing_line=DynamicDividingLine(),
|
||||
autocompleter=AutoCompleter(),
|
||||
repeat_command_groups=False,)
|
||||
arg_parser = ArgParser(processed_args=[BooleanArgument("repeat")])
|
||||
app: App = App(
|
||||
dividing_line=DynamicDividingLine(),
|
||||
autocompleter=AutoCompleter(),
|
||||
repeat_command_groups=False,
|
||||
)
|
||||
orchestrator: Orchestrator = Orchestrator(arg_parser)
|
||||
|
||||
|
||||
@@ -25,5 +27,6 @@ def main():
|
||||
|
||||
orchestrator.start_polling(app)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user