本文整理匯總了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"
)