3laba/run_all.py
2026-05-08 11:23:10 +03:00

56 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# run_all.py - универсальный запуск для PyCharm
import subprocess
import sys
import time
import os
def run_script(script_name):
"""Запуск Python скрипта"""
print(f"\n{'=' * 50}")
print(f"Запуск {script_name}")
print(f"{'=' * 50}")
result = subprocess.run([sys.executable, script_name])
return result.returncode
def main():
print("🚀 Запуск всех скриптов лабораторной работы")
print(f"Python: {sys.executable}")
scripts = [
('tcp_server.py', False), # Сервер запускаем в фоне?
('tcp_client.py', True),
('udp_server.py', False),
('udp_client.py', True),
('http_socket_client.py', True),
('http_requests_client.py', True),
('gitea_api_client.py', True),
]
# Запускаем серверы
servers = []
for script, is_client in scripts:
if not is_client:
print(f"\nЗапуск сервера: {script}")
proc = subprocess.Popen([sys.executable, script])
servers.append(proc)
time.sleep(1) # Даем серверу время на запуск
# Запускаем клиенты
for script, is_client in scripts:
if is_client:
time.sleep(0.5)
run_script(script)
# Завершаем серверы
for proc in servers:
proc.terminate()
print(f"Сервер остановлен")
print("\nВсе тесты завершены!")
if __name__ == '__main__':
main()