本文整理汇总了Python中CShowParser.CShowParser.parse_file_copy方法的典型用法代码示例。如果您正苦于以下问题:Python CShowParser.parse_file_copy方法的具体用法?Python CShowParser.parse_file_copy怎么用?Python CShowParser.parse_file_copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CShowParser.CShowParser
的用法示例。
在下文中一共展示了CShowParser.parse_file_copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_platform_image
# 需要导入模块: from CShowParser import CShowParser [as 别名]
# 或者: from CShowParser.CShowParser import parse_file_copy [as 别名]
def load_platform_image(self, img_filename, external_tftp_config=None):
""" load_platform_image(self, img_filename, external_tftp_config) -> None
Parameters
----------
external_tftp_config : dict
A path to external tftp config file other than using the one defined in the instance.
img_filename : str
image name to be saved into the platforms drive.
This method loads the configured image into the platform's harddisk (unless it is already loaded),
and sets that image to be the boot_image of the platform.
"""
if not self.check_image_existence(img_filename): # check if this image isn't already saved in platform
# tmp_tftp_config = external_tftp_config if external_tftp_config is not None else self.tftp_cfg
if self.config_history["tftp_server_config"]: # make sure a TFTP configuration has been loaded
cache = CCommandCache()
if self.running_image is None:
self.get_running_image_details()
command = "copy tftp://{tftp_ip}/{img_path}/{image} harddisk:".format(
tftp_ip=self.tftp_cfg["ip_address"], img_path=self.tftp_cfg["images_path"], image=img_filename
)
cache.add("EXEC", [command, "\r", "\r"])
progress_thread = CProgressDisp.ProgressThread(
notifyMessage="Copying image via tftp, this may take a while...\n"
)
progress_thread.start()
response = self.cmd_link.run_single_command(cache, timeout=900, read_until=["\?", "\#"])
print("RESPONSE:")
print(response)
progress_thread.join()
copy_ok = CShowParser.parse_file_copy(response)
if not copy_ok:
raise UserWarning(
"Image file loading failed. Please make sure the accessed image exists and has read privileges"
)
else:
raise UserWarning(
"TFTP configuration is not available. Please make sure a valid TFTP configuration has been provided"
)