本文整理汇总了Python中solaris_install.transfer.info.Source类的典型用法代码示例。如果您正苦于以下问题:Python Source类的具体用法?Python Source怎么用?Python Source使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Source类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_cpio_w_file_list
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,代码行数:29,代码来源:test_cpio.py
示例2: test_media_transform
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,代码行数:29,代码来源:test_cpio.py
示例3: test_single_args_instance
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,代码行数:25,代码来源:test_svr4.py
示例4: test_progress_estimate_with_size
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,代码行数:26,代码来源:test_cpio.py
示例5: test_valid_transfer_action
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,代码行数:30,代码来源:test_svr4.py
示例6: test_install_uninstall_dry_run
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,代码行数:26,代码来源:test_svr4.py
示例7: test_dry_run_transfer
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,代码行数:28,代码来源:test_svr4.py
示例8: test_cpio_w_dir_list_file
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,代码行数:29,代码来源:test_cpio.py
示例9: test_cpio_non_default_args_set
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,代码行数:34,代码来源:test_cpio.py
示例10: test_cpio_w_file_list_file
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,代码行数:29,代码来源:test_cpio.py
示例11: test_cleanup_temp_files
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,代码行数:25,代码来源:test_cpio.py
示例12: create_misc_archive
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,代码行数:60,代码来源:pkg_img_mod.py
示例13: add_content_list_to_doc
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,代码行数:35,代码来源:pkg_img_mod.py
示例14: test_origin_not_specified
def test_origin_not_specified(self):
'''Test an errer is raised when the origin is not specified.
'''
src = Source()
pub = Publisher()
src.insert_children([pub])
self.soft_node.insert_children([src])
tr_p5i = TransferP5I("P5I transfer")
self.assertRaises(ObjectNotFoundError, tr_p5i.execute, DRY_RUN)
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:9,代码来源:test_p5i.py
示例15: test_dst_not_specified
def test_dst_not_specified(self):
''' Test that an error is raised when dst is not specified'''
# Test that an error is raised.
src = Source()
src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11")
path = Dir(src_path)
src.insert_children([path])
self.soft_node.insert_children([src])
self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True)
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:10,代码来源:test_cpio.py
示例16: test_dst_not_specified
def test_dst_not_specified(self):
'''Test error when dst is not specified
'''
src = Source()
pub = Publisher()
origin = Origin(self.TEST_SRC_DIR)
pub.insert_children([origin])
src.insert_children([pub])
self.soft_node.insert_children([src])
self.assertRaises(Exception, self.tr_svr4.execute, dry_run=True)
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:11,代码来源:test_svr4.py
示例17: test_set_invalid_facets
def test_set_invalid_facets(self):
'''Ensure an error is raised for an invalid facet'''
src = Source()
pub = Publisher("opensolaris.org")
origin = Origin("http://ipkg.sfbay.sun.com/release/")
pub.insert_children([origin])
src.insert_children([pub])
self.soft_node.insert_children([src])
facet = Facet("doc", 'True')
self.ips_image.insert_children([facet])
self.assertRaises(Exception, self.tr_ips.execute)
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:12,代码来源:test_ips.py
示例18: test_default_publisher
def test_default_publisher(self):
'''Test that using the default publisher succeeds'''
src = Source()
pub = Publisher()
origin = Origin("http://ipkg.sfbay.sun.com/release/")
pub.insert_children([origin])
src.insert_children([pub])
self.soft_node.insert_children([src])
try:
self.tr_ips.execute(dry_run=DRY_RUN)
except Exception as err:
self.fail(str(err))
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:12,代码来源:test_ips.py
示例19: test_mirrors
def test_mirrors(self):
'''Test creating mirrors succeeds'''
src = Source()
pub = Publisher("opensolaris.org")
origin = Origin("http://ipkg.sfbay.sun.com/release/")
mirror = Mirror("http://ipkg.central.sun.com:8000/")
pub.insert_children([origin, mirror])
src.insert_children([pub])
self.soft_node.insert_children([src])
try:
self.tr_ips.execute(dry_run=DRY_RUN)
except Exception as err:
self.fail(str(err))
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:13,代码来源:test_ips.py
示例20: test_set_create_facets
def test_set_create_facets(self):
'''Test that creating facets succeeds'''
src = Source()
pub = Publisher("opensolaris.org")
origin = Origin("http://ipkg.sfbay.sun.com/release/")
pub.insert_children([origin])
src.insert_children([pub])
self.soft_node.insert_children([src])
facet = Facet("facet.doc", 'True')
self.ips_image.insert_children([facet])
try:
self.tr_ips.execute(dry_run=DRY_RUN)
except Exception as err:
self.fail(str(err))
开发者ID:PluribusNetworks,项目名称:pluribus_userland,代码行数:14,代码来源:test_ips.py
注:本文中的solaris_install.transfer.info.Source类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论