Beispiel #1
0
 def _GetConfigInstructions():
   command = _GSUTIL_PATH
   if util.IsRunningOnCrosDevice():
     command = 'HOME=%s %s' % (_CROS_GSUTIL_HOME_WAR, _GSUTIL_PATH)
   return ('To configure your credentials:\n'
           '  1. Run "%s config" and follow its instructions.\n'
           '  2. If you have a @google.com account, use that account.\n'
           '  3. For the project-id, just enter 0.' % command)
Beispiel #2
0
 def GetSystemInfo(self):
     if self._system_info_backend is None:
         self._system_info_backend = system_info_backend.SystemInfoBackend(
             self._port)
     # TODO(crbug.com/706336): Remove this condional branch once crbug.com/704024
     # is fixed.
     if util.IsRunningOnCrosDevice():
         return self._system_info_backend.GetSystemInfo(timeout=30)
     return self._system_info_backend.GetSystemInfo()
 def _GetConfigInstructions(gsutil_path):
     if SupportsProdaccess(gsutil_path) and _FindExecutableInPath(
             'prodaccess'):
         return 'Run prodaccess to authenticate.'
     else:
         if util.IsRunningOnCrosDevice():
             gsutil_path = ('HOME=%s %s' %
                            (_CROS_GSUTIL_HOME_WAR, gsutil_path))
         return (
             'To configure your credentials:\n'
             '  1. Run "%s config" and follow its instructions.\n'
             '  2. If you have a @google.com account, use that account.\n'
             '  3. For the project-id, just enter 0.' % gsutil_path)
Beispiel #4
0
def _RunCommand(args):
    # On cros device, as telemetry is running as root, home will be set to /root/,
    # which is not writable. gsutil will attempt to create a download tracker dir
    # in home dir and fail. To avoid this, override HOME dir to something writable
    # when running on cros device.
    #
    # TODO(tbarzic): Figure out a better way to handle gsutil on cros.
    #     http://crbug.com/386416, http://crbug.com/359293.
    gsutil_env = None
    if util.IsRunningOnCrosDevice():
        gsutil_env = os.environ.copy()
        gsutil_env['HOME'] = _CROS_GSUTIL_HOME_WAR

    if os.name == 'nt':
        # If Windows, prepend python. Python scripts aren't directly executable.
        args = [sys.executable, _GSUTIL_PATH] + args
    else:
        # Don't do it on POSIX, in case someone is using a shell script to redirect.
        args = [_GSUTIL_PATH] + args
        _EnsureExecutable(_GSUTIL_PATH)

    gsutil = subprocess.Popen(args,
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE,
                              env=gsutil_env)
    stdout, stderr = gsutil.communicate()

    if gsutil.returncode:
        if stderr.startswith(
            ('You are attempting to access protected data with no configured',
             'Failure: No handler was ready to authenticate.')):
            raise CredentialsError()
        if ('status=403' in stderr or 'status 403' in stderr
                or '403 Forbidden' in stderr):
            raise PermissionError()
        if (stderr.startswith('InvalidUriError') or 'No such object' in stderr
                or 'No URLs matched' in stderr
                or 'One or more URLs matched no' in stderr):
            raise NotFoundError(stderr)
        if '500 Internal Server Error' in stderr:
            raise ServerError(stderr)
        raise CloudStorageError(stderr)

    return stdout
def _InitHostPlatformIfNeeded():
    global _host_platform
    if _host_platform:
        return
    if util.IsRunningOnCrosDevice():
        from telemetry.core.platform import cros_platform_backend
        backend = cros_platform_backend.CrosPlatformBackend()
    elif sys.platform.startswith('linux'):
        from telemetry.core.platform import linux_platform_backend
        backend = linux_platform_backend.LinuxPlatformBackend()
    elif sys.platform == 'darwin':
        from telemetry.core.platform import mac_platform_backend
        backend = mac_platform_backend.MacPlatformBackend()
    elif sys.platform == 'win32':
        from telemetry.core.platform import win_platform_backend
        backend = win_platform_backend.WinPlatformBackend()
    else:
        raise NotImplementedError()

    _host_platform = Platform(backend)
Beispiel #6
0
 def GetSystemInfo(self):
     # TODO(crbug.com/706336): Remove this condional branch once crbug.com/704024
     # is fixed.
     if util.IsRunningOnCrosDevice():
         return self.devtools_client.GetSystemInfo(timeout=30)
     return self.devtools_client.GetSystemInfo(timeout=10)
 def IsPlatformBackendForHost(cls):
     return util.IsRunningOnCrosDevice()
 def IsPlatformBackendForHost(cls):
     return sys.platform.startswith(
         'linux') and not util.IsRunningOnCrosDevice()