Move Python scripts to src/ folder

main
Bram van den Heuvel 2023-10-01 16:33:10 +02:00
parent 94155b34a1
commit 5d86b17a01
4 changed files with 293 additions and 275 deletions

View File

@ -1,11 +1,18 @@
"""
The mc_wrapper modules handles the process that runs the Minecraft server.
The server is run in a subprocess, and live communication between the
game and the Python script is facilitated.
"""
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from typing import Union from typing import Union
import asyncio import asyncio
import json import json
import re import re
from nbsr import NonBlockingStreamReader as NBSR from src.nbsr import NonBlockingStreamReader as NBSR
import config import config
import build_server as build import src.build_server as build
# Write the appropriate files # Write the appropriate files
build.write_eula() build.write_eula()

View File

@ -3,10 +3,9 @@ import time
import re import re
from nio import AsyncClient, MatrixRoom, RoomMessageText from nio import AsyncClient, MatrixRoom, RoomMessageText
import mc_wrapper import src.mc_wrapper as mc_wrapper
import config import config
import build_server
STARTUP_TIME = time.time() STARTUP_TIME = time.time()

View File

@ -1,3 +1,15 @@
"""
The NBSR module defines a Non-blocking stream reader (NBSR class).
In short, the Minecraft stdout is a stream of data that doesn't end until
the server shuts down. Traditionally, Python would not run any code until
the server has shut down and returns its entire output.
The NBSR class allows us to read from the stream without blocking the entire
Python script. We will occasionally ask the NBSR for any updates, and it
will give us the latest output, if it exists.
"""
from threading import Thread from threading import Thread
from queue import Queue, Empty from queue import Queue, Empty