Skip to main content
Join the official Python Developers Survey 2018 and win valuable prizes: Start the survey!

Python library for accessing the Internet in Peking University.

Project description

libpkuipgw

A library for accessing the Internet through Peking University's Internet service.

Installing

The recommended way is to use pip to install

pip3 install --user libpkuipgw

Usage

First, initialize an IPGWClientobject:

import libpkuipgw
cli = libpkuipgw.IPGWClient(username, password)

If you are on Windows or macOS, you'll need to manually provide your MAC address:

import libpkuipgw
cli = libpkuipgw.IPGWClient(username, password, MAC) # MAC is a string, formatted like 5C:CF:7F:08:11:17

This is because I haven't found a way of portably getting the device's MAC address.

To connect to the Internet, call cli.connect()

To disconnect this device, call cli.disconnect()

To disconnect device with specific IP, make the call like cli.disconnect("10.2.111.111")

To disconnect all devices, call cli.disconnect_all()

To get all the connections available: cli.get_connections(). Returns a list:

[{'ip': '10.2.111.111', 'location': '22楼', 'login_time': '2018-08-08T22:22:22+08'}, {'ip': '10.2.222.222', 'location': '33楼', 'login_time': '2018-08-08T11:11:11+08'}]

The time format is ISO8601 complient.

Error Handling

Apart from get_connections, returns nothing when everything is all right. If an error occurs, an IPGWError would be raised.

Project details


Release history Release notifications

This version
History Node

0.1.3

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
libpkuipgw-0.1.3-py3-none-any.whl (3.5 kB) Copy SHA256 hash SHA256 Wheel py3 Aug 8, 2018
libpkuipgw-0.1.3.tar.gz (3.1 kB) Copy SHA256 hash SHA256 Source None Aug 8, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page