CPU frequency might be reported as None
Don't die when that's the case.
This commit is contained in:
parent
4a5308b4ab
commit
26789a2bb7
1 changed files with 12 additions and 3 deletions
|
|
@ -75,9 +75,18 @@ class EnvironmentDetector(object):
|
|||
return result
|
||||
|
||||
def _detect_hardware(self):
|
||||
return dict(cores=psutil.cpu_count(),
|
||||
freq=psutil.cpu_freq().max,
|
||||
ram=get_formatted_size(psutil.virtual_memory().total))
|
||||
cores = psutil.cpu_count()
|
||||
cpu_freq = psutil.cpu_freq()
|
||||
ram = psutil.virtual_memory()
|
||||
|
||||
result = dict()
|
||||
if cores:
|
||||
result["cores"] = cores
|
||||
if cpu_freq and hasattr(cpu_freq, "max"):
|
||||
result["freq"] = cpu_freq.max
|
||||
if ram and hasattr(ram, "total"):
|
||||
result["ram"] = ram.total
|
||||
return result
|
||||
|
||||
def _detect_from_plugins(self):
|
||||
result = dict()
|
||||
|
|
|
|||
Loading…
Reference in a new issue