buptgw

login to gw.bupt.edu.cn to access the Internet


Keywords
bupt, network, gateway, login
License
MIT
Install
pip install buptgw==0.1.1

Documentation

BUPT Gateway Login

用于登录北京邮电大学校园网的命令行程序。跨平台,但仅支持 Python 3。

可以从文件读取用户名和密码自动登录,或者通过参数指定用户名密码,也可以交互式输入用户名密码。

安装

直接使用 pip 安装

pip install buptgw


如果有问题可以使用 pypi 源,且支持 IPv6,校园网电脑无需登录网络即可访问

pip install -i https://pypi.org/simple buptgw

如果你没有 root 权限,可以添加 --user 参数即

pip install buptgw --userpip install -i https://pypi.org/simple buptgw --user

另外在某些比较旧版本系统上 pip 指向 pip2,所以需要使用 pip3 代替命令中的 pip

使用

登录 buptgw -i

退出 buptgw -o

保存用户名密码到文件(下次登录无需手动输入) buptgw -w

全部参数

Usage: buptgw -i|-o|-w  [-c <config_file>] [-u <username>] [-p <password>]
    -i                login
    -o                logout
    -w                write username and password to config file
    -c <config_path>  config file path, optional, defualt is ~/.buptgw
    -u <username>
    -p <password>

参数 -i 代表登录 -o 代表退出,-w 把用户名和密码写入配置文件,这三个只能选择一个

-c 指定配置文件路径(存储用户名和密码),对 -i-w 有效。如果不指定配置文件,默认为 ~/.buptgw。

-u 指定用户名,如果不指定,会从配置文件读取,如果读取失败则要求输入

-p 指定密码,如果不指定,则要求输入(如果用户名也没输入则一并从配置文件读取)

在 python 中调用

import buptgw

buptgw.login('2018xxxxxx', 'passwd') # 登录,xxx 处替换为正确的学号和密码
buptgw.logout() # 退出

实现开机自动登录

window

windows 下编写 bat 文件(xxx 处替换为正确的学号和密码),例如保存为 network.bat (注意,不能保存为 buptgw.bat 这样会导致这个文件自己调用自己)

buptgw -i -u 2018xxxxxx -p xxxxx

然后把这个文件放到系统的启动目录下,一般来说,通过运行(快捷键是 win + R),输入 shell:startup 可以快速打开启动目录。

Linux

把登录命令写入 ~/.profile 中

作者博客 :https://codeplot.top