def phymem_usage(): """Return the amount of total, used and free physical memory on the system in bytes plus the percentage usage. """ return _psplatform.phymem_usage()
REALTIME_PRIORITY_CLASS) elif sys.platform.lower().startswith("darwin"): import psutil._psosx as _psplatform elif sys.platform.lower().startswith("freebsd"): import psutil._psbsd as _psplatform else: raise NotImplementedError('platform %s is not supported' % sys.platform) __all__.extend(_psplatform.__extra__all__) NUM_CPUS = _psplatform.NUM_CPUS BOOT_TIME = _psplatform.BOOT_TIME TOTAL_PHYMEM = _psplatform.phymem_usage()[0] get_pid_list = _psplatform.get_pid_list pid_exists = _psplatform.pid_exists class Process(object): """Represents an OS process.""" def __init__(self, pid): """Create a new Process object, raises NoSuchProcess if the PID does not exist, and ValueError if the parameter is not an integer PID. """ if not isinstance(pid, int): raise ValueError("an integer is required") if not pid_exists(pid):
REALTIME_PRIORITY_CLASS) elif sys.platform.startswith("darwin"): import psutil._psosx as _psplatform elif sys.platform.startswith("freebsd"): import psutil._psbsd as _psplatform else: raise NotImplementedError('platform %s is not supported' % sys.platform) __all__.extend(_psplatform.__extra__all__) NUM_CPUS = _psplatform.NUM_CPUS BOOT_TIME = _psplatform.BOOT_TIME TOTAL_PHYMEM = _psplatform.phymem_usage()[0] class Process(object): """Represents an OS process.""" def __init__(self, pid): """Create a new Process object for the given pid. Raises NoSuchProcess if pid does not exist. """ self._pid = pid self._gone = False # platform-specific modules define an _psplatform.Process # implementation class self._platform_impl = _psplatform.Process(pid) self._last_sys_cpu_times = None