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
piview.GPU module¶
piview.Hardware module¶
- class piview.Hardware.Hardware[source]¶
Bases:
object
- static camera()[source]¶
Check if camera is enabled and present
- Return type
dictionary
- Returns
Details in form {“supported”: boolean, “detected”: boolean}
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
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
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
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.