示例#1
0
def FindAllAvailableBrowsers(finder_options, device):
    """Finds all available CrOS browsers, locally and remotely."""
    browsers = []
    if not isinstance(device, cros_device.CrOSDevice):
        return browsers

    if cros_device.IsRunningOnCrOS():
        browsers = [
            PossibleCrOSBrowser('system',
                                finder_options,
                                platform_module.GetHostPlatform(),
                                is_guest=False),
            PossibleCrOSBrowser('system-guest',
                                finder_options,
                                platform_module.GetHostPlatform(),
                                is_guest=True)
        ]

    # Check ssh
    try:
        plat = platform_module.GetPlatformForDevice(device, finder_options)
    except cros_interface.LoginException as ex:
        if isinstance(ex, cros_interface.KeylessLoginRequiredException):
            logging.warn(
                'Could not ssh into %s. Your device must be configured',
                finder_options.cros_remote)
            logging.warn('to allow passwordless login as root.')
            logging.warn('For a test-build device, pass this to your script:')
            logging.warn('   --identity $(CHROMITE)/ssh_keys/testing_rsa')
            logging.warn('')
            logging.warn('For a developer-mode device, the steps are:')
            logging.warn(
                ' - Ensure you have an id_rsa.pub (etc) on this computer')
            logging.warn(' - On the chromebook:')
            logging.warn('   -  Control-Alt-T; shell; sudo -s')
            logging.warn('   -  openssh-server start')
            logging.warn('   -  scp <this machine>:.ssh/id_rsa.pub /tmp/')
            logging.warn('   -  mkdir /root/.ssh')
            logging.warn('   -  chown go-rx /root/.ssh')
            logging.warn(
                '   -  cat /tmp/id_rsa.pub >> /root/.ssh/authorized_keys')
            logging.warn('   -  chown 0600 /root/.ssh/authorized_keys')
        raise browser_finder_exceptions.BrowserFinderException(str(ex))

    browsers.extend([
        PossibleCrOSBrowser('cros-chrome',
                            finder_options,
                            plat,
                            is_guest=False),
        PossibleCrOSBrowser('lacros-chrome',
                            finder_options,
                            plat,
                            is_guest=False),
        PossibleCrOSBrowser('cros-chrome-guest',
                            finder_options,
                            plat,
                            is_guest=True)
    ])
    return browsers
示例#2
0
def FindAllAvailableBrowsers(finder_options, device):
    """Finds all available CrOS browsers, locally and remotely."""
    if not isinstance(device, cros_device.CrOSDevice):
        return []

    if cros_device.IsRunningOnCrOS():
        return [
            PossibleCrOSBrowser('system',
                                finder_options,
                                platform_module.GetHostPlatform(),
                                is_guest=False),
            PossibleCrOSBrowser('system-guest',
                                finder_options,
                                platform_module.GetHostPlatform(),
                                is_guest=True)
        ]

    # Check ssh
    try:
        # Retries required because of DNS issue in the lab documented in
        # http://crbug/484726
        retries = 0
        while True:
            try:
                platform = platform_module.GetPlatformForDevice(
                    device, finder_options)
                break
            except cros_interface.DNSFailureException, ex:
                logging.warn('DNS Failure: %s', str(ex))
                retries += 1
                if retries > 1:
                    raise ex
    except cros_interface.LoginException, ex:
        if isinstance(ex, cros_interface.KeylessLoginRequiredException):
            logging.warn(
                'Could not ssh into %s. Your device must be configured',
                finder_options.cros_remote)
            logging.warn('to allow passwordless login as root.')
            logging.warn('For a test-build device, pass this to your script:')
            logging.warn('   --identity $(CHROMITE)/ssh_keys/testing_rsa')
            logging.warn('')
            logging.warn('For a developer-mode device, the steps are:')
            logging.warn(
                ' - Ensure you have an id_rsa.pub (etc) on this computer')
            logging.warn(' - On the chromebook:')
            logging.warn('   -  Control-Alt-T; shell; sudo -s')
            logging.warn('   -  openssh-server start')
            logging.warn('   -  scp <this machine>:.ssh/id_rsa.pub /tmp/')
            logging.warn('   -  mkdir /root/.ssh')
            logging.warn('   -  chown go-rx /root/.ssh')
            logging.warn(
                '   -  cat /tmp/id_rsa.pub >> /root/.ssh/authorized_keys')
            logging.warn('   -  chown 0600 /root/.ssh/authorized_keys')
            logging.warn('There, that was easy!')
            logging.warn('')
            logging.warn('P.S. Please, tell your manager how INANE this is.')
        raise browser_finder_exceptions.BrowserFinderException(str(ex))
示例#3
0
def _HasValidAdb():
    """Returns true if adb is present.

  Note that this currently will return True even if the adb that's present
  cannot run on this system.
  """
    if os.name != 'posix' or cros_device.IsRunningOnCrOS():
        return False

    try:
        adb_path = adb_wrapper.AdbWrapper.GetAdbPath()
    except device_errors.NoAdbError:
        return False

    if os.path.isabs(adb_path) and not os.path.exists(adb_path):
        return False

    return True
示例#4
0
def CanFindAvailableBrowsers(finder_options):
    return (cros_device.IsRunningOnCrOS() or finder_options.cros_remote
            or cros_interface.HasSSH())
示例#5
0
def SelectDefaultBrowser(possible_browsers):
    if cros_device.IsRunningOnCrOS():
        for b in possible_browsers:
            if b.browser_type == 'system':
                return b
    return None
示例#6
0
def FindAllBrowserTypes(_):
  return [
      'cros-chrome',
      'cros-chrome-guest',
      'system',
      'system-guest',
  ]

def FindAllAvailableBrowsers(finder_options, presentation.device):
  """Finds all available CrOS browsers, locally and remotely."""
  browsers = []
  if not isinstance(presentation.device, cros_device.CrOSDevice):
    return browsers

  if cros_device.IsRunningOnCrOS():
    browsers = [PossibleCrOSBrowser('system', finder_options,
                                    platform_module.GetHostPlatform(),
                                    is_guest=False),
                PossibleCrOSBrowser('system-guest', finder_options,
                                    platform_module.GetHostPlatform(),
                                    is_guest=True)]

  # Check ssh
  try:
    platform = platform_module.GetPlatformForDevice(presentation.device, finder_options)
  except cros_interface.LoginException, ex:
    if isinstance(ex, cros_interface.KeylessLoginRequiredException):
      logging.warn('Could not ssh into %s. Your presentation.device must be configured',
                   finder_options.cros_remote)
      logging.warn('to allow passwordless login as root.')