From 28f33a1be7e0be9bb62cbc50018d4f91f2452cbf Mon Sep 17 00:00:00 2001 From: wling <90316914+wling-art@users.noreply.github.com> Date: Thu, 8 Feb 2024 12:20:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=90=88=E5=B9=B6=E6=9B=B4=E6=94=B9=20(#3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * modified: tooldelta/basic_mods.py modified: tooldelta/get_python_libs.py more descriptions for the exception * 📦 提高 `Python` 支持宽容度 (#48) * modified: tooldelta/__init__.py modified: tooldelta/launch_cli.py modified: tooldelta/sys_args.py Add a new launcher frame * delete legacy version of the dependency table * enhanced stability for the release action * delete unnecessary lines on actions * format release action * format `pyproject.toml` --------- Co-authored-by: SuperScript-PRC <2528622340@qq.com> Co-authored-by: Happy2018new Co-authored-by: Eternal Crystal <109064184+Happy2018new@users.noreply.github.com> --- .github/workflows/build_and_release.yml | 8 ++++-- .github/workflows/publish_python_package.yml | 4 +-- requirements.txt | 9 ------ tooldelta/__init__.py | 4 ++- tooldelta/basic_mods.py | 4 +-- tooldelta/get_python_libs.py | 4 +-- tooldelta/launch_cli.py | 29 +++++++++++++++++++- tooldelta/sys_args.py | 7 +++-- 8 files changed, 46 insertions(+), 23 deletions(-) delete mode 100644 requirements.txt diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index 43a6d88b..e88b94f0 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -20,6 +20,7 @@ jobs: name: Build Winsows runs-on: windows-latest steps: + - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: @@ -27,9 +28,9 @@ jobs: - name: Install Dependencies run: | - python -m pip install --upgrade pip pip install pyinstaller pip install poetry + poetry update poetry install - name: Build @@ -60,6 +61,7 @@ jobs: name: Build Linux runs-on: ubuntu-latest steps: + - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: @@ -67,9 +69,9 @@ jobs: - name: Install Dependencies run: | - python -m pip install --upgrade pip pip install pyinstaller pip install poetry + poetry update poetry install - name: Build @@ -86,4 +88,4 @@ jobs: tag_name: ${{env.VERSION}} name: ${{env.VERSION}} files: | - dist/* \ No newline at end of file + dist/* diff --git a/.github/workflows/publish_python_package.yml b/.github/workflows/publish_python_package.yml index 2c802ff5..a6c7b7ad 100644 --- a/.github/workflows/publish_python_package.yml +++ b/.github/workflows/publish_python_package.yml @@ -23,9 +23,7 @@ jobs: python-version: '3.11' - name: Install Dependencies - run: | - python -m pip install --upgrade pip - pip install poetry + run: pip install poetry - name: Build and Publish run: | diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index bbf95b63..00000000 --- a/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -psutil==5.9.4 -requests==2.28.2 -NBT==1.5.1 -qrcode==7.4.2 -orjson==3.9.2 -PyMySQL==1.0.2 -websockets==10.4 -ujson==5.8.0 -rich==13.3.2 \ No newline at end of file diff --git a/tooldelta/__init__.py b/tooldelta/__init__.py index aa234511..da1edaef 100644 --- a/tooldelta/__init__.py +++ b/tooldelta/__init__.py @@ -75,6 +75,7 @@ def read_cfg(self): public_launcher = [ ("FastBuilder External 模式 (经典模式) §c(已停止维护, 无法适应新版本租赁服!)", FrameFBConn), ("NeOmega 框架 (NeOmega模式, 租赁服适应性强)", FrameNeOmg), + ("NeOmega 框架 (NeOmegay连接模式, 需要先启动对应的neOmega接入点)", FrameNeOmg), ] CFG = { "服务器号": 0, @@ -87,7 +88,8 @@ def read_cfg(self): "启动器启动模式(请不要手动更改此项, 改为0可重置)": Config.NNInt, } if not os.path.isfile("fbtoken"): - Print.print_err("请到FB官网 user.fastbuilder.pro 下载FBToken, 并放在本目录中,或者在下面输入fbtoken") # 用户手动输入fbtoken并创建文件 + Print.print_err("请到FB官网 user.fastbuilder.pro 下载FBToken, 并放在本目录中,或者在下面输入fbtoken") + # 用户手动输入fbtoken并创建文件 fbtoken = input(Print.fmt_info("请输入fbtoken: ", "§b 输入 ")) if fbtoken: with open("fbtoken", "w", encoding="utf-8") as f: diff --git a/tooldelta/basic_mods.py b/tooldelta/basic_mods.py index 22dc6a24..cbd2d4bf 100644 --- a/tooldelta/basic_mods.py +++ b/tooldelta/basic_mods.py @@ -4,11 +4,11 @@ sys.path.append(os.path.join(os.getcwd(), "libs")) import psutil, requests, nbt, qrcode, getpass, pymysql, websockets, ujson, hashlib, base64, rich.progress -except ModuleNotFoundError: +except ModuleNotFoundError as err: # 第一次部署该项目, 将会自动安装这些模块. from . import get_python_libs - get_python_libs.try_install_libs() + get_python_libs.try_install_libs(err) import time, os, sys, threading, json, traceback, datetime, platform, subprocess, socket, logging, ctypes, asyncio, copy, math, random import psutil, requests, nbt, qrcode, getpass, pymysql, websockets, ujson, hashlib, base64, rich.progress diff --git a/tooldelta/get_python_libs.py b/tooldelta/get_python_libs.py index 69b8bf8e..ef85ef60 100644 --- a/tooldelta/get_python_libs.py +++ b/tooldelta/get_python_libs.py @@ -15,11 +15,11 @@ "ujson": None } -def try_install_libs(): +def try_install_libs(parent_err): if argv[-1].split(sep)[-1] == "main.py": install_libs(neccessary_libs.keys()) else: - raise SystemExit("打包程序内模块未能找到") + raise ModuleNotFoundError(f"打包程序内模块未能找到: {parent_err}") def check_pip(): try: diff --git a/tooldelta/launch_cli.py b/tooldelta/launch_cli.py index e065caae..ba80e88e 100644 --- a/tooldelta/launch_cli.py +++ b/tooldelta/launch_cli.py @@ -5,6 +5,7 @@ from .builtins import Builtins from .packets import Packet_CommandOutput, PacketIDS from .urlmethod import get_free_port +from .sys_args import sys_args_to_dict class SysStatus: LAUNCHING = 0 @@ -380,7 +381,6 @@ def _msg_show_thread(): def launch(self): openat_port = self.start_neomega_proc() - # openat_port = 24016 self.msg_show() self.set_omega(openat_port) Print.print_suc("已开启 NEOMG 进程") @@ -465,3 +465,30 @@ def sendfbcmd(_): self.sendwocmd = sendwocmd self.sendPacket = self.sendPacketJson = sendPacket self.sendfbcmd = sendfbcmd + +class FrameNeOmgRemote(FrameNeOmg): + def launch(self): + try: + openat_port = int(sys_args_to_dict().get("access-point-port", "0")) + assert openat_port in range(65536) + except (ValueError, AssertionError): + Print.print_err("启动参数 -access-point-port 错误: 不是1~65535的整数") + if openat_port == 0: + Print.print_war("未用启动参数指定链接neOmega接入点开放端口, 尝试使用默认端口 24015") + Print.print_inf("可使用启动参数 -access-point-port=端口 以指定接入点端口.") + openat_port = 24015 + else: + Print.print_inf(f"将从端口 {openat_port} 连接至 neOmega 接入点.") + self.set_omega(openat_port) + Print.print_suc("已连接上 NEOMG 接入点进程.") + pcks = [ + self.omega.get_packet_id_to_name_mapping(i) + for i in self.need_listen_packets + ] + self.omega.listen_packets(pcks, self.packet_handler_parent) + self._launcher_listener() + # bug expired + self.omega.listen_player_chat(lambda _, _2: None) + Print.print_suc("NEOMEGA 已就绪") + r = self.omega.wait_disconnect() + return Exception(r) \ No newline at end of file diff --git a/tooldelta/sys_args.py b/tooldelta/sys_args.py index a5acafa2..997769e0 100644 --- a/tooldelta/sys_args.py +++ b/tooldelta/sys_args.py @@ -1,5 +1,8 @@ -def SysArgsToDict(argv: list): - d = {} +import sys +def sys_args_to_dict(argv: list[str] = sys.argv): + # 将启动参数分割为 -键=值 或 -键=None + # 为什么不用 argsparser? 因为这样可以支持混合型启动参数 + d: dict[str, str] = {} i = 0 while i < len(argv): arg = argv[i] From 2f782bc37d24c33257ee713ff7e47498d7b0cbed Mon Sep 17 00:00:00 2001 From: wling Date: Thu, 8 Feb 2024 12:26:26 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=8D=BB=20test=20github=20acthion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 98dddd75..13699b8e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ pymysql = "1.1.0" websockets = "12.0" ujson = "5.9.0" rich = "13.7.0" +pygame = "2.5.2" [build-system]