piview package

Submodules

piview.CPU module

class piview.CPU.CPU[source]

Bases: object

static max_load(random=False)[source]

This function returns the maximum “CPU load” across all CPU cores, or -1 if no value determined.

Providing a random=True parameter value will return a random value if the actual CPU load can’t be determined.

Parameters

random – boolean default False

Return type

float

Returns

The maximum CPU Load in range 0-100

static speed()[source]

Get the CPU frequency using the vcgencmd on Linux based systems

If frequency cannot be determined, returns -1

Return type

integer

Returns

The CPU frequency in MHz

static temperature()[source]

Requests the CPU temperature from the vcgencmd returning the result to the caller as a floating point value to 2DP

If no value can be determined, uses -999.99 as the returned “error” value.

Return type

float

Returns

The CPU temperature in degrees Celsius

static temperature_k()[source]

Provide temperature of the CPU in degrees Kelvin

Returns

CPU Temperature in Kelvin

piview.GPU module

class piview.GPU.GPU[source]

Bases: object

static temperature()[source]

Requests the GPU temperature from the thermal zone details

Return type

string

Returns

GPU temperature in degrees Celsius to 2DP

piview.Hardware module

class piview.Hardware.Hardware[source]

Bases: object

static bt()[source]

Check if Bluetooth module is enabled

Return type

boolean

Returns

True|False

static camera()[source]

Check if camera is enabled and present

Return type

dictionary

Returns

Details in form {“supported”: boolean, “detected”: boolean}

static i2c()[source]

Check if I2C bus is enabled by checking for i2c_bcm2 modules

Return type

boolean

Returns

True|False

static spi()[source]

Check if SPI bus is enabled by checking for spi_bcm2 modules

Return type

boolean

Returns

True|False

piview.Host module

class piview.Host.Host[source]

Bases: object

static boot_time()[source]

Determines the time the device was started

Return type

datetime

Returns

How long ago the Pi was booted

static model()[source]

Provide Pi Model Details

Extracts the details from the device tree model file

Return type

string

Returns

The model name and other identifying details

static name()[source]

Provides the host name to the user

Return type

string

Returns

The host name of the Pi

static python()[source]

Get current Python version

Return type

string

Returns

A string containing the version of python that is being used

static revision()[source]

Provide board revision details

The details are extracted from the cpu info file

Return type

string

Returns

The revision number of the Pi motherboard

static serial()[source]

Provide the Serial Number of the Pi CPU

The details are extracted from the cpu info file

Return type

string

Returns

The Pi’s serial number

static uptime()[source]

Determines the amount of time the device has been running for in seconds

Return type

float

Returns

The time that the Pi has been ‘up’ for

piview.Network module

class piview.Network.Network[source]

Bases: object

static eth_name(_type=None)[source]

Provide the Ethernet interface name

Parameters

_type – string, possible options are: enx or eth

Return type

string

Returns

The network interface name

static host_name()[source]

Provide the host name to the user

Return type

string

Returns

The host name of the Pi

static ip(interface='eth0')[source]

Provide IP Address from the named interface

Default is eth0

Uses the ifconfig command to create a text file, then processes this file to obtain the IP address.

Parameters

interface – string, the interface to obtain the IP address for

Return type

string

Returns

IPv4 address of the selected interface

static mac(interface='eth0')[source]

Provides the hardware MAC address for the interface requested

Default is eth0

Parameters

interface – string, the interface name to query

Return type

string

Returns

Mac address of the selected interface

piview.Storage module

class piview.Storage.Storage[source]

Bases: object

static all_discs()[source]

Provide the user with the storage space (Total, Free) for each disc attached to the Pi as a dictionary.

The dictionary will have: “disc name” : (total storage, free storage) for each disc.

Return disc stats

dictionary of tuples

static all_disks()[source]

Alias for all_discs()

see all_discs()

static disc()[source]

Provide the total disc space and the disc space that is free

Return type

tuple

Returns

(Total, Free)

static disk()[source]

Alias for disc()

see disc()

static ram()[source]

Provide the total RAM and free RAM to the user as a tuple

Return type

tuple

Returns

(Total, Free)

piview.Utils module

class piview.Utils.Utils[source]

Bases: object

static draw_line(characters='-=-', length=40)[source]

Draw a line of characters using a given character and length

Parameters
  • characters – string, the character(s) to draw with

  • length – integer), the length of the line

Return type

string

Returns

A string of exactly length characters

static format_bytes(size=0, style=None)[source]

Formats the given value into Bytes, Kilobytes, Megabytes, …

Using Byte shorthand by default - B, KB, MB, …

The style may be:

  • None | short | s – Short labels

  • long | l – Long labels

If style is anything other than above, then defaults to long format.

Parameters
  • size – integer, defaults to 0

  • style – string, defaults to None

Return type

tuple

Returns

(float, string)

static random_percentage(min_percentage=0, max_percentage=100)[source]

This function returns a random percentage. Useful for simulations when developing monitoring dashboards

Parameters
  • min_percentage – float, minimum value to return, default 0.0

  • max_percentage – float, maximum to return, default 100.0

Return type

float

Returns

A random CPU load value between 0% and 100% to 1DP

piview.piview module

Main module.

Module contents

Top-level package for PiView.