コード例 #1
0
    def setIsMoblab(self, is_moblab):
        """Set utils.is_moblab result.

        @param is_moblab: Value to have utils.is_moblab to return.
        """
        self.mox.StubOutWithMock(utils, 'is_moblab')
        utils.is_moblab().AndReturn(is_moblab)
コード例 #2
0
 def process_request(self, request):
     # look for a username from Apache
     user = request.META.get('REMOTE_USER')
     if user is None:
         # look for a user in headers.  This is insecure but
         # it's our temporarily solution for CLI auth.
         user = request.META.get('HTTP_AUTHORIZATION')
     if user is None:
         # no user info - assume we're in development mode
         user = constants.MOBLAB_USER if utils.is_moblab() else DEBUG_USER
     thread_local.set_user(user)
コード例 #3
0
def _start_servod(machine):
    """Try to start servod in moblab if it's not already running or running with
    different board or port.

    @param machine: Name of the dut used for test.
    """
    if not utils.is_moblab():
        return

    logging.debug('Trying to start servod.')
    try:
        afe = frontend.AFE()
        board = server_utils.get_board_from_afe(machine, afe)
        hosts = afe.get_hosts(hostname=machine)
        servo_host = hosts[0].attributes.get('servo_host', None)
        servo_port = hosts[0].attributes.get('servo_port', 9999)
        if not servo_host in ['localhost', '127.0.0.1']:
            logging.warn('Starting servod is aborted. The dut\'s servo_host '
                         'attribute is not set to localhost.')
            return
    except (urllib2.HTTPError, urllib2.URLError):
        # Ignore error if RPC failed to get board
        logging.error('Failed to get board name from AFE. Start servod is '
                      'aborted')
        return

    try:
        pid = utils.run('pgrep servod').stdout
        cmd_line = utils.run('ps -fp %s' % pid).stdout
        if ('--board %s' % board in cmd_line
                and '--port %s' % servo_port in cmd_line):
            logging.debug(
                'Servod is already running with given board and port.'
                ' There is no need to restart servod.')
            return
        logging.debug('Servod is running with different board or port. '
                      'Stopping existing servod.')
        utils.run('sudo stop servod')
    except error.CmdError:
        # servod is not running.
        pass

    try:
        utils.run(START_SERVOD_CMD % (board, servo_port))
        logging.debug('Servod is started')
    except error.CmdError as e:
        logging.error('Servod failed to be started, error: %s', e)
コード例 #4
0
 def verify(*args, **kwargs):
     if not utils.is_moblab():
         raise error.RPCException('RPC: %s can only run on Moblab Systems!',
                                  func.__name__)
     return func(*args, **kwargs)