Beispiel #1
0
    def test_to_skip(self):
        with utils.tmp_dir():
            # Create input files and directories.
            fw = test_utils.FileWriter(os.path.join(os.getcwd(), 'input'))
            fw.mkdir('.git')
            fw.write(os.path.join('.git', 'index'))
            fw.write('somefile')
            fw.write('.DS_STORE')
            fw.write('leftover.pyc')
            fw.write('.pycfile')

            # Zip, unzip.
            zip_utils.zip('input',
                          'test.zip',
                          to_skip=['.git', '.DS*', '*.pyc'])
            zip_utils.unzip('test.zip', 'output')

            # Remove the files/dirs we don't expect to see in output, so that we can
            # use self._compare_trees to check the results.
            fw.remove(os.path.join('.git', 'index'))
            fw.remove('.git')
            fw.remove('.DS_STORE')
            fw.remove('leftover.pyc')

            # Compare results.
            test_utils.compare_trees(self, 'input', 'output')
Beispiel #2
0
    def upload_new_version(self, target_dir, commit=False):
        """Upload a new version and update the version file for the asset."""
        version = self.get_next_version()
        target_dir = os.path.abspath(target_dir)
        with utils.tmp_dir():
            zip_file = os.path.join(os.getcwd(), '%d.zip' % version)
            zip_utils.zip(target_dir, zip_file, blacklist=ZIP_BLACKLIST)
            gs_path = GS_PATH_TMPL % (self._gs_subdir, str(version))
            self._gs.copy(zip_file, gs_path)

        def _write_version():
            with open(self.version_file, 'w') as f:
                f.write(str(version))
            subprocess.check_call([utils.GIT, 'add', self.version_file])

        with utils.chdir(SKIA_DIR):
            if commit:
                with utils.git_branch():
                    _write_version()
                    subprocess.check_call([
                        utils.GIT, 'commit', '-m',
                        'Update %s version' % self._name
                    ])
                    subprocess.check_call(
                        [utils.GIT, 'cl', 'upload', '--bypass-hooks'])
            else:
                _write_version()
Beispiel #3
0
 def upload(self, name, version, target_dir):
     """Upload to GS."""
     target_dir = os.path.abspath(target_dir)
     with utils.tmp_dir():
         zip_file = os.path.join(os.getcwd(), "%d.zip" % version)
         zip_utils.zip(target_dir, zip_file, blacklist=ZIP_BLACKLIST)
         gs_path = GS_PATH_TMPL % (GS_SUBDIR_TMPL % (self._gs_bucket, name), str(version))
         self.copy(zip_file, gs_path)
 def upload(self, name, version, target_dir):
   """Upload to GS."""
   target_dir = os.path.abspath(target_dir)
   with utils.tmp_dir():
     zip_file = os.path.join(os.getcwd(), '%d.zip' % version)
     zip_utils.zip(target_dir, zip_file, blacklist=ZIP_BLACKLIST)
     gs_path = GS_PATH_TMPL % (GS_SUBDIR_TMPL % (self._gs_bucket, name),
                               str(version))
     self.copy(zip_file, gs_path)
Beispiel #5
0
 def upload(self, name, version, target_dir, extra_tags=None):
     """Upload to GS."""
     target_dir = os.path.abspath(target_dir)
     with utils.tmp_dir():
         zip_file = os.path.join(os.getcwd(), '%d.zip' % version)
         zip_utils.zip(target_dir, zip_file, to_skip=PATTERNS_TO_SKIP)
         gs_path = GS_PATH_TMPL % (GS_SUBDIR_TMPL %
                                   (self._gs_bucket, name), str(version))
         self.copy(zip_file, gs_path)
Beispiel #6
0
    def test_zip_unzip(self):
        with utils.tmp_dir():
            fw = test_utils.FileWriter(os.path.join(os.getcwd(), 'input'))
            # Create input files and directories.
            fw.mkdir('mydir')
            fw.mkdir('anotherdir', 0o666)
            fw.mkdir('dir3', 0o600)
            fw.mkdir('subdir')
            fw.write('a.txt', 0o777)
            fw.write('b.txt', 0o751)
            fw.write('c.txt', 0o640)
            fw.write(os.path.join('subdir', 'd.txt'), 0o640)

            # Zip, unzip.
            zip_utils.zip('input', 'test.zip')
            zip_utils.unzip('test.zip', 'output')

            # Compare the inputs and outputs.
            test_utils.compare_trees(self, 'input', 'output')
  def test_zip_unzip(self):
    with utils.tmp_dir():
      fw = test_utils.FileWriter(os.path.join(os.getcwd(), 'input'))
      # Create input files and directories.
      fw.mkdir('mydir')
      fw.mkdir('anotherdir', 0666)
      fw.mkdir('dir3', 0600)
      fw.mkdir('subdir')
      fw.write('a.txt', 0777)
      fw.write('b.txt', 0751)
      fw.write('c.txt', 0640)
      fw.write(os.path.join('subdir', 'd.txt'), 0640)

      # Zip, unzip.
      zip_utils.zip('input', 'test.zip')
      zip_utils.unzip('test.zip', 'output')

      # Compare the inputs and outputs.
      test_utils.compare_trees(self, 'input', 'output')
  def test_blacklist(self):
    with utils.tmp_dir():
      # Create input files and directories.
      fw = test_utils.FileWriter(os.path.join(os.getcwd(), 'input'))
      fw.mkdir('.git')
      fw.write(os.path.join('.git', 'index'))
      fw.write('somefile')
      fw.write('.DS_STORE')
      fw.write('leftover.pyc')
      fw.write('.pycfile')

      # Zip, unzip.
      zip_utils.zip('input', 'test.zip', blacklist=['.git', '.DS*', '*.pyc'])
      zip_utils.unzip('test.zip', 'output')

      # Remove the files/dirs we don't expect to see in output, so that we can
      # use self._compare_trees to check the results.
      fw.remove(os.path.join('.git', 'index'))
      fw.remove('.git')
      fw.remove('.DS_STORE')
      fw.remove('leftover.pyc')

      # Compare results.
      test_utils.compare_trees(self, 'input', 'output')
Beispiel #9
0
  def upload_new_version(self, target_dir, commit=False):
    """Upload a new version and update the version file for the asset."""
    version = self.get_next_version()
    target_dir = os.path.abspath(target_dir)
    with utils.tmp_dir():
      zip_file = os.path.join(os.getcwd(), '%d.zip' % version)
      zip_utils.zip(target_dir, zip_file, blacklist=ZIP_BLACKLIST)
      gs_path = GS_PATH_TMPL % (self._gs_subdir, str(version))
      self._gs.copy(zip_file, gs_path)

    def _write_version():
      with open(self.version_file, 'w') as f:
        f.write(str(version))
      subprocess.check_call([utils.GIT, 'add', self.version_file])

    with utils.chdir(SKIA_DIR):
      if commit:
        with utils.git_branch():
          _write_version()
          subprocess.check_call([
              utils.GIT, 'commit', '-m', 'Update %s version' % self._name])
          subprocess.check_call([utils.GIT, 'cl', 'upload', '--bypass-hooks'])
      else:
        _write_version()
Beispiel #10
0
 def test_nonexistent_dir(self):
     with utils.tmp_dir():
         with self.assertRaises(IOError):
             zip_utils.zip('input', 'test.zip')
 def test_nonexistent_dir(self):
   with utils.tmp_dir():
     with self.assertRaises(IOError):
       zip_utils.zip('input', 'test.zip')