pylibsnmp.helpers

Python module with helper functions used in the project.

Functions

get_bits(octets)

Converts octets to bits.

get_mac_from_octets(octets[, delimiter])

Converts octets to mac address.

get_speed(bits)

Converts bits to Kbits/s, Mbits/s or Gbits/s according to the bits count.

get_unit(bits)

Returns unit type according to the bits count.

is_ip_address(address)

Checks the string to be in ip address format.

is_port_number(port)

Checks whether port number argument has an appropriate value.

Classes

SetInterval(func, sec)

Class for creating python alternative to JavaScript setInterval function.

class pylibsnmp.helpers.SetInterval(func: Callable, sec: int)

Class for creating python alternative to JavaScript setInterval function.

__init__(func: Callable, sec: int) None

Class constructor.

params:
func: {Callable} - function to execute
sec: {int} - interval in seconds to execute func
cancel()

Cancels Timer object in order for the application to end correctly.

pylibsnmp.helpers.get_bits(octets: int) int

Converts octets to bits.

An octet is really just a fancy name for a “byte”. So if you multiply this number by 8 you get bits.

pylibsnmp.helpers.get_mac_from_octets(octets: str, delimiter: str = ':') str

Converts octets to mac address.

When requesting physical address of the device using snmp responce comes in the format of octets.

In order to convert it to mac address: | - get list of ascii codes of octets | - convert it to bytearray | - convert it to hex format

pylibsnmp.helpers.get_speed(bits: int) int

Converts bits to Kbits/s, Mbits/s or Gbits/s according to the bits count.

pylibsnmp.helpers.get_unit(bits: int) str

Returns unit type according to the bits count.

pylibsnmp.helpers.is_ip_address(address: str) bool

Checks the string to be in ip address format.

IP address have to: | - have four octets | - each octet must be from 0 to 255 | - each octet must be in digital format

pylibsnmp.helpers.is_port_number(port: int) bool

Checks whether port number argument has an appropriate value.

Port number has to be in the range of 1 and 65535.