2024-09-16 21:01:46 +02:00
|
|
|
#!/usr/bi/python3
|
2024-09-13 15:07:56 +02:00
|
|
|
import libtmux
|
2024-09-15 20:38:22 +02:00
|
|
|
import settings
|
2024-09-13 15:07:56 +02:00
|
|
|
import libtmux.constants
|
|
|
|
|
2024-09-15 20:38:22 +02:00
|
|
|
|
|
|
|
def launchserver(lpane: libtmux.Pane):
|
|
|
|
lpane.send_keys(settings.RUN_SERVER_COMMAND)
|
|
|
|
lpane.enter()
|
|
|
|
lpane.send_keys(settings.LAUNCH_WORLD)
|
|
|
|
lpane.send_keys(settings.MAX_PLAYERS)
|
|
|
|
lpane.send_keys(settings.PORT)
|
|
|
|
lpane.send_keys(settings.FORWARD_PORT)
|
|
|
|
lpane.send_keys(settings.PASSWORD)
|
|
|
|
|
2024-09-13 15:07:56 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
try:
|
|
|
|
server = libtmux.Server()
|
2024-09-15 20:38:22 +02:00
|
|
|
session = server.new_session("terradash", start_directory=settings.SERVER_PATH)
|
2024-09-13 15:07:56 +02:00
|
|
|
|
|
|
|
window = session.active_window
|
|
|
|
rpane = window.active_pane
|
2024-09-15 20:38:22 +02:00
|
|
|
lpane = window.split(
|
|
|
|
direction=libtmux.constants.PaneDirection.Right,
|
|
|
|
start_directory=settings.path,
|
|
|
|
)
|
2024-09-13 15:07:56 +02:00
|
|
|
|
|
|
|
rpane.send_keys("clear")
|
|
|
|
lpane.send_keys("clear")
|
|
|
|
|
2024-09-15 20:38:22 +02:00
|
|
|
launchserver(rpane)
|
2024-09-13 15:07:56 +02:00
|
|
|
lpane.send_keys("python3 app.py")
|
2024-09-15 20:38:22 +02:00
|
|
|
|
2024-09-13 15:07:56 +02:00
|
|
|
server.attach_session("terradash")
|
|
|
|
|
|
|
|
except Exception as e:
|
2024-09-15 20:38:22 +02:00
|
|
|
print(f"Error: {e}")
|