Terra-Dash/main.py

43 lines
1.1 KiB
Python
Raw Normal View History

2024-09-16 21:01:46 +02:00
<<<<<<< HEAD
2024-09-16 13:05:26 +02:00
#!/usr/bin/python3
2024-09-16 21:01:46 +02:00
=======
#!/usr/bi/python3
>>>>>>> 079d2a0 (terminal intigration)
2024-09-13 15:07:56 +02:00
import libtmux
import settings
2024-09-13 15:07:56 +02:00
import libtmux.constants
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()
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
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")
launchserver(rpane)
2024-09-13 15:07:56 +02:00
lpane.send_keys("python3 app.py")
2024-09-13 15:07:56 +02:00
server.attach_session("terradash")
except Exception as e:
print(f"Error: {e}")