• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.rmtree函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: remove

    def remove(self):
        logger.debug('Removing server. %r' % {
            'server_id': self.id,
        })

        if self.status:
            self.force_stop()

        utils.rmtree(self.path)
        call_buffer = _call_buffers.pop(self.id, None)
        if call_buffer:
            call_buffer.stop_waiter()
开发者ID:DevMega,项目名称:pritunl-node,代码行数:12,代码来源:server.py


示例17: remove

    def remove(self):
        self.clear_cache()
        name = self.name

        for server in self.iter_servers():
            if server.status:
                server.stop()
            server.remove_org(self.id)

        utils.rmtree(self.path)
        LogEntry(message='Deleted organization "%s".' % name)
        Event(type=ORGS_UPDATED)
开发者ID:WrongChao,项目名称:pritunl,代码行数:12,代码来源:organization.py


示例18: remove

    def remove(self):
        logger.debug('Removing server. %r' % {
            'server_id': self.id,
        })
        self.clear_cache()
        name = self.name

        if self.status:
            self.force_stop(True)

        self._remove_primary_user()
        utils.rmtree(self.path)
        LogEntry(message='Deleted server "%s".' % name)
        Event(type=SERVERS_UPDATED)
开发者ID:ogrishman,项目名称:pritunl,代码行数:14,代码来源:server.py


示例19: _add_firmware

 def _add_firmware(self, name, dst):
     """download, extract and copy Debian non free firmware"""
     distribution, release, _ = name.split('-')
     path = '-'.join(('firmware', distribution, release))
     archive_dst = os.path.join(self.cfg['paths']['archives'], path)
     temp_firmware = os.path.join(self.temp, 'firmware')
     archive = os.path.join(archive_dst, 'firmware.tar.gz')
     url = self.cfg[distribution]['url_firmware'].replace('${release}',
         release)
     self._download(url, archive_dst)
     utils.untar(archive, temp_firmware)
     self._extract_debs(temp_firmware)
     src = os.path.join(temp_firmware, 'temp', 'lib/firmware')
     utils.file_move(src, dst)
     utils.rmtree(temp_firmware)
开发者ID:martinseener,项目名称:seedBank,代码行数:15,代码来源:manage.py


示例20: _disable_usb

 def _disable_usb(self, temp_initrd):
     """remove usb storage support from initrd"""
     for root, _, _ in os.walk(temp_initrd):
         if 'kernel/drivers/usb/storage' in root:
             if utils.rmtree(root):
                 logging.info('usb storage support has been disabled in the '
                     'initrd image (fixes "root partition not found" error)')
开发者ID:dmeulen,项目名称:seedBank,代码行数:7,代码来源:manage.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.run函数代码示例发布时间:2022-05-26
下一篇:
Python utils.rmfile函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap