Home | History | Annotate | Download | only in multimedia
      1 # Copyright 2015 The Chromium OS 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.
      4 
      5 """An adapter to remotely access the system facade on DUT."""
      6 
      7 
      8 class SystemFacadeRemoteAdapter(object):
      9     """SystemFacadeRemoteAdapter is an adapter to remotely control DUT system.
     10 
     11     The Autotest host object representing the remote DUT, passed to this
     12     class on initialization, can be accessed from its _client property.
     13 
     14     """
     15     def __init__(self, host, remote_facade_proxy):
     16         """Construct an SystemFacadeRemoteAdapter.
     17 
     18         @param host: Host object representing a remote host.
     19         @param remote_facade_proxy: RemoteFacadeProxy object.
     20 
     21         """
     22         self._client = host
     23         self._proxy = remote_facade_proxy
     24 
     25 
     26     @property
     27     def _system_proxy(self):
     28         """Gets the proxy to DUT system facade.
     29 
     30         @return XML RPC proxy to DUT system facade.
     31 
     32         """
     33         return self._proxy.system
     34 
     35 
     36     def set_scaling_governor_mode(self, index, mode):
     37         """Set mode of CPU scaling governor on one CPU of DUT.
     38 
     39         @param index: CPU index starting from 0.
     40 
     41         @param mode: Mode of scaling governor, accept 'interactive' or
     42                      'performance'.
     43 
     44         @returns: The original mode.
     45 
     46         """
     47         return self._system_proxy.set_scaling_governor_mode(index, mode)
     48 
     49 
     50     def get_cpu_usage(self):
     51         """Returns machine's CPU usage.
     52 
     53         Returns:
     54             A dictionary with 'user', 'nice', 'system' and 'idle' values.
     55             Sample dictionary:
     56             {
     57                 'user': 254544,
     58                 'nice': 9,
     59                 'system': 254768,
     60                 'idle': 2859878,
     61             }
     62         """
     63         return self._system_proxy.get_cpu_usage()
     64 
     65 
     66     def compute_active_cpu_time(self, cpu_usage_start, cpu_usage_end):
     67         """Computes the fraction of CPU time spent non-idling.
     68 
     69         This function should be invoked using before/after values from calls to
     70         get_cpu_usage().
     71         """
     72         return self._system_proxy.compute_active_cpu_time(cpu_usage_start,
     73                                                           cpu_usage_end)
     74 
     75 
     76     def get_mem_total(self):
     77         """Returns the total memory available in the system in MBytes."""
     78         return self._system_proxy.get_mem_total()
     79 
     80 
     81     def get_mem_free(self):
     82         """Returns the currently free memory in the system in MBytes."""
     83         return self._system_proxy.get_mem_free()
     84 
     85 
     86     def get_ec_temperatures(self):
     87         """Uses ectool to return a list of all sensor temperatures in Celsius.
     88         """
     89         return self._system_proxy.get_ec_temperatures()
     90 
     91 
     92     def get_current_board(self):
     93         """Returns the current device board name."""
     94         return self._system_proxy.get_current_board()
     95 
     96 
     97     def get_chromeos_release_version(self):
     98         """Returns chromeos version in device under test as string. None on
     99         fail.
    100         """
    101         return self._system_proxy.get_chromeos_release_version()
    102