Skip to content

Commit

Permalink
v1.3-2 完善根目录模式
Browse files Browse the repository at this point in the history
  • Loading branch information
Hikari16665 committed Jul 1, 2024
1 parent 453a198 commit 3bf51bc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ async def setting(self):
index = await promptSelect(OPTIONS_SETTINGS, '设置:')
if index == 0:
self.config.debug = await promptConfirm('开启调试模式?')
self.config.save_config()
if index == 1:
self.config.direct_mode = await promptConfirm('开启根目录模式?安装服务器将直接安装在当前目录下。')
elif index == len(OPTIONS_SETTINGS) - 1:
return
self.config.save_config()
async def mainMenu(self):
console.clear()
console.rule(f'{HSL_NAME} v{str(self.version/10)}')
Expand Down
25 changes: 15 additions & 10 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,24 @@ def run(self):
console.log(f'Run Command: {run_command}')

workdir = self.path
if self.config.direct_mode:
workdir = ''

output_queue = Queue()
input_queue = Queue()

process = subprocess.Popen(
run_command.split(" "),
cwd=workdir,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
if self.config.direct_mode:
process = subprocess.Popen(
run_command.split(" "),
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
else:
process = subprocess.Popen(
run_command.split(" "),
cwd=workdir,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)


t2 = Thread(target=self.input, args=(process, input_queue))
Expand Down
10 changes: 7 additions & 3 deletions workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ def load(self):
self.workspaces = json.load(f)
async def create(self, *, server_name: str):
serverPath = os.path.join(self.path,server_name)
if not os.path.exists(serverPath):
os.makedirs(serverPath)
with open(os.path.join(serverPath,"eula.txt"), 'w') as f:
if self.config.direct_mode:
with open('eula.txt', 'w') as f:
f.write("eula=true")
else:
if not os.path.exists(serverPath):
os.makedirs(serverPath)
with open(os.path.join(serverPath,'eula.txt'), 'w') as f:
f.write('eula=true')
return serverPath
async def add(self, Server: Server):
self.workspaces.append({
Expand Down

0 comments on commit 3bf51bc

Please sign in to comment.