当前位置: 首页>>代码示例>>Python>>正文


Python dir_util.copy_tree方法代码示例

本文整理汇总了Python中distutils.dir_util.copy_tree方法的典型用法代码示例。如果您正苦于以下问题:Python dir_util.copy_tree方法的具体用法?Python dir_util.copy_tree怎么用?Python dir_util.copy_tree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在distutils.dir_util的用法示例。


在下文中一共展示了dir_util.copy_tree方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import copy_tree [as 别名]
def main(self):
        self.sublconsole.showlog("start to refresh %s..." % (self.sel_dirs))
        self.meta_api = util.sf_login(self.sf_basic_config, Soap_Type=MetadataApi)
        retrive_metadata_objects = []
        for metaObj in self.meta_api.describeMetadata()["metadataObjects"]:
            if metaObj['directoryName'] in self.sel_dirs:
                retrive_metadata_objects.append(metaObj)
        if len(retrive_metadata_objects) > 0 :
            tmp_dir = self.sf_basic_config.get_tmp_dir()
            tmp_file = os.path.join(tmp_dir, "tmp_src.zip")
            tmp_src_dir = os.path.join(tmp_dir, "tmp_src")
            if os.path.exists(tmp_file):
                os.remove(tmp_file)
            if os.path.exists(tmp_src_dir):
                shutil.rmtree(tmp_src_dir)
            self.meta_api.retrieveZip(zip_file_name=tmp_file, retrive_metadata_objects=retrive_metadata_objects)
            if os.path.exists(tmp_file):
                self.meta_api.unzipfile(tmp_file, tmp_src_dir, self.settings["src_dir"])
                tmp_package_xml_path = os.path.join(tmp_src_dir, self.settings["src_dir"], "package.xml")
                if os.path.exists(tmp_package_xml_path): os.remove(tmp_package_xml_path)
                from distutils import dir_util
                dir_util.copy_tree(os.path.join(tmp_src_dir, self.settings["src_dir"]), os.path.join(self.sf_basic_config.get_src_root(), self.settings["src_dir"]))
        else:
            self.sublconsole.showlog("Sorry , Nothing to do. ") 
开发者ID:exiahuang,项目名称:SalesforceXyTools,代码行数:26,代码来源:main_metadata.py

示例2: update_pipe_project

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import copy_tree [as 别名]
def update_pipe_project(self):

        if os.path.exists(self.dst_pipe_template_path):
            logging.info('\n\n++++++++++++++++++++++\n\n')
            for pipe in self.pipes:
                if not self.checker.check(pipe):
                    logging.error('Pipeline was not updated!')
                    return False
            for pipe in self.pipes:
                self.update_pipe(pipe)
            dir_util.copy_tree(self.src_pipe_template_path, self.dst_pipe_template_path)
            
            logging.info("Copyed pipeline template dir from %s to %s"%(self.src_pipe_template_path,
                                                    self.dst_pipe_template_path))
        else:
            logging.warning(('Cannot update. No such pipe project: *{}*. '
                            'Maybe you want to import a pipeline instead ' 
                            'of updating it.').format(self.namespace)) 
开发者ID:l3p-cv,项目名称:lost,代码行数:20,代码来源:template_import.py

示例3: start_import

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import copy_tree [as 别名]
def start_import(self):
        logging.info('\n\n++++++++++++++++++++++ \n\n')
        logging.info('Start pipe project import for: {}'.format(self.src_pipe_template_path))
        for pipe in self.pipes:
            if not self.checker.check(pipe):
                logging.error('Wrong pipeline definition! Did not import pipe project!')
                return False
        if os.path.exists(self.dst_pipe_template_path):
            logging.warning('Cannot import pipeline!')
            logging.warning('Pipe Template Dir already exist: {}'.format(
                self.dst_pipe_template_path
            ))
            return
        dir_util.copy_tree(self.src_pipe_template_path, self.dst_pipe_template_path)
        logging.info("Copyed pipeline template dir from %s to %s"%(self.src_pipe_template_path,
                                                    self.dst_pipe_template_path))
        for pipe in self.pipes:
            self.import_pipe(pipe) 
开发者ID:l3p-cv,项目名称:lost,代码行数:20,代码来源:template_import.py

示例4: test_copy_tree_verbosity

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import copy_tree [as 别名]
def test_copy_tree_verbosity(self):

        mkpath(self.target, verbose=0)

        copy_tree(self.target, self.target2, verbose=0)
        self.assertEqual(self._logs, [])

        remove_tree(self.root_target, verbose=0)

        mkpath(self.target, verbose=0)
        a_file = os.path.join(self.target, 'ok.txt')
        with open(a_file, 'w') as f:
            f.write('some content')

        wanted = ['copying %s -> %s' % (a_file, self.target2)]
        copy_tree(self.target, self.target2, verbose=1)
        self.assertEqual(self._logs, wanted)

        remove_tree(self.root_target, verbose=0)
        remove_tree(self.target2, verbose=0) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:22,代码来源:test_dir_util.py

示例5: copy_to_labview_dir

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import copy_tree [as 别名]
def copy_to_labview_dir(self, source, relative_destination):
        labview_path = os.path.join(self.path, relative_destination)
        self._helpers.copy_tree(source, labview_path)
        self._helpers.make_writable(labview_path)
        return labview_path 
开发者ID:ni,项目名称:python_labview_automation,代码行数:7,代码来源:labview.py

示例6: copy_tree

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import copy_tree [as 别名]
def copy_tree(self, source, destination):
        copy_tree(source, destination) 
开发者ID:ni,项目名称:python_labview_automation,代码行数:4,代码来源:labview.py

示例7: copytree

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import copy_tree [as 别名]
def copytree(a, b):
    """shutil's copytree is dumb so use distutils."""
    return dir_util.copy_tree(a, b) 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:5,代码来源:pdos.py

示例8: build_template

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import copy_tree [as 别名]
def build_template(temp_dir):
    """
    Create HTML file with supporting JS and CSS files in a given directory.
    :param temp_dir: string with path to temp directory in which the html file should be built
    """
    dir_util.copy_tree(STATIC_TEMPLATE_LIB, temp_dir)
    dir_util.copy_tree(STATIC_PATH_LIB, os.path.join(
        temp_dir, STATIC_PATH_TEMP))

    # Move association file to root of temporary directory.
    copyfile(os.path.join(temp_dir, ASSOCIATION_PATH_IN_STATIC),
             os.path.join(temp_dir, ASSOCIATION_PATH_IN_ROOT)) 
开发者ID:gradio-app,项目名称:gradio-UI,代码行数:14,代码来源:networking.py

示例9: datadir

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import copy_tree [as 别名]
def datadir(tmpdir, request):
    '''
    Fixture responsible for searching a folder with the same name of test
    module and, if available, moving all contents to a temporary directory so
    tests can use them freely.
    '''
    filename = request.module.__file__
    test_dir, _ = os.path.splitext(filename)

    if os.path.isdir(test_dir):
        dir_util.copy_tree(test_dir, bytes(tmpdir))

    return tmpdir 
开发者ID:cea-hpc,项目名称:pcocc,代码行数:15,代码来源:conftest.py

示例10: copy_tree

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import copy_tree [as 别名]
def copy_tree(self, infile, outfile,
                   preserve_mode=1, preserve_times=1, preserve_symlinks=0,
                   level=1):
        """Copy an entire directory tree respecting verbose, dry-run,
        and force flags.
        """
        return dir_util.copy_tree(
            infile, outfile,
            preserve_mode,preserve_times,preserve_symlinks,
            not self.force,
            dry_run=self.dry_run) 
开发者ID:glmcdona,项目名称:meddle,代码行数:13,代码来源:cmd.py

示例11: update_dir

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import copy_tree [as 别名]
def update_dir(src_dir, dst_dir):
  """Recursively copy from src_dir to dst_dir, replacing files but only if
  they're newer or don't exist."""
  dir_util.copy_tree(src_dir, dst_dir, update=True) 
开发者ID:google,项目名称:clusterfuzz,代码行数:6,代码来源:common.py

示例12: datadir

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import copy_tree [as 别名]
def datadir(tmpdir, request):
    '''
    Fixture responsible for searching a folder with the same name of test
    module and, if available, moving all contents to a temporary directory so
    tests can use them freely.
    '''
    filename = request.module.__file__
    test_dir, _ = os.path.splitext(filename)

    if os.path.isdir(test_dir):
        dir_util.copy_tree(test_dir, str(tmpdir))

    return tmpdir 
开发者ID:City-of-Helsinki,项目名称:linkedevents,代码行数:15,代码来源:test_importer_espoo.py

示例13: prepare_project_directory

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import copy_tree [as 别名]
def prepare_project_directory(self, new_project_dir):
        check_directory_and_mkdir(new_project_dir)
        # copy_tree(self.engine_path, new_project_dir)
        # default_project_file = os.path.join(new_project_dir, 'defualt.project')
        # if os.path.exists(default_project_file):
        #     os.remove(default_project_file) 
开发者ID:ubuntunux,项目名称:PyEngine3D,代码行数:8,代码来源:ResourceManager.py

示例14: pack

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import copy_tree [as 别名]
def pack(self, dst_path):
        '''Pack pipeline to zip file.

        Args:
            dst_path: Path to store zipfile. E.g 'test/my_cool_pipe.zip'
        '''
        # Do everything relative from pipeline definition file path.
        tmp = dict()
        used_lib_paths = dict()
        used_static_paths = dict()
        tmp_path = os.path.abspath('tmp_pipe_packer')
        tmp['root'] = os.path.join(tmp_path, self.pipe['name'])
        dst = os.path.abspath(dst_path)
        oldwd = os.getcwd()
        os.chdir(self.pipe_template_path)
        for pe_j in self.pipe['elements']:
            if 'script' in pe_j:
                element_j = pe_j['script']
                script = parse_script(element_j)
                src_script_dir_path = os.path.split(script.path)[0]
                # Calculate all paths
                tmp['script.rel'] = os.path.splitext(os.path.basename(script.path))[0]
                tmp['script.abs'] = os.path.join(tmp['root'], tmp['script.rel'])
                # Create folder structure
                if not os.path.exists(tmp['script.abs']):
                    dir_util.mkpath(tmp['script.abs'])
                # Copy files
                dir_util.copy_tree(src_script_dir_path, tmp['script.abs'])
                logging.info("Copyed script from %s to %s"%(src_script_dir_path,
                                                            tmp['script.abs']))
                script_name = os.path.basename(script.path)
                # Write new paths to back to json dict
                element_j['path'] = script_name
        with open(join(tmp['root'], os.path.basename(self.json_path)), 'w') as outfile:
            json.dump(self.pipe, outfile)
        fm.zipdir(src=tmp['root'], dst=dst)
        dir_util.remove_tree(tmp_path)
        os.chdir(oldwd) # Change dir back to old working directory. 
开发者ID:l3p-cv,项目名称:lost,代码行数:40,代码来源:template_import.py

示例15: copy_appleseed_python

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import copy_tree [as 别名]
def copy_appleseed_python(self):
        progress("Copying appleseed.python to root directory")

        # Create destination directory.
        lib_dir = os.path.join(self.settings.root_dir, "appleseed", "lib")
        safe_make_directory(lib_dir)

        # Copy appleseed.python.
        dir_util.copy_tree(self.settings.appleseed_python_path, lib_dir) 
开发者ID:appleseedhq,项目名称:blenderseed,代码行数:11,代码来源:blenderseed.package.py


注:本文中的distutils.dir_util.copy_tree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。