16 Commits

Author SHA1 Message Date
803f742d85 降低python版本依赖 2024-10-03 01:48:18 +08:00
2e0c8ff194 降低python版本依赖 2024-10-03 01:47:38 +08:00
af970a77ed 降低python版本依赖 2024-10-03 00:59:49 +08:00
a579c76002 添加命令行工具 2024-10-03 00:27:39 +08:00
66d0782106 添加命令行工具 2024-10-03 00:24:53 +08:00
851242ce51 添加命令行工具 2024-10-03 00:22:04 +08:00
703fe75a76 添加注释 2024-10-03 00:17:56 +08:00
d24926daeb 添加注释 2024-10-03 00:14:08 +08:00
80ee613746 添加注释 2024-10-03 00:13:57 +08:00
851d1b0b7f 添加注释 2024-10-02 23:03:54 +08:00
f12858a876 添加注释 2024-10-02 23:03:19 +08:00
a0c84037e8 添加注释 2024-10-02 23:02:24 +08:00
25e137b6db first comm 2024-10-02 12:55:24 +08:00
c9d6265b9c first comm 2024-10-02 12:52:51 +08:00
95667b454e first comm 2024-10-02 12:51:11 +08:00
cd548f595e first comm 2024-10-02 12:47:32 +08:00
7 changed files with 102 additions and 17 deletions

49
.github/workflows/nuitka-compile.yml vendored Normal file
View File

@@ -0,0 +1,49 @@
name: Publish
on:
push:
tags:
- '*'
jobs:
build:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
arch: [amd64, arm64, arm, 386]
runs-on: ${{ matrix.os }}
steps:
- name: Check-out repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
cache: 'pip'
cache-dependency-path: |
**/requirements*.txt
- name: Install Dependencies
run: |
pip install pdm
pdm install --no-lock
- name: Build Executable
uses: Nuitka/Nuitka-Action@main
with:
nuitka-version: main
script-name: server_status.__main__
onefile: true
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }} Build
path: |
build/*.exe
build/*.bin
build/*.app/**/*

21
.github/workflows/pypi-publish.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: Publish
on:
push:
tags:
- '*'
jobs:
pypi-publish:
name: upload release to PyPI
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- uses: pdm-project/setup-pdm@v3
- name: Publish package distributions to PyPI
run: pdm publish

View File

@@ -32,16 +32,16 @@ _✨ 服务器状态 - 客户端 ✨_
Debian系请使用pipx安装 Debian系请使用pipx安装
```bash ```bash
sudo apt install python3-pipx sudo apt install pipx
pipx install server-status sudo pipx install server-status
``` ```
## 🎉 使用 ## 🎉 使用
### 命令 ### 命令
- `server_status <server> <token> <id> run` - 运行客户端 - `server-status <server> <token> <id> run` - 运行客户端
- `server_status <server> <token> <id> rm` - 从服务端移除主机 - `server-status <server> <token> <id> rm` - 从服务端移除主机
#### 可选项 #### 可选项
- `-n|--name` - 设置主机名称 - `-n|--name` - 设置主机名称
@@ -60,6 +60,8 @@ server_status https://status.liteyuki.icu 114514 myhost run -n "MyHost" --labels
### 开机启动 ### 开机启动
执行以下命令 执行以下命令
```shell ```shell
sudo pipx ensurepath # 确保pipx路径在环境变量下
sudo touch /etc/systemd/system/server-status-client.service sudo touch /etc/systemd/system/server-status-client.service
sudo bash -c 'cat <<EOF > /etc/systemd/system/server-status-client.service sudo bash -c 'cat <<EOF > /etc/systemd/system/server-status-client.service
@@ -69,7 +71,7 @@ After=network-online.target
[Service] [Service]
Type=simple Type=simple
ExecStart=sudo server_status <server> <token> <id> run # 请替换为实际参数 ExecStart=server-status <server> <token> <id> run # 请替换为实际参数
Restart=on-failure Restart=on-failure
RestartSec=10 RestartSec=10
@@ -79,4 +81,8 @@ EOF'
sudo systemctl enable server-status-client sudo systemctl enable server-status-client
sudo systemctl start server-status-client sudo systemctl start server-status-client
``` ```
### 服务端
请在中心服务器上部署 [server-status-server](https://github.com/snowykami/server-status-server)

View File

@@ -1,23 +1,30 @@
[project] [project]
name = "server-status-cv-py" name = "server-status"
version = "0.1.0" dynamic = ["version"]
description = "Server status client" description = "Server status client"
authors = [ authors = [
{name = "snowykami", email = "snowykami@outlook.com"}, { name = "snowykami", email = "snowykami@outlook.com" },
] ]
dependencies = [ dependencies = [
"requests>=2.32.3", "requests>=2.32.3",
"psutil>=6.0.0", "psutil>=6.0.0",
"arclet-alconna>=1.8.30", "arclet-alconna>=1.8.30",
] ]
requires-python = ">=3.11" requires-python = ">=3.10"
readme = "README.md" readme = "README.md"
license = {text = "MIT"} license = { text = "MIT" }
[build-system] [build-system]
requires = ["pdm-backend"] requires = ["pdm-backend"]
build-backend = "pdm.backend" build-backend = "pdm.backend"
[project.scripts]
server-status = "server_status.__main__:main"
[tool.pdm] [tool.pdm]
distribution = true distribution = true
[tool.pdm.version]
source = "scm"
tag_filter = "v*"
tag_regex = '^v(?:\D*)?(?P<version>([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*((a|b|c|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?$)$'

View File

@@ -1,10 +1,10 @@
import socket
import sys import sys
from server_status.api import * from server_status.api import *
from server_status.cmd_parser import server_status_alc from server_status.cmd_parser import server_status_alc
if __name__ == "__main__":
def main():
raw_msg = "server_status " + " ".join(sys.argv[1:]) raw_msg = "server_status " + " ".join(sys.argv[1:])
arp = server_status_alc.parse(raw_msg) arp = server_status_alc.parse(raw_msg)
@@ -35,3 +35,7 @@ if __name__ == "__main__":
else: else:
log("Unknown command, use 'server_status --help' for help/未知命令或参数错误,请使用 'server_status --help' 获取帮助") log("Unknown command, use 'server_status --help' for help/未知命令或参数错误,请使用 'server_status --help' 获取帮助")
if __name__ == "__main__":
main()

View File

@@ -106,17 +106,15 @@ class Api:
""" """
self.headers.update(self.format(headers)) self.headers.update(self.format(headers))
def format(self, obj: str | tuple[str, ...] | dict[str, Any]): def format(self, obj: str | list[str] | dict[str, Any]) -> str | list[str] | dict[str, Any]:
if isinstance(obj, str): if isinstance(obj, str):
obj = obj.format(**self.variables) obj = obj.format(**self.variables)
elif isinstance(obj, dict): elif isinstance(obj, dict):
for key in obj: for key in obj:
obj[key] = self.format(obj[key]) obj[key] = self.format(obj[key])
elif isinstance(obj, (list, tuple)): elif isinstance(obj, list):
for i in range(len(obj)): for i in range(len(obj)):
obj[i] = self.format(obj[i]) obj[i] = self.format(obj[i])
else:
pass
return obj return obj