1# Copyright 2013 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4from telemetry.core import gpu_info
5
6
7class SystemInfo(object):
8  """Provides low-level system information."""
9
10  def __init__(self, model_name, gpu_dict):
11    if (model_name == None) or (gpu_dict == None):
12      raise Exception("Missing model_name or gpu_dict argument")
13    self._model_name = model_name
14    self._gpu = gpu_info.GPUInfo.FromDict(gpu_dict)
15
16  @classmethod
17  def FromDict(cls, attrs):
18    """Constructs a SystemInfo from a dictionary of attributes.
19       Attributes currently required to be present in the dictionary:
20
21         model_name (string): a platform-dependent string
22           describing the model of machine, or the empty string if not
23           supported.
24         gpu (object containing GPUInfo's required attributes)
25    """
26    return cls(attrs["model_name"], attrs["gpu"])
27
28  @property
29  def model_name(self):
30    """A string describing the machine model.
31
32       This is a highly platform-dependent value and not currently
33       specified for any machine type aside from Macs. On Mac OS, this
34       is the model identifier, reformatted slightly; for example,
35       'MacBookPro 10.1'."""
36    return self._model_name
37
38  @property
39  def gpu(self):
40    """A GPUInfo object describing the graphics processor(s) on the system."""
41    return self._gpu
42