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


Python utils.rmtree函数代码示例

本文整理汇总了Python中utils.rmtree函数的典型用法代码示例。如果您正苦于以下问题:Python rmtree函数的具体用法?Python rmtree怎么用?Python rmtree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: prepare

 def prepare(self):
     """remove temporary files, create the directory structure"""
     utils.rmtree(self.work_path)
     utils.make_dirs(os.path.join(self.work_iso, 'seedbank/etc/runonce.d'))
     utils.make_dirs(self.work_initrd)
     utils.run('bsdtar -C "%s" -xf "%s"' % (self.work_iso, self.iso_file))
     utils.run('chmod -R u+w "%s"' % self.work_iso)
开发者ID:favoretti,项目名称:seedBank,代码行数:7,代码来源:iso.py

示例2: remove

    def remove(self,name,with_delete=True,with_sync=True,with_triggers=True,recursive=False):
        """
        Remove element named 'name' from the collection
        """

        # NOTE: with_delete isn't currently meaningful for repos
        # but is left in for consistancy in the API.  Unused.
        name = name.lower()
        obj = self.find(name=name)
        if obj is not None:
            if with_delete:
                if with_triggers: 
                    self._run_triggers(self.config.api, obj, "/var/lib/cobbler/triggers/delete/repo/pre/*")

            del self.listing[name]
            self.config.serialize_delete(self, obj)

            if with_delete:
                self.log_func("deleted repo %s" % name)
                if with_triggers: 
                    self._run_triggers(self.config.api, obj, "/var/lib/cobbler/triggers/delete/repo/post/*")
                    self._run_triggers(self.config.api, obj, "/var/lib/cobbler/triggers/change/*")
           
 
                path = "/var/www/cobbler/repo_mirror/%s" % obj.name
                if os.path.exists(path):
                    utils.rmtree(path)

            if with_delete and not self.api.is_cobblerd:
                self.api._internal_cache_update("repo", name, remove=True)

            return True
开发者ID:icontender,项目名称:cobbler,代码行数:32,代码来源:collection_repos.py

示例3: remove_single_profile

 def remove_single_profile(self, name, rebuild_menu=True):
     # delete profiles/$name file in webdir
     utils.rmfile(os.path.join(self.settings.webdir, "profiles", name))
     # delete contents on kickstarts/$name directory in webdir
     utils.rmtree(os.path.join(self.settings.webdir, "kickstarts", name))
     if rebuild_menu:
         self.sync.pxegen.make_pxe_menu()
开发者ID:ArcRaven,项目名称:cobbler,代码行数:7,代码来源:action_litesync.py

示例4: remove

    def remove(self,name,with_delete=True,with_sync=True,with_triggers=True,recursive=False,logger=None):
        """
        Remove element named 'name' from the collection
        """
        name = name.lower()

        # first see if any Groups use this distro
        if not recursive:
            for v in self.config.profiles():
                if v.distro.lower() == name:
                    raise CX(_("removal would orphan profile: %s") % v.name)

        obj = self.find(name=name)

        if obj is not None:
            kernel = obj.kernel
            if recursive:
                kids = obj.get_children()
                for k in kids:
                    self.config.api.remove_profile(k.name, recursive=recursive, delete=with_delete, with_triggers=with_triggers, logger=logger)

            if with_delete:
                if with_triggers: 
                    utils.run_triggers(self.config.api, obj, "/var/lib/cobbler/triggers/delete/distro/pre/*", [], logger)
                if with_sync:
                    lite_sync = action_litesync.BootLiteSync(self.config, logger=logger)
                    lite_sync.remove_single_distro(name)
            del self.listing[name]

            self.config.serialize_delete(self, obj)

            if with_delete:
                if with_triggers: 
                    utils.run_triggers(self.config.api, obj, "/var/lib/cobbler/triggers/delete/distro/post/*", [], logger)
                    utils.run_triggers(self.config.api, obj, "/var/lib/cobbler/triggers/change/*", [], logger)


            # look through all mirrored directories and find if any directory is holding
            # this particular distribution's kernel and initrd
            possible_storage = glob.glob("/var/www/cobbler/ks_mirror/*")
            path = None
            for storage in possible_storage:
                if os.path.dirname(obj.kernel).find(storage) != -1:
                    path = storage
                    continue

            # if we found a mirrored path above, we can delete the mirrored storage /if/
            # no other object is using the same mirrored storage.
            if with_delete and path is not None and os.path.exists(path) and kernel.find("/var/www/cobbler") != -1:
               # this distro was originally imported so we know we can clean up the associated
               # storage as long as nothing else is also using this storage.
               found = False
               distros = self.api.distros()
               for d in distros:
                   if d.kernel.find(path) != -1:
                       found = True
               if not found:
                   utils.rmtree(path)

        return True
开发者ID:GunioRobot,项目名称:cobbler,代码行数:60,代码来源:collection_distros.py

示例5: extract

    def extract(self, ex_path, version):
        if os.path.exists(ex_path):
            utils.rmtree(ex_path, ignore_errors=True)

        path = self.save_file_path(version)

        file = self.extract_class(path,
                                  *self.extract_args)
        # currently, python's extracting mechanism for zipfile doesn't
        # copy file permissions, resulting in a binary that
        # that doesn't work. Copied from a patch here:
        # http://bugs.python.org/file34873/issue15795_cleaned.patch
        if path.endswith('.zip'):
            members = file.namelist()
            for zipinfo in members:
                minfo = file.getinfo(zipinfo)
                target = file.extract(zipinfo, ex_path)
                mode = minfo.external_attr >> 16 & 0x1FF
                os.chmod(target, mode)
        else:
            file.extractall(ex_path)

        if path.endswith('.tar.gz'):
            dir_name = utils.path_join(ex_path, os.path.basename(path).replace('.tar.gz',''))
        else:
            dir_name = utils.path_join(ex_path, os.path.basename(path).replace('.zip',''))

        if os.path.exists(dir_name):
            for p in os.listdir(dir_name):
                abs_file = utils.path_join(dir_name, p)
                utils.move(abs_file, ex_path)
            utils.rmtree(dir_name, ignore_errors=True)
开发者ID:thugetry,项目名称:Web2Executable,代码行数:32,代码来源:command_line.py

示例6: clean_trees

    def clean_trees(self):
        """
        Delete any previously built pxelinux.cfg tree and virt tree info and then create
        directories.

        Note: for SELinux reasons, some information goes in /tftpboot, some in /var/www/cobbler
        and some must be duplicated in both.  This is because PXE needs tftp, and auto-kickstart
        and Virt operations need http.   Only the kernel and initrd images are duplicated, which is
        unfortunate, though SELinux won't let me give them two contexts, so symlinks are not
        a solution.  *Otherwise* duplication is minimal.
        """

        # clean out parts of webdir and all of /tftpboot/images and /tftpboot/pxelinux.cfg
        for x in os.listdir(self.settings.webdir):
            path = os.path.join(self.settings.webdir, x)
            if os.path.isfile(path):
                if not x.endswith(".py"):
                    utils.rmfile(path, logger=self.logger)
            if os.path.isdir(path):
                if x not in ["aux", "web", "webui", "localmirror", "repo_mirror", "ks_mirror", "images", "links", "pub", "repo_profile", "repo_system", "svc", "rendered", ".link_cache"]:
                    # delete directories that shouldn't exist
                    utils.rmtree(path, logger=self.logger)
                if x in ["kickstarts", "kickstarts_sys", "images", "systems", "distros", "profiles", "repo_profile", "repo_system", "rendered"]:
                    # clean out directory contents
                    utils.rmtree_contents(path, logger=self.logger)
        #
        self.make_tftpboot()
        utils.rmtree_contents(self.pxelinux_dir, logger=self.logger)
        utils.rmtree_contents(self.grub_dir, logger=self.logger)
        utils.rmtree_contents(self.images_dir, logger=self.logger)
        utils.rmtree_contents(self.yaboot_bin_dir, logger=self.logger)
        utils.rmtree_contents(self.yaboot_cfg_dir, logger=self.logger)
        utils.rmtree_contents(self.rendered_dir, logger=self.logger)
开发者ID:Acidburn0zzz,项目名称:cobbler,代码行数:33,代码来源:action_sync.py

示例7: remove

    def remove(self,name,with_delete=True,with_sync=True,with_triggers=True,recursive=False,logger=None):
        """
        Remove element named 'name' from the collection
        """

        # NOTE: with_delete isn't currently meaningful for repos
        # but is left in for consistancy in the API.  Unused.
        name = name.lower()
        obj = self.find(name=name)
        if obj is not None:
            if with_delete:
                if with_triggers: 
                    utils.run_triggers(self.config.api, obj, "/var/lib/cobbler/triggers/delete/repo/pre/*", [], logger)

            del self.listing[name]
            self.config.serialize_delete(self, obj)

            if with_delete:
                if with_triggers: 
                    utils.run_triggers(self.config.api, obj, "/var/lib/cobbler/triggers/delete/repo/post/*", [], logger)
                    utils.run_triggers(self.config.api, obj, "/var/lib/cobbler/triggers/change/*", [], logger)
           
 
                path = "/var/www/cobbler/repo_mirror/%s" % obj.name
                if os.path.exists(path):
                    utils.rmtree(path)

            return True

        raise CX(_("cannot delete an object that does not exist: %s") % name)
开发者ID:GunioRobot,项目名称:cobbler,代码行数:30,代码来源:collection_repos.py

示例8: remove_single_distro

 def remove_single_distro(self, name):
     bootloc = utils.tftpboot_location()
     # delete contents of images/$name directory in webdir
     utils.rmtree(os.path.join(self.settings.webdir, "images", name))
     # delete contents of images/$name in tftpboot
     utils.rmtree(os.path.join(bootloc, "images", name))
     # delete potential symlink to tree in webdir/links
     utils.rmfile(os.path.join(self.settings.webdir, "links", name)) 
开发者ID:ArcRaven,项目名称:cobbler,代码行数:8,代码来源:action_litesync.py

示例9: build_extension

 def build_extension(self, extension):
     log.info("Building module %s..." % extension)
     
     # Prepare folders
     os.chdir(self.build_dir)
     module_build_dir = os.path.join(self.build_dir,  extension)
     if os.path.exists(module_build_dir):
         log.info("Deleting module build folder %s..." % module_build_dir)
         rmtree(module_build_dir)
     log.info("Creating module build folder %s..." % module_build_dir)
     os.mkdir(module_build_dir)
     os.chdir(module_build_dir)
     
     module_src_dir = os.path.join(self.sources_dir, extension)
     
     # Build module
     cmake_cmd = [
         "cmake",
         "-G", self.make_generator,
         "-DQT_QMAKE_EXECUTABLE=%s" % self.qmake_path,
         "-DBUILD_TESTS=False",
         "-DDISABLE_DOCSTRINGS=True",
         "-DCMAKE_BUILD_TYPE=%s" % self.build_type,
         "-DCMAKE_INSTALL_PREFIX=%s" % self.install_dir,
         module_src_dir
     ]
     if sys.version_info[0] > 2:
         cmake_cmd.append("-DPYTHON3_EXECUTABLE=%s" % self.py_executable)
         cmake_cmd.append("-DPYTHON3_INCLUDE_DIR=%s" % self.py_include_dir)
         cmake_cmd.append("-DPYTHON3_LIBRARY=%s" % self.py_library)
         if self.build_type.lower() == 'debug':
             cmake_cmd.append("-DPYTHON3_DBG_EXECUTABLE=%s" % self.py_executable)
             cmake_cmd.append("-DPYTHON3_DEBUG_LIBRARY=%s" % self.py_library)
     else:
         cmake_cmd.append("-DPYTHON_EXECUTABLE=%s" % self.py_executable)
         cmake_cmd.append("-DPYTHON_INCLUDE_DIR=%s" % self.py_include_dir)
         cmake_cmd.append("-DPYTHON_LIBRARY=%s" % self.py_library)
         if self.build_type.lower() == 'debug':
             cmake_cmd.append("-DPYTHON_DEBUG_LIBRARY=%s" % self.py_library)
     if extension.lower() == "shiboken":
         cmake_cmd.append("-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=yes")
         if sys.version_info[0] > 2:
             cmake_cmd.append("-DUSE_PYTHON3=ON")
     
     log.info("Configuring module %s (%s)..." % (extension,  module_src_dir))
     if run_process(cmake_cmd, log) != 0:
         raise DistutilsSetupError("Error configuring " + extension)
     
     log.info("Compiling module %s..." % extension)
     if run_process([self.make_path], log) != 0:
         raise DistutilsSetupError("Error compiling " + extension)
     
     log.info("Installing module %s..." % extension)
     if run_process([self.make_path, "install/fast"], log) != 0:
         raise DistutilsSetupError("Error pseudo installing " + extension)
     
     os.chdir(self.script_dir)
开发者ID:enthought,项目名称:pyside-setup,代码行数:57,代码来源:setup.py

示例10: command_base

def command_base():
    config.TESTING = True
    dpath = utils.get_data_path('')

    if os.path.exists(dpath):
        utils.rmtree(dpath)

    base = CommandBase()
    base._project_name = 'Test'
    return base
开发者ID:jyapayne,项目名称:Web2Executable,代码行数:10,代码来源:test_command_line.py

示例11: _extract

 def _extract(self, prefix, files, src, dst, target):
     """extract files to the seedbank temp directory and move those"""
     archive = os.path.join(dst, os.path.basename(src))
     files = (os.path.join(prefix, file_name) for file_name in files)
     temp_manage = os.path.join(self.temp, 'manage')
     if os.path.isdir(temp_manage):
         utils.rmtree(temp_manage)
     utils.make_dirs(temp_manage)
     utils.untar_files(archive, files, temp_manage)
     self.copy_dir_contents(temp_manage, target)
     utils.rmtree(temp_manage)
开发者ID:martinseener,项目名称:seedBank,代码行数:11,代码来源:manage.py

示例12: _debian_firmware

 def _debian_firmware(self, name):
     """integrate Debian non free firmware"""
     temp_initrd = os.path.join(self.temp, 'initrd')
     initrd = os.path.join(self.cfg['paths']['tftpboot'], 'seedbank', name,
         'initrd.gz')
     utils.make_dirs(temp_initrd)
     utils.initrd_extract(temp_initrd, initrd)
     dst = os.path.join(self.temp, 'initrd/lib/firmware')
     self._add_firmware(name, dst)
     utils.initrd_create(temp_initrd, initrd)
     utils.rmtree(temp_initrd)
开发者ID:martinseener,项目名称:seedBank,代码行数:11,代码来源:manage.py

示例13: _remove_netboot

 def _remove_netboot(self, name):
     """remove a netboot image and if defined the related firmware files"""
     path = os.path.join(self.cfg['paths']['tftpboot'], 'seedbank', name)
     if not utils.rmtree(path):
         logging.info('release "%s" has not been installed', name)
     else:
         utils.rmtree(os.path.join(self.cfg['paths']['archives'], name))
     release = name.split('-')[1]
     firmware = os.path.join(self.cfg['paths']['archives'],
         'firmware-' + release)
     if not utils.rmtree(firmware):
         logging.info('firmware "%s" not found, nothing to do', firmware)
开发者ID:martinseener,项目名称:seedBank,代码行数:12,代码来源:manage.py

示例14: _initialize

 def _initialize(self):
     self._make_dirs()
     try:
         self.ca_cert = User(self, type=CERT_CA)
         cache_db.set_add("orgs", self.id)
         self.commit()
         LogEntry(message='Created new organization "%s".' % self.name)
     except:
         logger.exception("Failed to create organization. %r" % {"org_id": self.id})
         self.clear_cache()
         utils.rmtree(self.path)
         raise
开发者ID:pombredanne,项目名称:pritunl,代码行数:12,代码来源:organization.py

示例15: prepare

 def prepare(self, values):
     """ apply templates to all the .sb_template files and build the
     fix_perms.sh script from the permissions file"""
     values.update(self.cfg['pxe'])
     utils.rmtree(self.dst)
     utils.copy_tree(self.path, self.dst)
     for root, _, files in os.walk(self.dst):
         for file_name in files:
             if file_name.endswith('.sb_template'):
                 file_name = os.path.join(root, file_name)
                 utils.write_template(values, file_name)
                 utils.file_move(file_name, os.path.splitext(file_name)[0])
开发者ID:favoretti,项目名称:seedBank,代码行数:12,代码来源:pimp.py


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