예제 #1
0
    def test_copy_file_tree_excludes(self):
        """ Test coping file tree with excludes """
        copy_path = os.path.join(self.path, "copy_test_dir")
        copy_file_tree(self.test_dir2, copy_path)

        from filecmp import dircmp
        dcmp = dircmp(self.test_dir2, copy_path, ignore=[os.path.basename(self.test_file_5)])
        self.assertEqual(dcmp.left_list, dcmp.right_list)
예제 #2
0
    def test_copy_file_tree(self):
        """ Test coping file tree without any excludes """
        copy_path = os.path.join(self.path, "copy_test_dir")
        copy_file_tree(self.test_dir1, copy_path)

        from filecmp import dircmp
        dcmp = dircmp(self.test_dir1, copy_path)
        self.assertEqual(dcmp.left_list, dcmp.right_list)
예제 #3
0
    def copy_dir(self, src_dir):

        root_dir = self.get_root()
        src_dir = norm_path(src_dir)

        if root_dir != src_dir:
            copy_file_tree(src_dir, root_dir)
            return True
예제 #4
0
    def get(self,
            content_hash: str,
            client_options: Optional[ClientOptions] = None,
            filepath: Optional[str] = None,
            **_) -> tuple:

        from golem.core.fileshelper import copy_file_tree

        resource = self._resources[content_hash]
        path = self._paths[content_hash]
        files = [os.path.join(filepath, f) for f in resource.values()]

        if path != filepath:
            copy_file_tree(path, filepath)

        return content_hash, files
예제 #5
0
    def copy(self, src_path, dst_relative_path, task_id):

        dst_relative_path = norm_path(dst_relative_path)
        dst_path = self.get_path(dst_relative_path, task_id)
        src_path = norm_path(src_path)

        make_path_dirs(dst_path)

        if os.path.isfile(dst_path):
            os.remove(dst_path)
        elif os.path.isdir(dst_path):
            shutil.rmtree(dst_path)

        if os.path.isfile(src_path):
            shutil.copyfile(src_path, dst_path)
        elif os.path.isdir(src_path):
            copy_file_tree(src_path, dst_path)
        else:
            raise ValueError("Error reading source path: '{}'"
                             .format(src_path))
예제 #6
0
 def copy_resources(self, new_resource_dir):
     copy_file_tree(self.resource_dir, new_resource_dir)
     filenames = next(os.walk(self.resource_dir))[2]
     for f in filenames:
         os.remove(os.path.join(self.resource_dir, f))