bumblebee_status.util package¶
Submodules¶
bumblebee_status.util.algorithm module¶
-
bumblebee_status.util.algorithm.
merge
(target, *args)¶ Merges arbitrary data - copied from http://blog.impressiver.com/post/31434674390/deep-merge-multiple-python-dicts
Parameters: - target – the data structure to fill
- args – a list of data structures to merge into target
Returns: target, with all data in args merged into it
Return type: whatever type was originally passed in
bumblebee_status.util.cli module¶
-
bumblebee_status.util.cli.
execute
(cmd, wait=True, ignore_errors=False, include_stderr=False, env=None, return_exitcode=False, shell=False)¶ Executes a commandline utility and returns its output
Parameters: - cmd – the command (as string) to execute, returns the program’s output
- wait – set to True to wait for command completion, False to return immediately, defaults to True
- ignore_errors – set to True to return a string when an exception is thrown, otherwise might throw, defaults to False
- include_stderr – set to True to include stderr output in the return value, defaults to False
- env – provide a dict here to specify a custom execution environment, defaults to None
- return_exitcode – set to True to return a pair, where the first member is the exit code and the message the second, defaults to False
- shell – set to True to run command in a separate shell, defaults to False
Raises: RuntimeError – the command either didn’t exist or didn’t exit cleanly, and ignore_errors was set to False
Returns: output of cmd, or stderr, if ignore_errors is True and the command failed; or a tuple of exitcode and the previous, if return_exitcode is set to True
Return type: string or tuple (if return_exitcode is set to True)
bumblebee_status.util.format module¶
-
bumblebee_status.util.format.
asbool
(val)¶ Converts a value into a boolean
Parameters: val – value to convert; accepts a wide range of possible representations, such as yes, no, true, false, on, off Returns: True of val maps to true, False otherwise Return type: boolean
-
bumblebee_status.util.format.
asint
(val, minimum=None, maximum=None)¶ Converts a value into an integer
Parameters: - val – value to convert
- minimum – if specified, this determines the lower boundary for the returned value, defaults to None
- maximum – if specified, this determines the upper boundary for the returned value, defaults to None
Returns: integer representation of value
Return type: integer
-
bumblebee_status.util.format.
aslist
(val)¶ Converts a comma-separated value string into a list
Parameters: val – value to convert, either a single value or a comma-separated string Returns: list representation of the value passed in Return type: list of strings
-
bumblebee_status.util.format.
astemperature
(val, unit='metric')¶ Returns a temperature representation of the input value
Parameters: - val – value to format, must be convertible into an integer
- unit – unit of the input value, supported units are: metric, kelvin, imperial, defaults to metric
Returns: temperature representation of the input value
Return type: string
-
bumblebee_status.util.format.
byte
(val, fmt='{:.2f}', sys='IEC')¶ Returns a byte representation of the input value
Parameters: - val – value to format, must be convertible into a float
- fmt – optional output format string, defaults to {:.2f}
- sys – optional unit system specifier - SI (kilo, Mega, Giga, …) or IEC (kibi, Mebi, Gibi, …) - defaults to IEC
Returns: byte representation (e.g. <X> KiB, GiB, etc.) of the input value
Return type: string
-
bumblebee_status.util.format.
duration
(duration, compact=False, unit=False)¶ Returns a time duration string representing the input value
Parameters: - duration – value to format, must be convertible into an into
- compact – whether to show also seconds, defaults to False
- unit – whether to display he unit, defaults to False
Returns: duration representation (e.g. 5:02s) of the input value
Return type: string
-
bumblebee_status.util.format.
seconds
(duration)¶ Returns a time duration (in seconds) representation of the input value
Parameters: duration – value to format (e.g. 5h30m2s) Returns: duration in seconds of the input value Return type: float
bumblebee_status.util.graph module¶
-
class
bumblebee_status.util.graph.
BrailleGraph
(values)¶ Bases:
object
-
chars
= {(0, 0): ' ', (0, 1): '⢀', (0, 2): '⢠', (0, 3): '⢰', (0, 4): '⢸', (1, 0): '⡀', (1, 1): '⣀', (1, 2): '⣠', (1, 3): '⣰', (1, 4): '⣸', (2, 0): '⡄', (2, 1): '⣄', (2, 2): '⣤', (2, 3): '⣴', (2, 4): '⣼', (3, 0): '⡆', (3, 1): '⣆', (3, 2): '⣦', (3, 3): '⣶', (3, 4): '⣾', (4, 0): '⡇', (4, 1): '⣇', (4, 2): '⣧', (4, 3): '⣷', (4, 4): '⣿'}¶ This class is a helper class used to draw braille graphs - please use braille directly
Parameters: values – values to draw
-
get_chars
()¶
-
static
get_height
(value, unit)¶
-
get_steps
()¶
-
-
class
bumblebee_status.util.graph.
HBar
(value)¶ Bases:
bumblebee_status.util.graph.Bar
-
bars
= ['▁', '▂', '▃', '▄', '▅', '▆', '▇', '█']¶ This class is a helper class used to draw horizontal bars - please use hbar directly
Parameters: value – percentage value to draw (float, between 0 and 100)
-
get_char
()¶ Returns the character representing the current object’s value
Returns: character representing the value passed during initialization Return type: string with one character
-
-
class
bumblebee_status.util.graph.
VBar
(value, width=1)¶ Bases:
bumblebee_status.util.graph.Bar
-
bars
= ['▏', '▎', '▍', '▌', '▋', '▊', '▉', '█']¶ This class is a helper class used to draw vertical bars - please use vbar directly
Parameters: - value – percentage value to draw (float, between 0 and 100)
- width – maximum width of the bar in characters
-
get_chars
()¶
-
-
bumblebee_status.util.graph.
braille
(values)¶
-
bumblebee_status.util.graph.
hbar
(value)¶ “Retrieves the horizontal bar character representing the input value
Parameters: value – percentage value to draw (float, between 0 and 100) Returns: character representing the value passed during initialization Return type: string with one character
-
bumblebee_status.util.graph.
vbar
(value, width)¶ Returns the characters representing the current object’s value
Parameters: - value – percentage value to draw (float, between 0 and 100)
- width – maximum width of the bar in characters
Returns: characters representing the value passed during initialization
Return type: string
bumblebee_status.util.location module¶
Retrieves location information from an external service and caches it for 12h (retries are done every 30m in case of problems)
- Right now, it uses (in order of preference):
- http://free.ipwhois.io/ - 10k free requests/month
- http://ipapi.co/ - 30k free requests/month
- http://ip-api.com/ - ~2m free requests/month
-
bumblebee_status.util.location.
city_name
()¶ Returns the current city name
Returns: city name Return type: string
-
bumblebee_status.util.location.
coordinates
()¶ Returns a latitude, longitude pair
Returns: current latitude and longitude Return type: pair of strings
-
bumblebee_status.util.location.
country
()¶ Returns the current country name
Returns: country name Return type: string
-
bumblebee_status.util.location.
country_code
()¶ Returns the current country code
Returns: country code Return type: string
-
bumblebee_status.util.location.
location_info
()¶ Returns the current location information
Returns: public IP, country name, country code, city name & coordinates Return type: dictionary
-
bumblebee_status.util.location.
public_ip
()¶ Returns the current public IP
Returns: public IP Return type: string
-
bumblebee_status.util.location.
reset
()¶ Resets the location library, ensuring that a new query will be started
bumblebee_status.util.popup module¶
Pop-up menus.
Bases:
object
Draws a hierarchical popup menu
Parameters: - parent – If given, this menu is a leave of the “parent” menu
- leave – If set to True, close this menu when mouse leaves the area (defaults to True)
bumblebee_status.util.store module¶
Store interface
Allows arbitrary classes to offer a simple get/set store interface by deriving from the Store class in this module
-
class
bumblebee_status.util.store.
Store
¶ Bases:
object
Interface for storing and retrieving simple values
-
get
(key, default=None)¶ Returns the current value for the specified key, or a default value, if the key is not set
Parameters: - key – the name of the parameter to retrieve
- default – the default value to return, defaults to None
-
set
(key, value)¶ Sets key to value, overwriting any existing data for that key
Parameters: - key – the name of the parameter to set
- value – the value to be set
-
unused_keys
()¶ Returns a list of unused keys
Returns: a list of keys that are set, but never used Return type: list of strings
-