geowatch.utils.util_hardware module

See: ~/code/watch/geowatch/utils/process_context.py

geowatch.utils.util_hardware.get_cpu_mem_info()[source]
geowatch.utils.util_hardware.get_cpu_info()[source]
geowatch.utils.util_hardware.get_mem_info(with_units=False)[source]

Memory info is returned in bytes.

Todo

  • [ ] Should we use pint to give these numbers units?

References

https://psutil.readthedocs.io/en/latest/#psutil.virtual_memory

Example

>>> from geowatch.utils import util_hardware
>>> import ubelt as ub
>>> mem_info = util_hardware.get_mem_info(with_units=1)
>>> print(f'mem_info = {ub.urepr(mem_info, nl=1)}')

total = mem_info[‘used’] tmp = (

# mem_info[‘cached’] + # mem_info[‘buffers’] + # mem_info[‘inactive’] + mem_info[‘slab’])

green = total - tmp print(f’green={green}’) percent = ((green / mem_info[‘total’]) * 100).m print(f’percent={percent}’)

geowatch.utils.util_hardware.disk_info_of_path(path)[source]

Get disk info wrt where a file lives

WIP - needs more work

CommandLine

xdoctest -m geowatch.utils.util_hardware disk_info_of_path
Returns:

dict - dictionary of information

Example

>>> from geowatch.utils.util_hardware import *  # NOQA
>>> path = '.'
>>> x = disk_info_of_path(path)
>>> import ubelt as ub
>>> print(ub.urepr(x))

Todo

  • [ ] Handle btrfs

  • [ ] Handle whatever AWS uses

  • [ ] Use udisksctl or udevadm

References

https://askubuntu.com/questions/609708/how-to-find-hard-drive-brand-name-or-model https://stackoverflow.com/questions/38615464/how-to-get-device-name-on-which-a-file-is-located-from-its-path-in-c