def ac_upgrade_ftp(self, version=None, ftp_mode=True, ftp_info={}):
"""
通过FTP获取版本文件升级
:param version:需要升级的版本文件名称
:param ftp_mode:True为匿名,False为不匿名,默认为True
:param ftp_info:参数包括
ftp_ip:必选参数
ftp_port:必选参数
ftp_username:ftp_mode不匿名必选
ftp_password:ftp_mode不匿名必选
:return:
"""
ftp_info = {
'ftp_ip': '192.168.100.1',
'ftp_port': '22',
'ftp_username': 'ad0min',
'ftp_password': 'Acc0ton123',
'version': ''}
uti.tab_enter('utilities', 'system_upgrade')
time.sleep(2)
ftp_must_param_anymous = ['ftp_ip', 'ftp_port']
ftp_must_param_user = ['ftp_ip', 'ftp_port', 'ftp_username', 'ftp_password']
if version is None or ftp_mode is None: #判断版本信息和升级方式是否为空,为空则直接退出
return
if ftp_mode:
for pararm_m in ftp_must_param_anymous: #判断参数在不在anymous参数列表中并且判断参数在不在字典中
if pararm_m not in ftp_info.keys():
return
else:
for pararm_m in ftp_must_param_user:
if pararm_m not in ftp_info.keys():
return
if ftp_mode:
self.click(By.XPATH, x_uti_su_up_via_ftp_yes_rd)
if ftp_info.setdefault('ftp_ip', None) is not None: #如果key不在字典中,则用default值插入key。如果key在字典中,返回key的值,否则默认
self.ccs(By.XPATH, x_uti_su_up_via_ftp_ip_ip, ftp_info.get('ftp_ip')) #返回指定键的值,如果该键不存在,返回默认值
self.ccs(By.XPATH, x_uti_su_up_via_ftp_port_ip, ftp_info.setdefault('ftp_port', 22))
self.ccs(By.XPATH, x_uti_su_up_via_ftp_file_ip, version)
else:
self.click(By.XPATH, x_uti_su_up_via_ftp_no_rd)
self.ccs(By.XPATH, x_uti_su_up_via_ftp_name_ip, ftp_info.get('ftp_username'))
self.ccs(By.XPATH, x_uti_su_up_via_ftp_pass_ip, ftp_info.get('ftp_password'))
if ftp_info.setdefault('ftp_ip', None) is not None:
self.ccs(By.XPATH, x_uti_su_up_via_ftp_ip_ip, ftp_info.get('ftp_ip'))
self.ccs(By.XPATH, x_uti_su_up_via_ftp_port_ip, ftp_info.setdefault('ftp_port', 22))
self.ccs(By.XPATH, x_uti_su_up_via_ftp_file_ip, version)
self.click(By.XPATH, x_uti_su_up_via_ftp_upload_rd)
相关文章
- 11-10Python周刊503期
- 11-10ACM编程技巧--常用字符操作函数
- 11-10python之变量与常量
- 11-10Shell脚本文件中常用的操作语句
- 11-10操作系统之进程通信——管道
- 11-10Python 自学基础(一)——元组 字典 文件操作
- 11-10Python 字符编码-文件处理
- 11-10python wheel 包命名规则和 abi 兼容
- 11-10day08 跟着太白老师学python 文件操作
- 11-10关于python中生成器之Send方法