Home | History | Annotate | Download | only in afe
      1 #!/usr/bin/python
      2 # Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
      3 # Use of this source code is governed by a BSD-style license that can be
      4 # found in the LICENSE file.
      5 
      6 import common
      7 import autotest_lib.server.frontend as frontend
      8 from autotest_lib.frontend.afe import site_rpc_interface
      9 from autotest_lib.frontend.afe import rpc_interface
     10 
     11 class directAFE(frontend.AFE):
     12     """
     13     A wrapper for frontend.AFE which exposes all of the AFE
     14     functionality, but makes direct calls to site_rpc_interface and
     15     rpc_interface rather than making RPC calls to an RPC server.
     16     """
     17     def run(self, call, **dargs):
     18         func = None
     19 
     20         try:
     21             func = rpc_interface.__getattribute__(call)
     22         except AttributeError:
     23             pass
     24 
     25         try:
     26             func = site_rpc_interface.__getattribute__(call)
     27         except AttributeError:
     28             pass
     29 
     30         if not func:
     31             raise AttributeError('No function named %s in either '
     32                                  'rpc_interface or site_rpc_interface' % call)
     33 
     34         return func(**dargs)