Bug 1240059 - Treat psutil as optional in record_resource_usage. r=gps

--HG--
extra : commitid : luOomgRgcQ
This commit is contained in:
Chris Manchester 2016-02-03 20:37:12 -08:00
Родитель 592b12bb62
Коммит 8d867f3c62
1 изменённых файлов: 14 добавлений и 4 удалений

Просмотреть файл

@ -414,17 +414,27 @@ class BuildMonitor(MozbuildObject):
# TODO: it would be nice to collect data on the storage device as well # TODO: it would be nice to collect data on the storage device as well
o['system'] = dict( o['system'] = dict(
architecture=list(platform.architecture()), architecture=list(platform.architecture()),
logical_cpu_count=psutil.cpu_count(),
machine=platform.machine(), machine=platform.machine(),
physical_cpu_count=psutil.cpu_count(logical=False),
python_version=platform.python_version(), python_version=platform.python_version(),
release=platform.release(), release=platform.release(),
system=platform.system(), system=platform.system(),
swap_total=psutil.swap_memory()[0],
version=platform.version(), version=platform.version(),
vmem_total=psutil.virtual_memory()[0],
) )
# If the imports for this file ran before the in-tree virtualenv
# was bootstrapped (for instance, for a clobber build in automation),
# psutil might not be available.
#
# Treat psutil as optional to avoid an outright failure to log resources
# in this case.
if psutil:
o['system'].update(dict(
logical_cpu_count=psutil.cpu_count(),
physical_cpu_count=psutil.cpu_count(logical=False),
swap_total=psutil.swap_memory()[0],
vmem_total=psutil.virtual_memory()[0],
))
if platform.system() == 'Linux': if platform.system() == 'Linux':
dist = list(platform.linux_distribution()) dist = list(platform.linux_distribution())
o['system']['linux_distribution'] = dist o['system']['linux_distribution'] = dist