Ejemplo n.º 1
0
    def testTransform(self, binpath, relpath):
        # pylint: disable=line-too-long
        relpath.return_value = 'https://glazier'
        binpath.return_value = 'https://glazier/bin/'

        result = download.Transform(r'sccm.x86_64.1.00.1337\#13371337.exe',
                                    self.buildinfo)
        self.assertEqual(result, 'sccm.x86_64.1.00.1337#13371337.exe')

        result = download.Transform(
            r'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -File #My-Script.ps1 -Verbose',
            self.buildinfo)
        self.assertEqual(
            result,
            r'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -File https://glazier/My-Script.ps1 -Verbose'
        )

        result = download.Transform(
            r'@Corp/install/1.0.0/installer.exe sccm.x86_64.1.00.1337\@13371337.exe',
            self.buildinfo)
        self.assertEqual(
            result,
            'https://glazier/bin/Corp/install/1.0.0/installer.exe [email protected]'
        )

        result = download.Transform(
            r'C:\Windows\System32\msiexec.exe /i @Google/Chrome/1.3.3.7/googlechromestandaloneenterprise64.msi /qb /norestart',
            self.buildinfo)
        self.assertEqual(
            result,
            r'C:\Windows\System32\msiexec.exe /i https://glazier/bin/Google/Chrome/1.3.3.7/googlechromestandaloneenterprise64.msi /qb /norestart'
        )

        result = download.Transform('nothing _ here', self.buildinfo)
        self.assertEqual(result, 'nothing _ here')
Ejemplo n.º 2
0
 def testTransform(self, binpath, relpath):
     relpath.return_value = 'https://glazier'
     binpath.return_value = 'https://glazier/bin/'
     result = download.Transform('stuff#blah', self.buildinfo)
     self.assertEqual(result, 'stuffhttps://glazier/blah')
     result = download.Transform('stuff@blah', self.buildinfo)
     self.assertEqual(result, 'stuffhttps://glazier/bin/blah')
     result = download.Transform('nothing _ here', self.buildinfo)
     self.assertEqual(result, 'nothing _ here')
Ejemplo n.º 3
0
 def Run(self):
   downloader = download.Download()
   for arg in self._args:
     src = arg[0]
     dst = arg[1]
     full_url = download.Transform(src, self._build_info)
     # support legacy untagged short filenames
     if not (download.IsRemote(full_url) or download.IsLocal(full_url)):
       full_url = download.PathCompile(self._build_info, file_name=full_url)
     try:
       file_util.CreateDirectories(dst)
     except file_util.Error as e:
       raise ActionError('Could not create destination directory %s. %s' %
                         (dst, e))
     try:
       downloader.DownloadFile(full_url, dst, show_progress=True)
     except download.DownloadError as e:
       downloader.PrintDebugInfo()
       raise ActionError('Transfer error while downloading %s: %s' %
                         (full_url, str(e)))
     if len(arg) > 2 and arg[2]:
       logging.info('Verifying SHA256 hash for %s.', dst)
       hash_ok = downloader.VerifyShaHash(dst, arg[2])
       if not hash_ok:
         raise ActionError('SHA256 hash for %s was incorrect.' % dst)
Ejemplo n.º 4
0
    def CacheFromLine(self, line, build_info):
        """Downloads any files in the command line and replaces with the local path.

    Args:
      line: the command line to process as a string
      build_info: the current build information

    Returns:
      the final command line as a string; None on error

    Raises:
      CacheError: unable to download a file to the local cache
    """
        match = self._FindDownload(line)
        while match:
            dl = download.Transform(match, build_info)
            destination = self._DestinationPath(dl)
            try:
                self._downloader.DownloadFile(dl, destination)
            except download.DownloadError as e:
                self._downloader.PrintDebugInfo()
                raise CacheError('Unable to download required file %s: %s' %
                                 (dl, e))
            line = line.replace(match, destination)
            match = self._FindDownload(line)
        return line
Ejemplo n.º 5
0
  def CacheFromLine(self, line: Text,
                    build_info: 'buildinfo.BuildInfo') -> Optional[Text]:
    """Downloads any files in the command line and replaces with the local path.

    Args:
      line: the command line to process as a string
      build_info: the current build information

    Returns:
      the final command line as a string; None on error

    Raises:
      CacheError: unable to download a file to the local cache
    """
    match = self._FindDownload(line)
    while match:
      dl = download.Transform(match, build_info)
      if download.IsRemote(dl):
        destination = self._DestinationPath(build_info.CachePath(), dl)
        try:
          self._downloader.DownloadFile(dl, destination)
        except download.DownloadError as e:
          self._downloader.PrintDebugInfo()
          raise CacheError('Unable to download required file %s: %s' % (dl, e))
      else:  # bypass download for local files
        destination = dl
      line = line.replace(match, destination)
      match = self._FindDownload(line)
    return line