minecraft-server-creator 2.1.1__tar.gz → 3.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {minecraft_server_creator-2.1.1 → minecraft_server_creator-3.0.0}/LICENSE +2 -2
- minecraft_server_creator-3.0.0/PKG-INFO +86 -0
- minecraft_server_creator-3.0.0/README.md +64 -0
- minecraft_server_creator-3.0.0/pyproject.toml +41 -0
- {minecraft_server_creator-2.1.1 → minecraft_server_creator-3.0.0}/setup.cfg +4 -4
- minecraft_server_creator-3.0.0/src/mcsc_gui/__init__.py +17 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/__main__.py +14 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/_pymcsc_check.py +66 -0
- {minecraft_server_creator-2.1.1/src/mcsc → minecraft_server_creator-3.0.0/src/mcsc_gui}/config/settings.py +33 -45
- minecraft_server_creator-3.0.0/src/mcsc_gui/core/__init__.py +7 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/core/async_bridge.py +162 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/core/logger.py +46 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/core/migration.py +60 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/core/notifier.py +52 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/core/os_utils.py +59 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/core/server_manager.py +327 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/core/shortcuts.py +321 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/core/shutdown.py +58 -0
- {minecraft_server_creator-2.1.1/src/mcsc/modules → minecraft_server_creator-3.0.0/src/mcsc_gui/core}/translations.py +46 -46
- {minecraft_server_creator-2.1.1/src/mcsc/modules → minecraft_server_creator-3.0.0/src/mcsc_gui/core}/user_settings.py +156 -144
- {minecraft_server_creator-2.1.1/src/mcsc → minecraft_server_creator-3.0.0/src/mcsc_gui}/localization/it.py +142 -80
- minecraft_server_creator-3.0.0/src/mcsc_gui/qt_main.py +159 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/static/logo-512.png +0 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/static/logo.ico +0 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/static/logo.png +0 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/static/logo.svg +17 -0
- {minecraft_server_creator-2.1.1/src/mcsc → minecraft_server_creator-3.0.0/src/mcsc_gui}/telemetry.py +110 -97
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/__init__.py +1 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/config_files.py +37 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/config_model.py +192 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/dialogs/__init__.py +1 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/dialogs/app_settings.py +97 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/dialogs/confirm_quit.py +37 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/dialogs/create_server.py +196 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/dialogs/delete_server.py +72 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/dialogs/edit_server.py +79 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/dialogs/fields.py +65 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/dialogs/shortcut.py +76 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/dialogs/update_app.py +52 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/invoke.py +60 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/main_window.py +332 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/navigator.py +168 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/pages/__init__.py +1 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/pages/config_editor.py +245 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/pages/dashboard.py +206 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/pages/server_detail.py +247 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/server_events.py +147 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/single_instance.py +75 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/tasks.py +169 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/theme/__init__.py +5 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/theme/fonts.py +40 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/theme/icons.py +79 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/theme/qss.py +368 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/theme/tokens.py +118 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/usage.py +36 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/widgets/__init__.py +1 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/widgets/card.py +47 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/widgets/common.py +79 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/widgets/console.py +181 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/widgets/empty_state.py +42 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/widgets/overlay_dialog.py +258 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/widgets/ram_slider.py +157 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/widgets/server_card.py +68 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/widgets/sidebar.py +103 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/widgets/sparkline.py +57 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/widgets/spinner.py +57 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/widgets/stat_tile.py +48 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/widgets/status_badge.py +124 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/widgets/title_bar.py +98 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/ui/widgets/toast.py +330 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/update.py +239 -0
- minecraft_server_creator-3.0.0/src/mcsc_gui/updater.py +453 -0
- {minecraft_server_creator-2.1.1/src/mcsc → minecraft_server_creator-3.0.0/src/mcsc_gui}/utils.py +30 -30
- minecraft_server_creator-3.0.0/src/minecraft_server_creator.egg-info/PKG-INFO +86 -0
- minecraft_server_creator-3.0.0/src/minecraft_server_creator.egg-info/SOURCES.txt +85 -0
- minecraft_server_creator-3.0.0/src/minecraft_server_creator.egg-info/entry_points.txt +2 -0
- minecraft_server_creator-3.0.0/src/minecraft_server_creator.egg-info/requires.txt +10 -0
- minecraft_server_creator-3.0.0/src/minecraft_server_creator.egg-info/top_level.txt +1 -0
- minecraft_server_creator-3.0.0/tests/test_async_bridge.py +98 -0
- minecraft_server_creator-3.0.0/tests/test_entrypoints.py +49 -0
- minecraft_server_creator-3.0.0/tests/test_migration.py +80 -0
- minecraft_server_creator-3.0.0/tests/test_os_utils.py +31 -0
- minecraft_server_creator-3.0.0/tests/test_pymcsc_check.py +44 -0
- minecraft_server_creator-3.0.0/tests/test_server_manager.py +231 -0
- minecraft_server_creator-3.0.0/tests/test_shortcuts.py +68 -0
- minecraft_server_creator-3.0.0/tests/test_updater.py +157 -0
- minecraft_server_creator-2.1.1/PKG-INFO +0 -48
- minecraft_server_creator-2.1.1/README.md +0 -29
- minecraft_server_creator-2.1.1/pyproject.toml +0 -22
- minecraft_server_creator-2.1.1/src/mcsc/__init__.py +0 -10
- minecraft_server_creator-2.1.1/src/mcsc/__main__.py +0 -12
- minecraft_server_creator-2.1.1/src/mcsc/config/update_files.py +0 -24
- minecraft_server_creator-2.1.1/src/mcsc/main.py +0 -97
- minecraft_server_creator-2.1.1/src/mcsc/modules/classes.py +0 -115
- minecraft_server_creator-2.1.1/src/mcsc/modules/logger.py +0 -107
- minecraft_server_creator-2.1.1/src/mcsc/modules/pages.py +0 -386
- minecraft_server_creator-2.1.1/src/mcsc/modules/servers/forge.py +0 -151
- minecraft_server_creator-2.1.1/src/mcsc/modules/servers/java.py +0 -13
- minecraft_server_creator-2.1.1/src/mcsc/modules/servers/models.py +0 -438
- minecraft_server_creator-2.1.1/src/mcsc/modules/servers/paper.py +0 -109
- minecraft_server_creator-2.1.1/src/mcsc/modules/servers/utils.py +0 -136
- minecraft_server_creator-2.1.1/src/mcsc/modules/utils.py +0 -738
- minecraft_server_creator-2.1.1/src/mcsc/static/logo.png +0 -0
- minecraft_server_creator-2.1.1/src/mcsc/static/style.css +0 -249
- minecraft_server_creator-2.1.1/src/mcsc/tasks.py +0 -139
- minecraft_server_creator-2.1.1/src/mcsc/update.py +0 -86
- minecraft_server_creator-2.1.1/src/minecraft_server_creator.egg-info/PKG-INFO +0 -48
- minecraft_server_creator-2.1.1/src/minecraft_server_creator.egg-info/SOURCES.txt +0 -33
- minecraft_server_creator-2.1.1/src/minecraft_server_creator.egg-info/entry_points.txt +0 -2
- minecraft_server_creator-2.1.1/src/minecraft_server_creator.egg-info/requires.txt +0 -6
- minecraft_server_creator-2.1.1/src/minecraft_server_creator.egg-info/top_level.txt +0 -1
- minecraft_server_creator-2.1.1/tests/test_entrypoints.py +0 -16
- {minecraft_server_creator-2.1.1 → minecraft_server_creator-3.0.0}/src/minecraft_server_creator.egg-info/dependency_links.txt +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
2
|
-
See https://creativecommons.org/licenses/by-nc-sa/4.0/ for more details.
|
|
1
|
+
This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
2
|
+
See https://creativecommons.org/licenses/by-nc-sa/4.0/ for more details.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: minecraft-server-creator
|
|
3
|
+
Version: 3.0.0
|
|
4
|
+
Summary: Minecraft Server Creator - Manage Minecraft servers
|
|
5
|
+
Author-email: ddavidel <ddavidel@proton.me>
|
|
6
|
+
License: This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
7
|
+
See https://creativecommons.org/licenses/by-nc-sa/4.0/ for more details.
|
|
8
|
+
|
|
9
|
+
Requires-Python: >=3.12
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: requests
|
|
13
|
+
Requires-Dist: appdirs
|
|
14
|
+
Requires-Dist: pymcsc>=0.1.0
|
|
15
|
+
Requires-Dist: PySide6-Essentials>=6.8
|
|
16
|
+
Requires-Dist: qtawesome
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: pytest; extra == "dev"
|
|
19
|
+
Requires-Dist: pytest-qt; extra == "dev"
|
|
20
|
+
Requires-Dist: pytest-asyncio; extra == "dev"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
[](./LICENSE)
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
# MCSC - Minecraft Server Creator
|
|
27
|
+
MCSC is a user-friendly tool written in Python with a GUI that simplifies the process of creating and managing Minecraft servers. Whether you're a beginner or experienced, MCSC allows you to easily set up, run, and control multiple Minecraft servers from a single interface.
|
|
28
|
+
> **Warning**: MCSC is still in development, thus it may not be completely error free.
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
- **Create Multiple Servers**: Set up and manage multiple Minecraft servers from within the app.
|
|
32
|
+
- **Start/Stop Servers**: Easily start and stop your Minecraft servers directly from the GUI.
|
|
33
|
+
- **Console Interaction**: Read the console output in real-time and send commands to the Minecraft server console.
|
|
34
|
+
- **Edit server.properties**: Customize your Minecraft server settings by editing the `server.properties` file with a built-in editor.
|
|
35
|
+
- **User-Friendly GUI**: A simple and intuitive interface designed for both beginners and experienced users.
|
|
36
|
+
- **Manage Server Instances**: Keep track of all your servers in one place.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
### Windows installer (no Python needed)
|
|
40
|
+
Download `mcsc-setup-<version>.exe` from the [latest release](https://github.com/ddavidel/minecraft-server-creator/releases/latest)
|
|
41
|
+
and run it. It installs MCSC with its own private Python, adds it to the Start menu and keeps
|
|
42
|
+
it up to date from the app. No admin rights are needed. Uninstall it from *Settings > Apps*:
|
|
43
|
+
your servers and settings are kept. Java is still required to run Minecraft servers.
|
|
44
|
+
|
|
45
|
+
### From PyPI
|
|
46
|
+
MCSC requires Python 3.12+ and Java.
|
|
47
|
+
|
|
48
|
+
Install it from PyPI and run it:
|
|
49
|
+
```bash
|
|
50
|
+
pip install minecraft-server-creator
|
|
51
|
+
mcsc
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
To run it from the source code:
|
|
55
|
+
1. Clone the repository:
|
|
56
|
+
`git clone https://github.com/ddavidel/minecraft-server-creator.git`
|
|
57
|
+
|
|
58
|
+
2. Navigate to the project folder and install it with its dependencies:
|
|
59
|
+
`pip install -e .`
|
|
60
|
+
|
|
61
|
+
3. Run the application with `mcsc` or `python scripts/start.py` (add `--debug` to log to the console).
|
|
62
|
+
|
|
63
|
+
## Project structure
|
|
64
|
+
- `src/mcsc_gui`: the desktop app (Qt/PySide6 interface, translations, settings, telemetry, updates).
|
|
65
|
+
- Server management (creating, running, monitoring and configuring servers) is provided by the
|
|
66
|
+
[pymcsc](https://pypi.org/project/pymcsc/) library, imported as `mcsc`.
|
|
67
|
+
|
|
68
|
+
## Code signing policy
|
|
69
|
+
Free code signing provided by [SignPath.io](https://about.signpath.io/), certificate by
|
|
70
|
+
[SignPath Foundation](https://signpath.org/).
|
|
71
|
+
|
|
72
|
+
- Committers and reviewers: [repository members](https://github.com/ddavidel/minecraft-server-creator/graphs/contributors)
|
|
73
|
+
- Approvers: [ddavidel](https://github.com/ddavidel)
|
|
74
|
+
|
|
75
|
+
The Windows installer is built from this repository by GitHub Actions
|
|
76
|
+
(`.github/workflows/installer.yml`) and signed only after an approver confirms the release.
|
|
77
|
+
|
|
78
|
+
## Privacy policy
|
|
79
|
+
When it starts, MCSC sends an anonymous usage event to `mcscreator.altervista.org`. The event
|
|
80
|
+
holds a random client ID generated on first run, the event name, a timestamp and the app
|
|
81
|
+
version. It doesn't send personal data, server contents or files. It also checks PyPI for updates and downloads Minecraft server files when you create a
|
|
82
|
+
server. Nothing else is sent to other networked systems unless you ask for it.
|
|
83
|
+
|
|
84
|
+
## Upcoming Features
|
|
85
|
+
- **Support for more server types**: In the future updates, MCSC will support creating and managing many popular Minecraft server types.
|
|
86
|
+
- **Plugin and Mod Manager**: Easily manage plugins and mods.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
[](./LICENSE)
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
# MCSC - Minecraft Server Creator
|
|
5
|
+
MCSC is a user-friendly tool written in Python with a GUI that simplifies the process of creating and managing Minecraft servers. Whether you're a beginner or experienced, MCSC allows you to easily set up, run, and control multiple Minecraft servers from a single interface.
|
|
6
|
+
> **Warning**: MCSC is still in development, thus it may not be completely error free.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
- **Create Multiple Servers**: Set up and manage multiple Minecraft servers from within the app.
|
|
10
|
+
- **Start/Stop Servers**: Easily start and stop your Minecraft servers directly from the GUI.
|
|
11
|
+
- **Console Interaction**: Read the console output in real-time and send commands to the Minecraft server console.
|
|
12
|
+
- **Edit server.properties**: Customize your Minecraft server settings by editing the `server.properties` file with a built-in editor.
|
|
13
|
+
- **User-Friendly GUI**: A simple and intuitive interface designed for both beginners and experienced users.
|
|
14
|
+
- **Manage Server Instances**: Keep track of all your servers in one place.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
### Windows installer (no Python needed)
|
|
18
|
+
Download `mcsc-setup-<version>.exe` from the [latest release](https://github.com/ddavidel/minecraft-server-creator/releases/latest)
|
|
19
|
+
and run it. It installs MCSC with its own private Python, adds it to the Start menu and keeps
|
|
20
|
+
it up to date from the app. No admin rights are needed. Uninstall it from *Settings > Apps*:
|
|
21
|
+
your servers and settings are kept. Java is still required to run Minecraft servers.
|
|
22
|
+
|
|
23
|
+
### From PyPI
|
|
24
|
+
MCSC requires Python 3.12+ and Java.
|
|
25
|
+
|
|
26
|
+
Install it from PyPI and run it:
|
|
27
|
+
```bash
|
|
28
|
+
pip install minecraft-server-creator
|
|
29
|
+
mcsc
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
To run it from the source code:
|
|
33
|
+
1. Clone the repository:
|
|
34
|
+
`git clone https://github.com/ddavidel/minecraft-server-creator.git`
|
|
35
|
+
|
|
36
|
+
2. Navigate to the project folder and install it with its dependencies:
|
|
37
|
+
`pip install -e .`
|
|
38
|
+
|
|
39
|
+
3. Run the application with `mcsc` or `python scripts/start.py` (add `--debug` to log to the console).
|
|
40
|
+
|
|
41
|
+
## Project structure
|
|
42
|
+
- `src/mcsc_gui`: the desktop app (Qt/PySide6 interface, translations, settings, telemetry, updates).
|
|
43
|
+
- Server management (creating, running, monitoring and configuring servers) is provided by the
|
|
44
|
+
[pymcsc](https://pypi.org/project/pymcsc/) library, imported as `mcsc`.
|
|
45
|
+
|
|
46
|
+
## Code signing policy
|
|
47
|
+
Free code signing provided by [SignPath.io](https://about.signpath.io/), certificate by
|
|
48
|
+
[SignPath Foundation](https://signpath.org/).
|
|
49
|
+
|
|
50
|
+
- Committers and reviewers: [repository members](https://github.com/ddavidel/minecraft-server-creator/graphs/contributors)
|
|
51
|
+
- Approvers: [ddavidel](https://github.com/ddavidel)
|
|
52
|
+
|
|
53
|
+
The Windows installer is built from this repository by GitHub Actions
|
|
54
|
+
(`.github/workflows/installer.yml`) and signed only after an approver confirms the release.
|
|
55
|
+
|
|
56
|
+
## Privacy policy
|
|
57
|
+
When it starts, MCSC sends an anonymous usage event to `mcscreator.altervista.org`. The event
|
|
58
|
+
holds a random client ID generated on first run, the event name, a timestamp and the app
|
|
59
|
+
version. It doesn't send personal data, server contents or files. It also checks PyPI for updates and downloads Minecraft server files when you create a
|
|
60
|
+
server. Nothing else is sent to other networked systems unless you ask for it.
|
|
61
|
+
|
|
62
|
+
## Upcoming Features
|
|
63
|
+
- **Support for more server types**: In the future updates, MCSC will support creating and managing many popular Minecraft server types.
|
|
64
|
+
- **Plugin and Mod Manager**: Easily manage plugins and mods.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "minecraft-server-creator"
|
|
7
|
+
version = "3.0.0"
|
|
8
|
+
description = "Minecraft Server Creator - Manage Minecraft servers"
|
|
9
|
+
authors = [{ name = "ddavidel", email = "ddavidel@proton.me" }]
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
license = { file = "LICENSE" }
|
|
12
|
+
dependencies = [
|
|
13
|
+
"requests",
|
|
14
|
+
"appdirs",
|
|
15
|
+
"pymcsc>=0.1.0", # server management, imported as `mcsc`
|
|
16
|
+
"PySide6-Essentials>=6.8",
|
|
17
|
+
"qtawesome",
|
|
18
|
+
]
|
|
19
|
+
requires-python = ">=3.12"
|
|
20
|
+
|
|
21
|
+
[project.optional-dependencies]
|
|
22
|
+
dev = [
|
|
23
|
+
"pytest",
|
|
24
|
+
"pytest-qt",
|
|
25
|
+
"pytest-asyncio",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[tool.setuptools]
|
|
29
|
+
package-dir = { "" = "src" }
|
|
30
|
+
|
|
31
|
+
[project.scripts]
|
|
32
|
+
mcsc = "mcsc_gui.__main__:main"
|
|
33
|
+
|
|
34
|
+
[tool.setuptools.package-data]
|
|
35
|
+
"mcsc_gui" = ["static/*", "static/**/*"]
|
|
36
|
+
|
|
37
|
+
[tool.pytest.ini_options]
|
|
38
|
+
testpaths = ["tests"]
|
|
39
|
+
qt_api = "pyside6"
|
|
40
|
+
asyncio_mode = "auto"
|
|
41
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[egg_info]
|
|
2
|
-
tag_build =
|
|
3
|
-
tag_date = 0
|
|
4
|
-
|
|
1
|
+
[egg_info]
|
|
2
|
+
tag_build =
|
|
3
|
+
tag_date = 0
|
|
4
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Public package interface for the Minecraft Server Creator."""
|
|
2
|
+
|
|
3
|
+
from ._pymcsc_check import ensure_pymcsc
|
|
4
|
+
|
|
5
|
+
# Must run before anything imports the pymcsc library (``mcsc``): see _pymcsc_check
|
|
6
|
+
ensure_pymcsc()
|
|
7
|
+
|
|
8
|
+
__all__ = ["main"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def main() -> int:
|
|
12
|
+
"""Application entry point used by the package CLI (``mcsc``)."""
|
|
13
|
+
# Imported lazily so that importing a subpackage (e.g. ``mcsc_gui.core``)
|
|
14
|
+
# doesn't load Qt.
|
|
15
|
+
from .qt_main import main as qt_main # pylint: disable=import-outside-toplevel
|
|
16
|
+
|
|
17
|
+
return qt_main()
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Module entry point for the project CLI (``mcsc`` / ``python -m mcsc_gui``)."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def main() -> None:
|
|
7
|
+
"""Run the Qt desktop app."""
|
|
8
|
+
from .qt_main import main as qt_main # pylint: disable=import-outside-toplevel
|
|
9
|
+
|
|
10
|
+
sys.exit(qt_main())
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
if __name__ == "__main__":
|
|
14
|
+
main()
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Repair the pymcsc library after an upgrade from MCSC 2.x.
|
|
3
|
+
|
|
4
|
+
MCSC 2.x installed the app itself as the ``mcsc`` package, the same name pymcsc
|
|
5
|
+
uses. When pip upgrades from 2.x it installs pymcsc first and then uninstalls
|
|
6
|
+
the old app, deleting ``mcsc/__init__.py``, which by then belongs to pymcsc.
|
|
7
|
+
``mcsc`` is then left as a broken namespace package. This module detects that
|
|
8
|
+
and reinstalls pymcsc before anything imports it.
|
|
9
|
+
|
|
10
|
+
Runs before logging is configured, so it reports on stderr.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import importlib
|
|
16
|
+
import importlib.metadata
|
|
17
|
+
import subprocess
|
|
18
|
+
import sys
|
|
19
|
+
|
|
20
|
+
REPAIR_HINT = "pip install --force-reinstall --no-deps pymcsc"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def pymcsc_available() -> bool:
|
|
24
|
+
"""True if ``mcsc`` is the working pymcsc library."""
|
|
25
|
+
try:
|
|
26
|
+
from mcsc import ServerManager # pylint: disable=import-outside-toplevel,unused-import
|
|
27
|
+
except ImportError:
|
|
28
|
+
return False
|
|
29
|
+
return True
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _forget_mcsc_modules() -> None:
|
|
33
|
+
"""Drop the half-imported ``mcsc`` modules, so the next import reads the repaired files."""
|
|
34
|
+
for name in [n for n in sys.modules if n == "mcsc" or n.startswith("mcsc.")]:
|
|
35
|
+
del sys.modules[name]
|
|
36
|
+
importlib.invalidate_caches()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _requirement() -> str:
|
|
40
|
+
"""The installed pymcsc version (still listed by pip even when its files are broken)."""
|
|
41
|
+
try:
|
|
42
|
+
return f"pymcsc=={importlib.metadata.version('pymcsc')}"
|
|
43
|
+
except importlib.metadata.PackageNotFoundError:
|
|
44
|
+
return "pymcsc"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def ensure_pymcsc() -> None:
|
|
48
|
+
"""Make sure pymcsc can be imported, reinstalling it once if it's broken."""
|
|
49
|
+
if pymcsc_available():
|
|
50
|
+
return
|
|
51
|
+
|
|
52
|
+
requirement = _requirement()
|
|
53
|
+
print(f"MCSC: the pymcsc library is damaged, reinstalling {requirement}...", file=sys.stderr)
|
|
54
|
+
try:
|
|
55
|
+
subprocess.check_call(
|
|
56
|
+
[sys.executable, "-m", "pip", "install", "--force-reinstall", "--no-deps", requirement]
|
|
57
|
+
)
|
|
58
|
+
except (OSError, subprocess.CalledProcessError) as e:
|
|
59
|
+
raise RuntimeError(
|
|
60
|
+
f"Can't repair the pymcsc library ({e}). Run '{REPAIR_HINT}' and restart MCSC."
|
|
61
|
+
) from e
|
|
62
|
+
|
|
63
|
+
_forget_mcsc_modules()
|
|
64
|
+
if not pymcsc_available():
|
|
65
|
+
raise RuntimeError(f"The pymcsc library is still broken. Run '{REPAIR_HINT}' and restart MCSC.")
|
|
66
|
+
print("MCSC: pymcsc repaired.", file=sys.stderr)
|
|
@@ -1,45 +1,33 @@
|
|
|
1
|
-
"""Settings"""
|
|
2
|
-
|
|
3
|
-
import os
|
|
4
|
-
from appdirs import user_data_dir
|
|
5
|
-
from
|
|
6
|
-
_user_settings = UserSettings().user_settings
|
|
7
|
-
|
|
8
|
-
DEBUG=
|
|
9
|
-
# MISC APP SETTINGS
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
#
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
SERVERS_JSON_PATH = os.path.join(DATA_DIR_PATH, "config", "servers.json")
|
|
35
|
-
JAR_VERSIONS_FILTER = "stable" # "stable", "none"
|
|
36
|
-
MAX_LOG_LINES = 300
|
|
37
|
-
|
|
38
|
-
# SERVER EXECUTION SETTINGS
|
|
39
|
-
JAVA_BIT_MODEL = "64"
|
|
40
|
-
NOGUI = True
|
|
41
|
-
|
|
42
|
-
# URLS
|
|
43
|
-
VANILLA_VERSION_LIST_URL = "https://raw.githubusercontent.com/ddavidel/minecraft-server-jars/refs/heads/main/versions/vanilla_version_list.json"
|
|
44
|
-
FORGE_VERSION_LIST_URL = "https://raw.githubusercontent.com/ddavidel/minecraft-forge-links/refs/heads/main/version_list.json"
|
|
45
|
-
PAPER_VERSION_LIST_URL = "https://raw.githubusercontent.com/ddavidel/minecraft-server-jars/refs/heads/main/versions/paper_version_list.json"
|
|
1
|
+
"""Settings"""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from appdirs import user_data_dir
|
|
5
|
+
from mcsc_gui.core.user_settings import UserSettings
|
|
6
|
+
_user_settings = UserSettings().user_settings
|
|
7
|
+
|
|
8
|
+
DEBUG = os.environ.get("MCSC_DEBUG", "").lower() in {"1", "true", "yes"}
|
|
9
|
+
# MISC APP SETTINGS
|
|
10
|
+
# The data folder keeps the historical "mcsc" name so existing installs keep their data
|
|
11
|
+
DATA_DIR_PATH = user_data_dir("mcsc")
|
|
12
|
+
LOG_DIR_PATH = os.path.join(DATA_DIR_PATH, "logs")
|
|
13
|
+
TELEMETRY_DIR_PATH = os.path.join(DATA_DIR_PATH, "telemetry")
|
|
14
|
+
TELEMETRY_API = "https://mcscreator.altervista.org/telemetry/receiver.php"
|
|
15
|
+
PACKAGE_NAME = "minecraft-server-creator"
|
|
16
|
+
PYPI_PACKAGE_URL = f"https://pypi.org/pypi/{PACKAGE_NAME}/json"
|
|
17
|
+
|
|
18
|
+
# DB
|
|
19
|
+
BACKEND = "json"
|
|
20
|
+
USER_SETTINGS_FILENAME = "user_settings.json"
|
|
21
|
+
USER_SETTINGS_PATH = os.path.join(DATA_DIR_PATH, "config")
|
|
22
|
+
USER_SETTINGS_FILE_PATH = os.path.join(USER_SETTINGS_PATH, USER_SETTINGS_FILENAME)
|
|
23
|
+
|
|
24
|
+
# TRANSLATION SETTINGS
|
|
25
|
+
DEFAULT_LANGUAGE = _user_settings.get("language", "en")
|
|
26
|
+
AVAILABLE_LANGAGUES = ["en", "it"]
|
|
27
|
+
|
|
28
|
+
# SERVERS SETTINGS (server management is handled by the pymcsc library)
|
|
29
|
+
SERVER_DIR_PATH = os.path.join(DATA_DIR_PATH, "servers")
|
|
30
|
+
SERVERS_JSON_PATH = os.path.join(DATA_DIR_PATH, "config", "servers.json")
|
|
31
|
+
JAR_VERSIONS_FILTER = "stable" # "stable", "none"
|
|
32
|
+
MAX_LOG_LINES = 300
|
|
33
|
+
SERVER_STOP_TIMEOUT = 60 # seconds before a server that doesn't stop gets killed
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"""
|
|
2
|
+
An asyncio event loop running in a dedicated background thread.
|
|
3
|
+
|
|
4
|
+
pymcsc is asyncio based (server processes are asyncio subprocesses), while the
|
|
5
|
+
Qt event loop owns the main thread. The UI never runs pymcsc code itself: it
|
|
6
|
+
hands coroutines to :meth:`AsyncBridge.submit` (or blocking functions to
|
|
7
|
+
:meth:`AsyncBridge.call`) and gets a :class:`concurrent.futures.Future` back.
|
|
8
|
+
|
|
9
|
+
pymcsc listeners therefore run in the bridge thread: they must never touch UI
|
|
10
|
+
widgets. No UI toolkit is imported here.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import asyncio
|
|
16
|
+
import concurrent.futures
|
|
17
|
+
import functools
|
|
18
|
+
import logging
|
|
19
|
+
import sys
|
|
20
|
+
import threading
|
|
21
|
+
from collections.abc import Callable, Coroutine
|
|
22
|
+
from typing import Any, TypeVar
|
|
23
|
+
|
|
24
|
+
logger = logging.getLogger(__name__)
|
|
25
|
+
|
|
26
|
+
T = TypeVar("T")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class AsyncBridge:
|
|
30
|
+
"""Runs an asyncio loop in a daemon thread and schedules work on it."""
|
|
31
|
+
|
|
32
|
+
def __init__(self, name: str = "mcsc-asyncio") -> None:
|
|
33
|
+
self._name = name
|
|
34
|
+
self._loop: asyncio.AbstractEventLoop | None = None
|
|
35
|
+
self._thread: threading.Thread | None = None
|
|
36
|
+
self._ready = threading.Event()
|
|
37
|
+
self._lock = threading.Lock()
|
|
38
|
+
self._stopped = False
|
|
39
|
+
|
|
40
|
+
# ------------------------------------------------------------- lifecycle
|
|
41
|
+
|
|
42
|
+
def start(self) -> None:
|
|
43
|
+
"""Start the thread and the loop. Idempotent. Blocks until the loop is ready."""
|
|
44
|
+
with self._lock:
|
|
45
|
+
if self._stopped:
|
|
46
|
+
raise RuntimeError("bridge stopped")
|
|
47
|
+
if self._thread is not None:
|
|
48
|
+
return
|
|
49
|
+
self._thread = threading.Thread(target=self._run, name=self._name, daemon=True)
|
|
50
|
+
self._thread.start()
|
|
51
|
+
self._ready.wait()
|
|
52
|
+
|
|
53
|
+
def _run(self) -> None:
|
|
54
|
+
if sys.platform == "win32":
|
|
55
|
+
# Subprocesses need the proactor loop on Windows (the default since 3.8,
|
|
56
|
+
# made explicit because this loop doesn't live in the main thread).
|
|
57
|
+
loop: asyncio.AbstractEventLoop = asyncio.ProactorEventLoop()
|
|
58
|
+
else:
|
|
59
|
+
loop = asyncio.new_event_loop()
|
|
60
|
+
asyncio.set_event_loop(loop)
|
|
61
|
+
self._loop = loop
|
|
62
|
+
loop.call_soon(self._ready.set)
|
|
63
|
+
try:
|
|
64
|
+
loop.run_forever()
|
|
65
|
+
finally:
|
|
66
|
+
try:
|
|
67
|
+
loop.run_until_complete(loop.shutdown_asyncgens())
|
|
68
|
+
loop.run_until_complete(loop.shutdown_default_executor())
|
|
69
|
+
except Exception: # pylint: disable=broad-exception-caught
|
|
70
|
+
logger.exception("Error while closing the asyncio loop")
|
|
71
|
+
finally:
|
|
72
|
+
loop.close()
|
|
73
|
+
logger.debug("asyncio bridge loop closed")
|
|
74
|
+
|
|
75
|
+
@property
|
|
76
|
+
def loop(self) -> asyncio.AbstractEventLoop:
|
|
77
|
+
"""The bridge's event loop (only valid after :meth:`start`)."""
|
|
78
|
+
if self._loop is None:
|
|
79
|
+
raise RuntimeError("bridge not started")
|
|
80
|
+
return self._loop
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def is_running(self) -> bool:
|
|
84
|
+
"""True between :meth:`start` and :meth:`shutdown`."""
|
|
85
|
+
return self._loop is not None and not self._stopped and self._loop.is_running()
|
|
86
|
+
|
|
87
|
+
@property
|
|
88
|
+
def thread(self) -> threading.Thread | None:
|
|
89
|
+
"""The bridge thread (``None`` before :meth:`start`)."""
|
|
90
|
+
return self._thread
|
|
91
|
+
|
|
92
|
+
def in_bridge_thread(self) -> bool:
|
|
93
|
+
"""True if the caller runs in the bridge thread."""
|
|
94
|
+
return threading.current_thread() is self._thread
|
|
95
|
+
|
|
96
|
+
# ------------------------------------------------------------------ work
|
|
97
|
+
|
|
98
|
+
def submit(self, coro: Coroutine[Any, Any, T]) -> concurrent.futures.Future[T]:
|
|
99
|
+
"""Schedule ``coro`` on the loop. Thread-safe. Raises ``RuntimeError`` once stopped."""
|
|
100
|
+
if self._stopped or self._loop is None:
|
|
101
|
+
coro.close() # avoid "coroutine was never awaited"
|
|
102
|
+
raise RuntimeError("bridge stopped" if self._stopped else "bridge not started")
|
|
103
|
+
return asyncio.run_coroutine_threadsafe(coro, self._loop)
|
|
104
|
+
|
|
105
|
+
def call(self, fn: Callable[..., T], *args: Any, **kwargs: Any) -> concurrent.futures.Future[T]:
|
|
106
|
+
"""Run a blocking function (I/O, requests, pip) in the loop's executor."""
|
|
107
|
+
|
|
108
|
+
async def _in_executor() -> T:
|
|
109
|
+
loop = asyncio.get_running_loop()
|
|
110
|
+
return await loop.run_in_executor(None, functools.partial(fn, *args, **kwargs))
|
|
111
|
+
|
|
112
|
+
return self.submit(_in_executor())
|
|
113
|
+
|
|
114
|
+
# -------------------------------------------------------------- shutdown
|
|
115
|
+
|
|
116
|
+
def shutdown(self, timeout: float = 5.0) -> None:
|
|
117
|
+
"""Cancel the pending tasks, stop the loop and join the thread. Idempotent."""
|
|
118
|
+
with self._lock:
|
|
119
|
+
if self._stopped:
|
|
120
|
+
return
|
|
121
|
+
self._stopped = True
|
|
122
|
+
loop, thread = self._loop, self._thread
|
|
123
|
+
if loop is None or thread is None:
|
|
124
|
+
return
|
|
125
|
+
|
|
126
|
+
if loop.is_running() and not self.in_bridge_thread():
|
|
127
|
+
try:
|
|
128
|
+
asyncio.run_coroutine_threadsafe(_cancel_pending(), loop).result(timeout)
|
|
129
|
+
except (concurrent.futures.TimeoutError, RuntimeError):
|
|
130
|
+
logger.warning("Timed out cancelling the pending asyncio tasks")
|
|
131
|
+
except Exception: # pylint: disable=broad-exception-caught
|
|
132
|
+
logger.exception("Error cancelling the pending asyncio tasks")
|
|
133
|
+
try:
|
|
134
|
+
loop.call_soon_threadsafe(loop.stop)
|
|
135
|
+
except RuntimeError:
|
|
136
|
+
pass # loop already closed
|
|
137
|
+
if not self.in_bridge_thread():
|
|
138
|
+
thread.join(timeout)
|
|
139
|
+
if thread.is_alive():
|
|
140
|
+
logger.warning("asyncio bridge thread did not stop within %ss", timeout)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
async def _cancel_pending() -> None:
|
|
144
|
+
current = asyncio.current_task()
|
|
145
|
+
tasks = [t for t in asyncio.all_tasks() if t is not current and not t.done()]
|
|
146
|
+
for task in tasks:
|
|
147
|
+
task.cancel()
|
|
148
|
+
results = await asyncio.gather(*tasks, return_exceptions=True)
|
|
149
|
+
for result in results:
|
|
150
|
+
if isinstance(result, Exception) and not isinstance(result, asyncio.CancelledError):
|
|
151
|
+
logger.error(f"Exception during shutdown: {result}")
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
_bridge: AsyncBridge | None = None
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def get_bridge() -> AsyncBridge:
|
|
158
|
+
"""The application-wide bridge (created, not started, on first use)."""
|
|
159
|
+
global _bridge # pylint: disable=global-statement
|
|
160
|
+
if _bridge is None:
|
|
161
|
+
_bridge = AsyncBridge()
|
|
162
|
+
return _bridge
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Logging setup.
|
|
3
|
+
|
|
4
|
+
The app and the pymcsc library (``mcsc`` logger) log through the standard
|
|
5
|
+
``logging`` module; this module routes both to a daily log file.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import datetime
|
|
9
|
+
import logging
|
|
10
|
+
import os
|
|
11
|
+
|
|
12
|
+
from mcsc_gui.config import settings as mcssettings
|
|
13
|
+
|
|
14
|
+
LOGGER_NAMES = ("mcsc", "mcsc_gui")
|
|
15
|
+
LOG_FORMAT = "[%(asctime)s] %(levelname)s %(name)s: %(message)s"
|
|
16
|
+
DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
|
|
17
|
+
|
|
18
|
+
_configured = False
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def setup_logging(debug: bool = mcssettings.DEBUG, log_dir: str = mcssettings.LOG_DIR_PATH) -> None:
|
|
22
|
+
"""Send app and library logs to ``log_dir/logs_<date>.log`` (and the console in debug)."""
|
|
23
|
+
global _configured # pylint: disable=global-statement
|
|
24
|
+
if _configured:
|
|
25
|
+
return
|
|
26
|
+
|
|
27
|
+
os.makedirs(log_dir, exist_ok=True)
|
|
28
|
+
today = datetime.datetime.now().strftime("%Y-%m-%d")
|
|
29
|
+
formatter = logging.Formatter(LOG_FORMAT, DATE_FORMAT)
|
|
30
|
+
|
|
31
|
+
handlers: list[logging.Handler] = [
|
|
32
|
+
logging.FileHandler(os.path.join(log_dir, f"logs_{today}.log"), encoding="utf-8")
|
|
33
|
+
]
|
|
34
|
+
if debug:
|
|
35
|
+
handlers.append(logging.StreamHandler())
|
|
36
|
+
|
|
37
|
+
for handler in handlers:
|
|
38
|
+
handler.setFormatter(formatter)
|
|
39
|
+
|
|
40
|
+
for name in LOGGER_NAMES:
|
|
41
|
+
logger = logging.getLogger(name)
|
|
42
|
+
logger.setLevel(logging.DEBUG if debug else logging.INFO)
|
|
43
|
+
for handler in handlers:
|
|
44
|
+
logger.addHandler(handler)
|
|
45
|
+
|
|
46
|
+
_configured = True
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""Migration of servers created by MCSC v1 (legacy layout) to the current one."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import logging
|
|
7
|
+
import os
|
|
8
|
+
import shutil
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from mcsc import ServerConfig
|
|
12
|
+
|
|
13
|
+
from mcsc_gui.config import settings as mcssettings
|
|
14
|
+
from mcsc_gui.core.server_manager import find_server, register_server
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
MIGRATION_FILENAME = "migration.mgr"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def migrate_legacy(
|
|
22
|
+
data_dir: str | os.PathLike | None = None,
|
|
23
|
+
servers_dir: str | os.PathLike | None = None,
|
|
24
|
+
) -> int:
|
|
25
|
+
"""
|
|
26
|
+
Copy the servers listed by a legacy ``migration.mgr`` into ``servers_dir``.
|
|
27
|
+
|
|
28
|
+
``migration.mgr`` (written by the v1 uninstaller) holds the path of the legacy
|
|
29
|
+
``servers.json``. Servers already migrated are skipped. When done the file is
|
|
30
|
+
renamed to ``migration.mgr.done``. Returns the number of migrated servers.
|
|
31
|
+
"""
|
|
32
|
+
data_dir = Path(data_dir if data_dir is not None else mcssettings.DATA_DIR_PATH)
|
|
33
|
+
servers_dir = Path(servers_dir if servers_dir is not None else mcssettings.SERVER_DIR_PATH)
|
|
34
|
+
migration_file = data_dir / MIGRATION_FILENAME
|
|
35
|
+
if not migration_file.exists():
|
|
36
|
+
return 0
|
|
37
|
+
|
|
38
|
+
logger.info("Detected servers migration for legacy version of MCSC")
|
|
39
|
+
legacy_servers_json = migration_file.read_text(encoding="utf-8").strip()
|
|
40
|
+
legacy_servers_dict = json.loads(Path(legacy_servers_json).read_text(encoding="utf-8"))
|
|
41
|
+
|
|
42
|
+
migrated = 0
|
|
43
|
+
for server_uuid, legacy_config in legacy_servers_dict.items():
|
|
44
|
+
logger.info(f"Migrating server '{server_uuid}' ({legacy_config.get('name')})...")
|
|
45
|
+
new_server_folder = servers_dir / server_uuid
|
|
46
|
+
|
|
47
|
+
if new_server_folder.exists() or find_server(server_uuid) is not None:
|
|
48
|
+
continue
|
|
49
|
+
|
|
50
|
+
shutil.copytree(legacy_config["folder_path"], new_server_folder)
|
|
51
|
+
|
|
52
|
+
# ServerConfig.from_dict understands the legacy keys (jar_type, dedicated_ram, ...)
|
|
53
|
+
config = ServerConfig.from_dict({**legacy_config, "uuid": server_uuid})
|
|
54
|
+
config.path = new_server_folder
|
|
55
|
+
register_server(config)
|
|
56
|
+
migrated += 1
|
|
57
|
+
|
|
58
|
+
migration_file.rename(migration_file.with_suffix(".mgr.done"))
|
|
59
|
+
logger.info("Migration completed successfully.")
|
|
60
|
+
return migrated
|