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


Python Source.insert_children方法代码示例

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


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

示例1: test_source_replacement

# 需要导入模块: from solaris_install.transfer.info import Source [as 别名]
# 或者: from solaris_install.transfer.info.Source import insert_children [as 别名]
    def test_source_replacement(self):
        '''Test that replacing a source succeeds'''
        # Setup an IPS image
        src = Source()
        pub = Publisher("opensolaris.org")
        origin = Origin("http://ipkg.sfbay.sun.com/release/")
        pub2 = Publisher("extra")
        origin2 = Origin("http://ipkg.sfbay.sun.com/extra/")
        pub2.insert_children([origin2])
        pub.insert_children([origin])
        src.insert_children([pub, pub2])
        self.soft_node.insert_children([src])
        try:
            self.tr_ips.execute(dry_run=DRY_RUN)
        except Exception as err:
            self.fail(str(err))

        # Create a new transaction with a differnt publisher/origin.
        # Specify to update the image created above.
        self.soft_node = Software("IPS post install")
        self.doc.insert_children([self.soft_node])
        src = Source()
        pub = Publisher("opensolaris.org")
        origin = Origin("http://ipkg.sfbay.sun.com/dev/")
        pub.insert_children([origin])
        src.insert_children([pub])
        dst = Destination()
        self.ips_image = Image(self.IPS_IMG_DIR, "update")
        dst.insert_children([self.ips_image])
        self.soft_node.insert_children([dst, src])
        try:
            self.tr_ips.execute(dry_run=DRY_RUN)
        except Exception as err:
            self.fail(str(err))
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:36,代码来源:test_ips.py

示例2: test_cpio_non_default_args_set

# 需要导入模块: from solaris_install.transfer.info import Source [as 别名]
# 或者: from solaris_install.transfer.info.Source import insert_children [as 别名]
    def test_cpio_non_default_args_set(self):
        '''Test copying a list of directories and files succeeds'''
        # Copy all the directories and files from /etc/X11 and /etc/zones
        # to /rpool/cpio_test_dir using a list for the contents

        # Set up the source
        src = Source()
        path = Dir(self.TEST_SRC_DIR)
        src.insert_children([path])

        # Set up the destination
        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        args = Args({"cpio_args": "-n -d -pdum"})
        self.tr_node.insert_children([args])

        # Insert the source and dest into the Software node
        self.soft_node.insert_children([src, dst])

        self.TEST_CONTENTS_LIST.append("bin/xclock")
        self.TEST_CONTENTS_LIST.append("bin/pv.sh")

        # The CPIO values that are specified
        self.TEST_CONTENTS_LIST.append("etc/X11")
        self.TEST_CONTENTS_LIST.append("etc/zones")
        self.tr_node.action = "install"
        self.tr_node.contents = self.TEST_CONTENTS_LIST

        try:
            self.tr_cpio.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:36,代码来源:test_cpio.py

示例3: add_content_list_to_doc

# 需要导入模块: from solaris_install.transfer.info import Source [as 别名]
# 或者: from solaris_install.transfer.info.Source import insert_children [as 别名]
    def add_content_list_to_doc(self, content_list):
        src_path = Dir(MEDIA_DIR_VAR)
        src = Source()
        src.insert_children(src_path)

        dst_path = Dir(INSTALL_TARGET_VAR)
        dst = Destination()
        dst.insert_children(dst_path)

        media_install = CPIOSpec()
        media_install.action = CPIOSpec.INSTALL
        media_install.contents = content_list
        total_size_byte = 0
        for content in content_list:
            content_path = os.path.join(self.pkg_img_path, content)
            # only want to calculate the size of files, since directories
            # are traversed and it's files are included in the list.
            if not os.path.isdir(content_path):
                total_size_byte += file_size(content_path)
        media_install.size = str(total_size_byte)

        media_soft_node = Software(TRANSFER_MEDIA, type="CPIO")
        media_soft_node.insert_children([src, dst, media_install])

        # Add that into the software transfer list.
        self.doc.persistent.insert_children(media_soft_node)

        # call manifest writer to write out the content of
        # the transfer manifest
        manifest_out = os.path.join(self.pkg_img_path, TRANSFER_MANIFEST_NAME)
        xslt_name = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                 "xslt", "doc2_media_transfer.xslt")
        manifest_writer = ManifestWriter("manifest-writer",
                                         manifest_out, xslt_file=xslt_name)
        manifest_writer.write(self.doc)
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:37,代码来源:pkg_img_mod.py

示例4: test_single_args_instance

# 需要导入模块: from solaris_install.transfer.info import Source [as 别名]
# 或者: from solaris_install.transfer.info.Source import insert_children [as 别名]
    def test_single_args_instance(self):
        '''Test pass when single instance of args provided
        '''
        mysrc = "srcdir"
        mydest = "destfile"
        args = Args({"svr4_args": "-n -d %s -R %s" % (mysrc, mydest)})
        self.tr_node.insert_children([args])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])
        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1"]

        try:
            self.tr_svr4.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:27,代码来源:test_svr4.py

示例5: test_progress_estimate_with_size

# 需要导入模块: from solaris_install.transfer.info import Source [as 别名]
# 或者: from solaris_install.transfer.info.Source import insert_children [as 别名]
    def test_progress_estimate_with_size(self):
        '''Test progress estimate value when size is pre-calculated  exists
        '''
        src = Source()
        src_path = os.path.join(self.TEST_SRC_DIR, "etc")
        path = Dir(src_path)
        src.insert_children([path])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.tr_node.action = "install"
        self.tr_node.contents = ["./"]
        size_to_transfer = dir_size(src_path)
        self.tr_node.size = str(size_to_transfer)

        progress_estimate = self.tr_cpio.get_progress_estimate()
        expect_estimate = \
            int((float(size_to_transfer/1024) / self.tr_cpio.DEFAULT_SIZE) * \
                self.tr_cpio.DEFAULT_PROG_EST)

        self.assertEqual(progress_estimate, expect_estimate)
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:28,代码来源:test_cpio.py

示例6: test_media_transform

# 需要导入模块: from solaris_install.transfer.info import Source [as 别名]
# 或者: from solaris_install.transfer.info.Source import insert_children [as 别名]
    def test_media_transform(self):
        '''Test media transform functionality'''
        src = Source()
        src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11")
        path = Dir(src_path)
        src.insert_children([path])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.tr_node.action = "transform"
        self.tr_node.contents = self.TEST_MEDIA_TRANSFORM
        with open(self.TEST_MEDIA_TRANSFORM, 'w') as filehandle:
            filehandle.write("#!/usr/bin/python\n")
            filehandle.write("import os\n")
            mkdir_cmd = "os.mkdir('" + self.TEST_DST_DIR + "')"
            filehandle.write(mkdir_cmd + "\n")
            mkdir_cmd = "os.mkdir('" + os.path.join(self.TEST_DST_DIR,
                                                    "media") + "')"
            filehandle.write(mkdir_cmd)
        os.chmod(self.TEST_MEDIA_TRANSFORM, 0777)
        try:
            self.tr_cpio.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:31,代码来源:test_cpio.py

示例7: test_install_uninstall_dry_run

# 需要导入模块: from solaris_install.transfer.info import Source [as 别名]
# 或者: from solaris_install.transfer.info.Source import insert_children [as 别名]
    def test_install_uninstall_dry_run(self):
        '''Test an install followed by an uninstall'''
        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1", "SUNWpkg2", "SUNWpkg3"]
        args = Args({"svr4_args": "-n -R %s" % (self.TEST_DST_DIR)})
        self.tr_node.insert_children([args])
        self.tr_node2 = SVR4Spec()
        self.tr_node2.action = "uninstall"
        self.tr_node2.contents = ["SUNWpkg2"]
        self.soft_node.insert_children([self.tr_node2])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])

        try:
            self.tr_svr4.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:28,代码来源:test_svr4.py

示例8: create_misc_archive

# 需要导入模块: from solaris_install.transfer.info import Source [as 别名]
# 或者: from solaris_install.transfer.info.Source import insert_children [as 别名]
    def create_misc_archive(self):
        """ class method to create the /mnt/misc file system archive
        """
        os.chdir(self.pkg_img_path)

        self.logger.info("Generating /mnt/misc file system archive")

        os.mkdir("miscdirs")
        shutil.move("opt", "miscdirs")
        shutil.move("etc", "miscdirs")
        shutil.move("var", "miscdirs")

        # add Software node to install items from /mnt/misc

        src_path = Dir("/mnt/misc")
        src = Source()
        src.insert_children(src_path)

        dst_path = Dir(INSTALL_TARGET_VAR)
        dst = Destination()
        dst.insert_children(dst_path)

        tr_install_misc = CPIOSpec()
        tr_install_misc.action = CPIOSpec.INSTALL
        tr_install_misc.contents = ["."]
        tr_install_misc.size = str(dir_size(os.path.join(self.pkg_img_path,
                                                         "miscdirs")))

        misc_software_node = Software(TRANSFER_MISC, type="CPIO")
        misc_software_node.insert_children([src, dst, tr_install_misc])
        self.doc.persistent.insert_children(misc_software_node)

        cmd = [cli.MKISOFS, "-o", "solarismisc.zlib", "-N", "-l", "-R",
               "-U", "-allow-multidot", "-no-iso-translate", "-quiet",
               "-cache-inodes", "-d", "-D", "-V", "\"compress\"",
               "miscdirs"]
        run(cmd)

        self.logger.info("Compressing /mnt/misc file system archive " +
                         "using: " + self.compression_type)

        cmd = [cli.LOFIADM, "-C", self.compression_type,
               os.path.join(self.pkg_img_path, "solarismisc.zlib")]
        p = run(cmd, check_result=Popen.ANY)
        if p.returncode != 0:
            if "invalid algorithm name" in p.stderr:
                raise RuntimeError("Invalid compression algorithm " +
                    "specified for /mnt/misc archive: " +
                    self.compression_type)
            else:
                raise RuntimeError("Compression of /mnt/misc file system " +
                                   "failed:  " + os.strerror(p.returncode))

        # the removal of /usr must be deferred to until solarismisc.zlib has
        # been created because the contents of solarismisc.zlib actually come
        # from /usr
        shutil.rmtree(os.path.join(self.pkg_img_path, "miscdirs"),
                      ignore_errors=True)
        shutil.rmtree(os.path.join(self.pkg_img_path, "usr"),
                      ignore_errors=True)
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:62,代码来源:pkg_img_mod.py

示例9: test_dry_run_transfer

# 需要导入模块: from solaris_install.transfer.info import Source [as 别名]
# 或者: from solaris_install.transfer.info.Source import insert_children [as 别名]
    def test_dry_run_transfer(self):
        '''Test with accurate input dry run succeeds
        '''
        self.tr_node2 = SVR4Spec()
        self.tr_node2.action = "install"
        self.tr_node2.contents = ["SUNWpkg1", "SUNWpkg2"]
        self.soft_node.insert_children([self.tr_node2])
        args2 = Args({"svr4_args": "-n -R %s" % (self.TEST_DST_DIR)})
        self.tr_node2.insert_children([args2])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])

        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1", "SUNWpkg2"]

        try:
            self.tr_svr4.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:30,代码来源:test_svr4.py

示例10: test_cpio_w_file_list

# 需要导入模块: from solaris_install.transfer.info import Source [as 别名]
# 或者: from solaris_install.transfer.info.Source import insert_children [as 别名]
    def test_cpio_w_file_list(self):
        '''Test copy from a list succeeds'''
        # Copy /bin/xclock and /bin/pv.sh to /rpool/cpio_test_dir
        # using a file list as the contents source

        # Set up the source
        src = Source()
        path = Dir(self.TEST_SRC_DIR)
        src.insert_children([path])

        # Set up the destination
        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        # Insert the source and dest into the Software node
        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.TEST_CONTENTS_LIST.append("bin/xclock")
        self.TEST_CONTENTS_LIST.append("bin/pv.sh")

        self.tr_node.action = "install"
        self.tr_node.contents = self.TEST_CONTENTS_LIST

        try:
            self.tr_cpio.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:31,代码来源:test_cpio.py

示例11: test_cpio_w_dir_list_file

# 需要导入模块: from solaris_install.transfer.info import Source [as 别名]
# 或者: from solaris_install.transfer.info.Source import insert_children [as 别名]
    def test_cpio_w_dir_list_file(self):
        '''Test directory cpio copy succeeds'''
        # Copy all the directories and files from /etc/X11 and /etc/zones
        # to /rpool/cpio_test_dir using a file for the contents

        # Set up the source
        src = Source()
        path = Dir(self.TEST_SRC_DIR)
        src.insert_children([path])

        # Set up the destination
        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        # Insert the source and dest into the Software node
        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.tr_node.action = "install"
        self.tr_node.contents = self.TEST_DIR_LIST_FILE
        with open(self.TEST_DIR_LIST_FILE, 'w') as filehandle:
            filehandle.write("etc/X11" + "\n")
            filehandle.write("etc/zones" + "\n")

        try:
            self.tr_cpio.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:31,代码来源:test_cpio.py

示例12: test_cleanup_temp_files

# 需要导入模块: from solaris_install.transfer.info import Source [as 别名]
# 或者: from solaris_install.transfer.info.Source import insert_children [as 别名]
    def test_cleanup_temp_files(self):
        '''Test the cleanup of the temporary files'''
        # Set up the source
        src = Source()
        src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11")
        path = Dir(src_path)
        src.insert_children([path])

        # Set up the destination
        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        # Insert the source and dest into the Software node
        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.tr_node.action = "install"
        self.tr_node.contents = ["./"]

        self.tr_cpio._parse_input()
        try:
            self.tr_cpio._cleanup_tmp_files()
        except Exception as err:
            self.fail(str(err))
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:27,代码来源:test_cpio.py

示例13: test_cpio_w_file_list_file

# 需要导入模块: from solaris_install.transfer.info import Source [as 别名]
# 或者: from solaris_install.transfer.info.Source import insert_children [as 别名]
    def test_cpio_w_file_list_file(self):
        '''Test copy of a file list file succeeds'''
        # Copy /bin/xclock and /bin/pv.sh to /rpool/cpio_test_dir
        # using a file list file as the contents souce

        # Set up the source
        src = Source()
        path = Dir(self.TEST_SRC_DIR)
        src.insert_children([path])

        # Set up the destination
        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        # Insert the source and dest into the Software node
        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.tr_node.action = "install"
        self.tr_node.contents = self.TEST_FILE_LIST_FILE
        with open(self.TEST_FILE_LIST_FILE, 'w') as filehandle:
            filehandle.write("bin/xclock" + "\n")
            filehandle.write("bin/pv.sh" + "\n")

        try:
            self.tr_cpio.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:31,代码来源:test_cpio.py

示例14: test_valid_transfer_action

# 需要导入模块: from solaris_install.transfer.info import Source [as 别名]
# 或者: from solaris_install.transfer.info.Source import insert_children [as 别名]
    def test_valid_transfer_action(self):
        '''Test valid input with dry run.
        '''
        self.tr_node2 = SVR4Spec()
        self.tr_node2.action = "uninstall"
        self.tr_node2.contents = ["SUNWpkg1", "SUNWpkg2"]
        self.soft_node.insert_children([self.tr_node2])
        args2 = Args({"svr4_args": "-n -R %s" % (self.TEST_DST_DIR)})
        self.tr_node2.insert_children([args2])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])

        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1", "SUNWpkg2"]

        self.tr_node3 = SVR4Spec()
        self.tr_node3.action = "transform"
        self.tr_node3.contents = ["SUNWpkg1", "SUNWpkg2"]
        self.soft_node.insert_children([self.tr_node3])

        self.assertRaises(Exception, self.tr_svr4.execute, dry_run=True)
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:32,代码来源:test_svr4.py

示例15: test_multiple_source_info

# 需要导入模块: from solaris_install.transfer.info import Source [as 别名]
# 或者: from solaris_install.transfer.info.Source import insert_children [as 别名]
    def test_multiple_source_info(self):
        '''Test that specifying multiple sources succeeds.'''
        soft_node = Software("transfer test 2")
        src1 = Source()
        pub1 = Publisher("test1.org")
        origin1 = Origin("http://test1/dev")
        pub1.insert_children([origin1])
        src1.insert_children([pub1])

        src2 = Source()
        pub2 = Publisher("test2.org")
        origin2 = Origin("http://test2/dev")
        pub2.insert_children([origin2])
        src2.insert_children([pub2])

        tr_node = IPSSpec()
        soft_node.insert_children([src1, src2, tr_node])
        self.doc.insert_children([soft_node])
        soft_list = self.doc.get_children("transfer test 2", Software)
        for soft in soft_list:
            src_list = soft.get_children("source", Source)
            pub = src_list[0].get_children("publisher", Publisher)
            origin = pub[0].get_children("origin", Origin)
            self.assertEqual(pub[0].publisher, "test1.org")
            self.assertEqual(origin[0].origin, "http://test1/dev")
            pub = src_list[1].get_children("publisher", Publisher)
            origin = pub[0].get_children("origin", Origin)
            self.assertEqual(pub[0].publisher, "test2.org")
            self.assertEqual(origin[0].origin, "http://test2/dev")
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:31,代码来源:test_info.py


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