python类removedirs()的实例源码

__init__.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def renames(old, new):
    """Like os.renames(), but handles renaming across devices."""
    # Implementation borrowed from os.renames().
    head, tail = os.path.split(new)
    if head and tail and not os.path.exists(head):
        os.makedirs(head)

    shutil.move(old, new)

    head, tail = os.path.split(old)
    if head and tail:
        try:
            os.removedirs(head)
        except OSError:
            pass
util.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def renames(old, new):
    """Like os.renames(), but handles renaming across devices."""
    # Implementation borrowed from os.renames().
    head, tail = os.path.split(new)
    if head and tail and not os.path.exists(head):
        os.makedirs(head)

    shutil.move(old, new)

    head, tail = os.path.split(old)
    if head and tail:
        try:
            os.removedirs(head)
        except OSError:
            pass
test_linchpin_module_schema_check.py 文件源码 项目:linchpin 作者: CentOS-PaaS-SIG 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def test_module_dir_params(self):
        """
        tests module with dir params
        """
        dir_name = tempfile.mkdtemp()
        invalid_params = {"data": dir_name, "schema": dir_name}
        self.options["module_args"] = json.dumps(invalid_params)
        results = run_module(self.options)
        msg = "Recursive directory not supported"
        output = results['failed'] and msg in results["msg"]
        os.removedirs(dir_name)
        assert_equal(output, True)
test_linchpin_module_output_parser.py 文件源码 项目:linchpin 作者: CentOS-PaaS-SIG 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_module_dir_params(self):
        """
        tests module with dir params
        """
        dir_name = tempfile.mkdtemp()
        invalid_params = {"output_file": dir_name}
        self.options["module_args"] = json.dumps(invalid_params)
        results = run_module(self.options)
        msg = "Recursive directory not supported"
        output = results['failed'] and msg in results["msg"]
        os.removedirs(dir_name)
        assert_equal(output, True)
test_linchpin_module_os_hot_stack.py 文件源码 项目:linchpin 作者: CentOS-PaaS-SIG 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test_module_dir_params(self):
        """
        tests module with dir params
        """
        dir_name = tempfile.mkdtemp()
        invalid_params = {"stack_name": "testname",
                          "state": "present",
                          "template": dir_name}
        self.options["module_args"] = json.dumps(invalid_params)
        results = run_module(self.options)
        msg = "Recursive directory not supported"
        output = results['failed'] and msg in results["msg"]
        assert_equal(output, True)
        os.removedirs(dir_name)
__init__.py 文件源码 项目:Sci-Finder 作者: snverse 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def renames(old, new):
    """Like os.renames(), but handles renaming across devices."""
    # Implementation borrowed from os.renames().
    head, tail = os.path.split(new)
    if head and tail and not os.path.exists(head):
        os.makedirs(head)

    shutil.move(old, new)

    head, tail = os.path.split(old)
    if head and tail:
        try:
            os.removedirs(head)
        except OSError:
            pass
__init__.py 文件源码 项目:Sci-Finder 作者: snverse 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def renames(old, new):
    """Like os.renames(), but handles renaming across devices."""
    # Implementation borrowed from os.renames().
    head, tail = os.path.split(new)
    if head and tail and not os.path.exists(head):
        os.makedirs(head)

    shutil.move(old, new)

    head, tail = os.path.split(old)
    if head and tail:
        try:
            os.removedirs(head)
        except OSError:
            pass
vmdk_ops_test.py 文件源码 项目:vsphere-storage-for-docker 作者: vmware 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def clean_path(path):
        if not path:
            logging.info("Directory clean up - empty dir passed")
            return

        logging.info("Directory clean up - removing  %s", path)
        try:
            # TODO: need to use osfs-rmdir on VSAN. For now jus yell if it failed
            os.removedirs(path)
        except Exception as e:
            logging.warning("Directory clean up failed  -  %s, err: %s", path, e)
__init__.py 文件源码 项目:ascii-art-py 作者: blinglnav 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def renames(old, new):
    """Like os.renames(), but handles renaming across devices."""
    # Implementation borrowed from os.renames().
    head, tail = os.path.split(new)
    if head and tail and not os.path.exists(head):
        os.makedirs(head)

    shutil.move(old, new)

    head, tail = os.path.split(old)
    if head and tail:
        try:
            os.removedirs(head)
        except OSError:
            pass
lvsetup.py 文件源码 项目:avocado-misc-tests 作者: avocado-framework 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def tearDown(self):
        """
        Clear all PV,VG, LV and snapshots created by the test.
        """
        # Remove created VG and unmount from base directory
        errs = []
        for ramdisk in self.ramdisks:
            try:
                lv_utils.vg_ramdisk_cleanup(*ramdisk)
            except Exception as exc:
                errs.append("Fail to cleanup ramdisk %s: %s" % (ramdisk, exc))
        if errs:
            self.error("\n".join(errs))
        os.removedirs(self.mount_loc)
__init__.py 文件源码 项目:ivaochdoc 作者: ivaoch 项目源码 文件源码 阅读 51 收藏 0 点赞 0 评论 0
def renames(old, new):
    """Like os.renames(), but handles renaming across devices."""
    # Implementation borrowed from os.renames().
    head, tail = os.path.split(new)
    if head and tail and not os.path.exists(head):
        os.makedirs(head)

    shutil.move(old, new)

    head, tail = os.path.split(old)
    if head and tail:
        try:
            os.removedirs(head)
        except OSError:
            pass
__init__.py 文件源码 项目:aws-cfn-plex 作者: lordmuffin 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def renames(old, new):
    """Like os.renames(), but handles renaming across devices."""
    # Implementation borrowed from os.renames().
    head, tail = os.path.split(new)
    if head and tail and not os.path.exists(head):
        os.makedirs(head)

    shutil.move(old, new)

    head, tail = os.path.split(old)
    if head and tail:
        try:
            os.removedirs(head)
        except OSError:
            pass
__init__.py 文件源码 项目:django 作者: alexsukhrin 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def renames(old, new):
    """Like os.renames(), but handles renaming across devices."""
    # Implementation borrowed from os.renames().
    head, tail = os.path.split(new)
    if head and tail and not os.path.exists(head):
        os.makedirs(head)

    shutil.move(old, new)

    head, tail = os.path.split(old)
    if head and tail:
        try:
            os.removedirs(head)
        except OSError:
            pass
__init__.py 文件源码 项目:RPoint 作者: george17-meet 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def renames(old, new):
    """Like os.renames(), but handles renaming across devices."""
    # Implementation borrowed from os.renames().
    head, tail = os.path.split(new)
    if head and tail and not os.path.exists(head):
        os.makedirs(head)

    shutil.move(old, new)

    head, tail = os.path.split(old)
    if head and tail:
        try:
            os.removedirs(head)
        except OSError:
            pass
Alpha_Organizer.py 文件源码 项目:Automation-Scripts 作者: MohammedRashad 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def clean():
    absolute_path = os.path.abspath(__file__)
    mypath = os.path.dirname(absolute_path)

    for root, dirs, files in os.walk(mypath,topdown=False):
        for name in dirs:
            fname = join(root,name)
            if not os.listdir(fname): #to check wither the dir is empty
                 os.removedirs(fname)
__init__.py 文件源码 项目:isni-reconcile 作者: cmh2166 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def renames(old, new):
    """Like os.renames(), but handles renaming across devices."""
    # Implementation borrowed from os.renames().
    head, tail = os.path.split(new)
    if head and tail and not os.path.exists(head):
        os.makedirs(head)

    shutil.move(old, new)

    head, tail = os.path.split(old)
    if head and tail:
        try:
            os.removedirs(head)
        except OSError:
            pass
test_UnRAR2.py 文件源码 项目:Comictagger 作者: dickloraine 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def cleanup(dir='test'):
    for path, dirs, files in os.walk(dir):
        for fn in files:
            os.remove(os.path.join(path, fn))
        for dir in dirs:
            os.removedirs(os.path.join(path, dir))


# basic test
__init__.py 文件源码 项目:AshsSDK 作者: thehappydinoa 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def renames(old, new):
    """Like os.renames(), but handles renaming across devices."""
    # Implementation borrowed from os.renames().
    head, tail = os.path.split(new)
    if head and tail and not os.path.exists(head):
        os.makedirs(head)

    shutil.move(old, new)

    head, tail = os.path.split(old)
    if head and tail:
        try:
            os.removedirs(head)
        except OSError:
            pass
__init__.py 文件源码 项目:habilitacion 作者: GabrielBD 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def renames(old, new):
    """Like os.renames(), but handles renaming across devices."""
    # Implementation borrowed from os.renames().
    head, tail = os.path.split(new)
    if head and tail and not os.path.exists(head):
        os.makedirs(head)

    shutil.move(old, new)

    head, tail = os.path.split(old)
    if head and tail:
        try:
            os.removedirs(head)
        except OSError:
            pass


问题


面经


文章

微信
公众号

扫码关注公众号