csust-login
这是一个用于自动登录长沙理工大学校园网的 Python 脚本工具。该工具能够自动检测网络连接状态,并在掉线时自动进行登录。
安装说明
直接下载
如果你使用 Windows 或 macOS,且不想安装 Python 环境,可以直接下载打包好的应用程序:
- Windows 用户:下载
.exe文件,双击即可运行 - macOS 用户:下载
.dmg文件,安装后即可使用
通过 pip 安装
你也可以通过 Python 的包管理器 pip 安装此工具。根据你的使用场景,有以下两种安装方式:
基础安装
如果你只需要命令行功能(例如在 Linux 服务器、OpenWrt 路由器上实现自动静默登录),请执行:
pip install csust-login
完整安装
如果你在 Windows 或 macOS 电脑上使用,并希望拥有图形化界面(App 界面)和系统通知功能,推荐安装 UI 扩展部分:
pip install "csust-login[ui]"
使用方法
图形界面模式
如果你已通过 pip install "csust-login[ui]" 安装了 UI 扩展,可以直接在终端运行:
csust-login-ui
启动后会打开图形界面窗口,你可以在界面中直接配置账号、密码等参数,无需手动编辑配置文件。
命令行模式
命令行模式非常适合在服务器、路由器或不需要图形界面的环境下长时间运行。
1. 准备配置文件
在使用之前,你需要在程序运行的目录下创建一个名为 config.yaml 的文件,用于存放你的校园网账号信息。
最简配置示例: 只需填入你的学号和密码即可。
USERNAME: "你的学号"
PASSWORD: "你的密码"
点击查看完整配置项(进阶用户)
如果你有特殊需求(如修改检测频率或设置网络重置命令),可以参考以下完整字段:
USERNAME: "" # 学号
PASSWORD: "" # 密码
DAEMON_EXEC_INTERVAL: 20 # 守护进程正常检测间隔(秒)
DAEMON_RETRY_INTERVAL: 3 # 登录失败后的重试间隔(秒)
CHECK_NETWORK_TIMEOUT: 5 # 网络检查超时时间
LOGIN_TIMEOUT: 10 # 登录请求超时时间
ENABLE_LOGGING: true # 是否开启日志记录
LOG_DIR: "logs" # 日志存放目录
LOG_LEVEL: "INFO" # 日志级别
NETWORK_RESET_CMD: "" # 网络重置自定义命令(例如重启网卡)
2. 运行工具
安装完成后,你可以直接在终端使用以下两个命令:
手动单次登录
用于立即执行一次登录检查。如果已在线则跳过,如果离线则尝试登录。
csust-login
后台守护进程
用于自动巡检。程序会根据配置的间隔时间(默认 20 秒)自动检测网络状态,发现掉线自动重连。
csust-login-daemon
如果你需要将守护进程配置为系统服务(开机自启),请参考下方后台服务配置章节。
后台服务配置
如果你希望让守护进程在系统启动时自动运行,可以参考以下配置方式。
OpenWrt
1. 安装依赖
opkg update
opkg install python3 python3-pip
pip install csust-login
2. 准备配置文件
mkdir -p /root/csust-login
cat > /root/csust-login/config.yaml << EOF
USERNAME: "你的学号"
PASSWORD: "你的密码"
EOF
3. 创建 init.d 服务
将以下内容写入 /etc/init.d/csust-login:
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
PROG="/usr/bin/csust-login-daemon"
SCRIPT_PATH="/root/csust-login"
start_service() {
procd_open_instance
procd_set_param command /bin/sh -c "cd $SCRIPT_PATH && $PROG"
procd_set_param respawn
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
4. 启用并启动服务
chmod +x /etc/init.d/csust-login
/etc/init.d/csust-login enable
/etc/init.d/csust-login start
Ubuntu / Debian
1. 安装依赖
使用系统 pip 或虚拟环境安装均可,以下以 Conda 为例:
# 使用 pip 直接安装
pip install csust-login
# 或通过 Conda 环境安装
conda activate your_env
pip install csust-login
2. 准备配置文件
mkdir -p ~/csust-login
cat > ~/csust-login/config.yaml << EOF
USERNAME: "你的学号"
PASSWORD: "你的密码"
EOF
3. 创建 systemd 服务
将以下内容写入 /etc/systemd/system/csust-login.service,注意根据实际情况修改 User、WorkingDirectory 和 ExecStart 路径:
[Unit]
Description=CSUST Network Login Daemon
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=your_username
WorkingDirectory=/home/your_username/csust-login
ExecStart=/usr/local/bin/csust-login-daemon
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
如果通过 Conda 安装,
ExecStart需要指向 Conda 环境中的可执行文件路径,例如/home/your_username/miniconda3/bin/csust-login-daemon。
4. 启用并启动服务
sudo systemctl daemon-reload
sudo systemctl enable csust-login
sudo systemctl start csust-login
查看运行状态:
sudo systemctl status csust-login
Metadata
Release files for csust-login 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| csust_login-1.0.1.tar.gz | 265.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| csust_login-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 495.5 kB
Release files / csust_login-1.0.1.tar.gz
| Download URL | csust_login-1.0.1.tar.gz |
|---|---|
| Size | 265.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c50372488c5cee17a5af833d7a62b0b4fb98b1d7cf086c4afc26335ccf09cd3f
|
|
BLAKE2b-256 checksum How to use checksums |
6e474bc46665be717a328eca27ec4b826fe91aeec1ba682add397a572a628a1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / csust_login-1.0.1-py3-none-any.whl
| Download URL | csust_login-1.0.1-py3-none-any.whl |
|---|---|
| Size | 229.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9bbbb7de5486f1c5b3b55cea22d17198df5ebfbb47ee5233031b13682038e78f
|
|
BLAKE2b-256 checksum How to use checksums |
7880b1be81a8e3c1cd3c84169cb480f30d4bace5352b23d671b7da436ca8afe4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for csust-login 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.