piview.Utils
¶
Module Contents¶
Classes¶
- class piview.Utils.Utils[source]¶
- 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