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


Python Stage.destroy方法代码示例

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


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

示例1: test_setup_and_destroy_no_name_without_tmp

# 需要导入模块: from spack.stage import Stage [as 别名]
# 或者: from spack.stage.Stage import destroy [as 别名]
    def test_setup_and_destroy_no_name_without_tmp(self):
        with use_tmp(False):
            stage = Stage(archive_url)
            self.check_setup(stage, None)

            stage.destroy()
            self.check_destroy(stage, None)
开发者ID:scrobey,项目名称:spack,代码行数:9,代码来源:stage.py

示例2: test_restage

# 需要导入模块: from spack.stage import Stage [as 别名]
# 或者: from spack.stage.Stage import destroy [as 别名]
    def test_restage(self):
        stage = Stage(archive_url, name=stage_name)

        stage.fetch()
        stage.expand_archive()
        stage.chdir_to_archive()
        self.check_expand_archive(stage, stage_name)
        self.check_chdir_to_archive(stage, stage_name)

        # Try to make a file in the old archive dir
        with closing(open('foobar', 'w')) as file:
            file.write("this file is to be destroyed.")

        self.assertTrue('foobar' in os.listdir(stage.expanded_archive_path))

        # Make sure the file is not there after restage.
        stage.restage()
        self.check_chdir(stage, stage_name)
        self.check_fetch(stage, stage_name)

        stage.chdir_to_archive()
        self.check_chdir_to_archive(stage, stage_name)
        self.assertFalse('foobar' in os.listdir(stage.expanded_archive_path))

        stage.destroy()
        self.check_destroy(stage, stage_name)
开发者ID:scrobey,项目名称:spack,代码行数:28,代码来源:stage.py

示例3: checkSetupAndDestroy

# 需要导入模块: from spack.stage import Stage [as 别名]
# 或者: from spack.stage.Stage import destroy [as 别名]
    def checkSetupAndDestroy(self, stage_name=None):
        stage = Stage(archive_url, name=stage_name)
        stage.setup()
        self.check_setup(stage, stage_name)

        stage.destroy()
        self.check_destroy(stage, stage_name)
开发者ID:jprotze,项目名称:spack,代码行数:9,代码来源:stage.py

示例4: test_setup_and_destroy_name_with_tmp

# 需要导入模块: from spack.stage import Stage [as 别名]
# 或者: from spack.stage.Stage import destroy [as 别名]
    def test_setup_and_destroy_name_with_tmp(self):
        with use_tmp(True):
            stage = Stage(archive_url, name=stage_name)
            self.check_setup(stage, stage_name)

            stage.destroy()
            self.check_destroy(stage, stage_name)
开发者ID:scrobey,项目名称:spack,代码行数:9,代码来源:stage.py

示例5: InstallTest

# 需要导入模块: from spack.stage import Stage [as 别名]
# 或者: from spack.stage.Stage import destroy [as 别名]
class InstallTest(MockPackagesTest):
    """Tests install and uninstall on a trivial package."""

    def setUp(self):
        super(InstallTest, self).setUp()

        self.stage = Stage('not_a_real_url')
        archive_dir = join_path(self.stage.path, dir_name)
        dummy_configure = join_path(archive_dir, 'configure')

        mkdirp(archive_dir)
        with closing(open(dummy_configure, 'w')) as configure:
            configure.write(
                "#!/bin/sh\n"
                "prefix=$(echo $1 | sed 's/--prefix=//')\n"
                "cat > Makefile <<EOF\n"
                "all:\n"
                "\techo Building...\n\n"
                "install:\n"
                "\tmkdir -p $prefix\n"
                "\ttouch $prefix/dummy_file\n"
                "EOF\n")
        os.chmod(dummy_configure, 0755)

        with working_dir(self.stage.path):
            tar = which('tar')
            tar('-czf', archive_name, dir_name)

        # We use a fake pacakge, so skip the checksum.
        spack.do_checksum = False

    def tearDown(self):
        super(InstallTest, self).tearDown()

        if self.stage is not None:
            self.stage.destroy()

        # Turn checksumming back on
        spack.do_checksum = True


    def test_install_and_uninstall(self):
        # Get a basic concrete spec for the trivial install package.
        spec = Spec(install_test_package)
        spec.concretize()
        self.assertTrue(spec.concrete)

        # Get the package
        pkg = spack.db.get(spec)

        # Fake the URL for the package so it downloads from a file.
        archive_path = join_path(self.stage.path, archive_name)
        pkg.url = 'file://' + archive_path

        try:
            pkg.do_install()
            pkg.do_uninstall()
        except Exception, e:
            pkg.remove_prefix()
            raise
开发者ID:dshrader,项目名称:spack,代码行数:62,代码来源:install.py

示例6: test_chdir

# 需要导入模块: from spack.stage import Stage [as 别名]
# 或者: from spack.stage.Stage import destroy [as 别名]
    def test_chdir(self):
        stage = Stage(archive_url, name=stage_name)

        stage.chdir()
        self.check_setup(stage, stage_name)
        self.check_chdir(stage, stage_name)

        stage.destroy()
        self.check_destroy(stage, stage_name)
开发者ID:scrobey,项目名称:spack,代码行数:11,代码来源:stage.py

示例7: test_expand_archive

# 需要导入模块: from spack.stage import Stage [as 别名]
# 或者: from spack.stage.Stage import destroy [as 别名]
    def test_expand_archive(self):
        stage = Stage(archive_url, name=stage_name)

        stage.fetch()
        self.check_setup(stage, stage_name)
        self.check_fetch(stage, stage_name)

        stage.expand_archive()
        self.check_expand_archive(stage, stage_name)

        stage.destroy()
        self.check_destroy(stage, stage_name)
开发者ID:scrobey,项目名称:spack,代码行数:14,代码来源:stage.py

示例8: MockRepo

# 需要导入模块: from spack.stage import Stage [as 别名]
# 或者: from spack.stage.Stage import destroy [as 别名]
class MockRepo(object):
    def __init__(self, stage_name, repo_name):
        """This creates a stage where some archive/repo files can be staged
           for testing spack's fetch strategies."""
        # Stage where this repo has been created
        self.stage = Stage(stage_name)

        # Full path to the repo within the stage.
        self.path = join_path(self.stage.path, repo_name)
        mkdirp(self.path)


    def destroy(self):
        """Destroy resources associated with this mock repo."""
        if self.stage:
            self.stage.destroy()
开发者ID:d-tk,项目名称:spack,代码行数:18,代码来源:mock_repo.py

示例9: stage

# 需要导入模块: from spack.stage import Stage [as 别名]
# 或者: from spack.stage.Stage import destroy [as 别名]
def stage():
    """Creates a stage with the directory structure for the tests."""
    s = Stage('link-tree-test')
    s.create()

    with working_dir(s.path):
        touchp('source/1')
        touchp('source/a/b/2')
        touchp('source/a/b/3')
        touchp('source/c/4')
        touchp('source/c/d/5')
        touchp('source/c/d/6')
        touchp('source/c/d/e/7')

    yield s

    s.destroy()
开发者ID:justintoo,项目名称:spack,代码行数:19,代码来源:link_tree.py

示例10: mirror

# 需要导入模块: from spack.stage import Stage [as 别名]
# 或者: from spack.stage.Stage import destroy [as 别名]
                    digest = pkg.versions[version]
                    stage.check(digest)
                    tty.msg("Checksum passed for %[email protected]%s" % (pkg.name, version))

                # change back and move the new archive into place.
                os.chdir(working_dir)
                shutil.move(stage.archive_file, mirror_file)
                tty.msg("Added %s to mirror" % mirror_file)
                num_mirrored += 1

            except Exception, e:
                 tty.warn("Error while fetching %s." % url, e.message)
                 num_error += 1

            finally:
                stage.destroy()

    # If nothing happened, try to say why.
    if not num_mirrored:
        if num_error:
            tty.error("No packages added to mirror.",
                      "All packages failed to fetch.")
        else:
            tty.error("No packages added to mirror. No versions matched specs:")
            colify(args.specs, indent=4)


def mirror(parser, args):
    action = { 'create' : mirror_create,
               'add'    : mirror_add,
               'remove' : mirror_remove,
开发者ID:scrobey,项目名称:spack,代码行数:33,代码来源:mirror.py

示例11: LinkTreeTest

# 需要导入模块: from spack.stage import Stage [as 别名]
# 或者: from spack.stage.Stage import destroy [as 别名]
class LinkTreeTest(unittest.TestCase):
    """Tests Spack's LinkTree class."""

    def setUp(self):
        self.stage = Stage('link-tree-test')

        with working_dir(self.stage.path):
            touchp('source/1')
            touchp('source/a/b/2')
            touchp('source/a/b/3')
            touchp('source/c/4')
            touchp('source/c/d/5')
            touchp('source/c/d/6')
            touchp('source/c/d/e/7')

        source_path = os.path.join(self.stage.path, 'source')
        self.link_tree = LinkTree(source_path)


    def tearDown(self):
        if self.stage:
            self.stage.destroy()


    def check_file_link(self, filename):
        self.assertTrue(os.path.isfile(filename))
        self.assertTrue(os.path.islink(filename))


    def check_dir(self, filename):
        self.assertTrue(os.path.isdir(filename))


    def test_merge_to_new_directory(self):
        with working_dir(self.stage.path):
            self.link_tree.merge('dest')

            self.check_file_link('dest/1')
            self.check_file_link('dest/a/b/2')
            self.check_file_link('dest/a/b/3')
            self.check_file_link('dest/c/4')
            self.check_file_link('dest/c/d/5')
            self.check_file_link('dest/c/d/6')
            self.check_file_link('dest/c/d/e/7')

            self.link_tree.unmerge('dest')

            self.assertFalse(os.path.exists('dest'))


    def test_merge_to_existing_directory(self):
        with working_dir(self.stage.path):

            touchp('dest/x')
            touchp('dest/a/b/y')

            self.link_tree.merge('dest')

            self.check_file_link('dest/1')
            self.check_file_link('dest/a/b/2')
            self.check_file_link('dest/a/b/3')
            self.check_file_link('dest/c/4')
            self.check_file_link('dest/c/d/5')
            self.check_file_link('dest/c/d/6')
            self.check_file_link('dest/c/d/e/7')

            self.assertTrue(os.path.isfile('dest/x'))
            self.assertTrue(os.path.isfile('dest/a/b/y'))

            self.link_tree.unmerge('dest')

            self.assertTrue(os.path.isfile('dest/x'))
            self.assertTrue(os.path.isfile('dest/a/b/y'))

            self.assertFalse(os.path.isfile('dest/1'))
            self.assertFalse(os.path.isfile('dest/a/b/2'))
            self.assertFalse(os.path.isfile('dest/a/b/3'))
            self.assertFalse(os.path.isfile('dest/c/4'))
            self.assertFalse(os.path.isfile('dest/c/d/5'))
            self.assertFalse(os.path.isfile('dest/c/d/6'))
            self.assertFalse(os.path.isfile('dest/c/d/e/7'))


    def test_merge_with_empty_directories(self):
        with working_dir(self.stage.path):
            mkdirp('dest/f/g')
            mkdirp('dest/a/b/h')

            self.link_tree.merge('dest')
            self.link_tree.unmerge('dest')

            self.assertFalse(os.path.exists('dest/1'))
            self.assertFalse(os.path.exists('dest/a/b/2'))
            self.assertFalse(os.path.exists('dest/a/b/3'))
            self.assertFalse(os.path.exists('dest/c/4'))
            self.assertFalse(os.path.exists('dest/c/d/5'))
            self.assertFalse(os.path.exists('dest/c/d/6'))
            self.assertFalse(os.path.exists('dest/c/d/e/7'))

            self.assertTrue(os.path.isdir('dest/a/b/h'))
#.........这里部分代码省略.........
开发者ID:jgalarowicz,项目名称:spack,代码行数:103,代码来源:link_tree.py


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