コード例 #1
0
ファイル: task.py プロジェクト: neven7/pants
 def _cleanup_workdir_stale_builds(self, vts):
   # workdir_max_build_entries has been assured of not None before invoking this method.
   max_entries_per_target = max(2, self.context.options.for_global_scope().workdir_max_build_entries)
   for vt in vts:
     live_dirs = list(vt.live_dirs())
     if not live_dirs:
       continue
     root_dir = os.path.dirname(vt.results_dir)
     safe_rm_oldest_items_in_dir(root_dir, max_entries_per_target, excludes=live_dirs)
コード例 #2
0
ファイル: task.py プロジェクト: wonlay/pants
 def _cleanup_workdir_stale_builds(self, vts):
   # workdir_max_build_entries has been assured of not None before invoking this method.
   max_entries_per_target = max(2, self.context.options.for_global_scope().workdir_max_build_entries)
   for vt in vts:
     live_dirs = list(vt.live_dirs())
     if not live_dirs:
       continue
     root_dir = os.path.dirname(vt.results_dir)
     safe_rm_oldest_items_in_dir(root_dir, max_entries_per_target, excludes=live_dirs)
コード例 #3
0
ファイル: task.py プロジェクト: cheister/pants
 def _cleanup_workdir_stale_builds(self, vts):
   # workdir_max_build_entries has been assured of not None before invoking this method.
   max_entries_per_target = max(2, self.context.options.for_global_scope().workdir_max_build_entries)
   for vt in vts:
     if vt.has_results_dir:
       if vt.has_previous_results_dir:
         excludes = [vt.results_dir, vt.previous_results_dir]
       else:
         excludes = [vt.results_dir]
       root_dir = os.path.dirname(vt.results_dir)
       safe_rm_oldest_items_in_dir(root_dir, max_entries_per_target, excludes)
コード例 #4
0
  def prune(self, root):
    """Prune stale cache files

    If the option --cache-target-max-entry is greater than zero, then prune will remove all but n
    old cache files for each target/task.

    :param str root: The path under which cacheable artifacts will be cleaned
    """

    max_entries_per_target = self._max_entries_per_target
    if os.path.isdir(root) and max_entries_per_target:
      safe_rm_oldest_items_in_dir(root, max_entries_per_target)
コード例 #5
0
    def prune(self, root):
        """Prune stale cache files

    If the option --cache-target-max-entry is greater than zero, then prune will remove all but n
    old cache files for each target/task.

    :param str root: The path under which cacheable artifacts will be cleaned
    """

        max_entries_per_target = self._max_entries_per_target
        if os.path.isdir(root) and max_entries_per_target:
            safe_rm_oldest_items_in_dir(root, max_entries_per_target)
コード例 #6
0
ファイル: task.py プロジェクト: cheister/pants
 def _cleanup_workdir_stale_builds(self, vts):
     # workdir_max_build_entries has been assured of not None before invoking this method.
     max_entries_per_target = max(
         2,
         self.context.options.for_global_scope().workdir_max_build_entries)
     for vt in vts:
         if vt.has_results_dir:
             if vt.has_previous_results_dir:
                 excludes = [vt.results_dir, vt.previous_results_dir]
             else:
                 excludes = [vt.results_dir]
             root_dir = os.path.dirname(vt.results_dir)
             safe_rm_oldest_items_in_dir(root_dir, max_entries_per_target,
                                         excludes)
コード例 #7
0
ファイル: test_dirutil.py プロジェクト: Xaelias/pants
    def test_safe_rm_oldest_items_in_dir_with_excludes(self):
        with temporary_dir() as td:
            touch(os.path.join(td, 'file1'))
            touch(os.path.join(td, 'file2'))
            touch(os.path.join(td, 'file3'))
            # Time modified is only accurate to second.
            time.sleep(1.1)
            touch(os.path.join(td, 'file4'))

            excludes = [os.path.join(td, 'file1'), os.path.join(td, 'file2')]
            safe_rm_oldest_items_in_dir(td, 1, excludes)

            self.assertTrue(os.path.exists(os.path.join(td, 'file1')))
            self.assertTrue(os.path.exists(os.path.join(td, 'file2')))
            self.assertTrue(os.path.exists(os.path.join(td, 'file4')))

            self.assertFalse(os.path.exists(os.path.join(td, 'file3')))
コード例 #8
0
ファイル: test_dirutil.py プロジェクト: benjyw/pants
  def test_safe_rm_oldest_items_in_dir_with_excludes(self):
    with temporary_dir() as td:
      touch(os.path.join(td, 'file1'))
      touch(os.path.join(td, 'file2'))
      touch(os.path.join(td, 'file3'))
      # Time modified is only accurate to second.
      time.sleep(1.1)
      touch(os.path.join(td, 'file4'))

      excludes = [os.path.join(td, 'file1'),
                  os.path.join(td, 'file2')]
      safe_rm_oldest_items_in_dir(td, 1, excludes)

      self.assertTrue(os.path.exists(os.path.join(td, 'file1')))
      self.assertTrue(os.path.exists(os.path.join(td, 'file2')))
      self.assertTrue(os.path.exists(os.path.join(td, 'file4')))

      self.assertFalse(os.path.exists(os.path.join(td, 'file3')))
コード例 #9
0
ファイル: test_dirutil.py プロジェクト: triplequote/pants
    def test_safe_rm_oldest_items_in_dir(self) -> None:
        with temporary_dir() as td:
            touch(os.path.join(td, 'file1'))
            safe_mkdir(os.path.join(td, 'file2'))
            # Time modified is only accurate to second.
            time.sleep(1.1)
            touch(os.path.join(td, 'file3'))
            touch(os.path.join(td, 'file4'))
            safe_mkdir(os.path.join(td, 'file5'))

            safe_rm_oldest_items_in_dir(td, 3)

            self.assertFalse(os.path.exists(os.path.join(td, 'file1')))
            self.assertFalse(os.path.exists(os.path.join(td, 'file2')))

            self.assertTrue(os.path.exists(os.path.join(td, 'file3')))
            self.assertTrue(os.path.exists(os.path.join(td, 'file4')))
            self.assertTrue(os.path.exists(os.path.join(td, 'file5')))
コード例 #10
0
ファイル: test_dirutil.py プロジェクト: Xaelias/pants
 def test_safe_rm_oldest_items_in_dir_noop(self):
     with temporary_dir() as td:
         safe_rm_oldest_items_in_dir(td, 1)
         touch(os.path.join(td, 'file1'))
         self.assertEqual(len(os.listdir(td)), 1)
コード例 #11
0
ファイル: test_dirutil.py プロジェクト: benjyw/pants
 def test_safe_rm_oldest_items_in_dir_noop(self):
   with temporary_dir() as td:
     safe_rm_oldest_items_in_dir(td, 1)
     touch(os.path.join(td, 'file1'))
     self.assertEqual(len(os.listdir(td)), 1)