def confirm_AP_upgrade_finish_after_reboot(self, host, user, pwd, version):
     try:
         #检查ap是否重启完成
         UpgradeBusiness.confirm_AP_reboot_finish(self, host)
         #检查直到能够ping通ap
         WebDriverWait(
             self.driver, 200,
             5).until(lambda ping: UpgradeControl.get_ping(self, host) == 0)
         #登录AP后台取出版本号
         tmp = UpgradeControl.get_router_version(self, host, user, pwd)
         #如果版本号不相同则等待,如果相同则直接退出
         if version not in tmp:
             print "AP need to be upgraded!"
             print "Start:go in Smart wait time detection..."
             print "the result of ping %s is :" % host
             #以下检查是否能够ping通ap,能够ping通就循环等待5s继续检查,不能ping通就跳出,持续15分钟后还不能ping通跳异常
             WebDriverWait(self.driver, 1200, 5).until_not(
                 lambda ping: UpgradeControl.get_ping(self, host) == 0)
             print "can't ping %s,and wait 2mins continue to ping" % host
             time.sleep(120)
             WebDriverWait(self.driver, 200, 5).until(
                 lambda ping: UpgradeControl.get_ping(self, host) == 0)
             time.sleep(30)
             print "Quit:can ping %s,quit Smart wait time detection" % host
         else:
             print "version is same,AP can't need to be upgraded!"
         print "AP upgrade finish!"
     except Exception as e:
         raise Exception("AP upgrade occur error! The reason is %s" % e)
 def upgrade_boot(self, host, user, pwd, version, addr):
     #点击系统设置菜单
     UpgradeControl.System_menu(self)
     #点击升级菜单
     UpgradeControl.Upgrade_menu(self)
     #升级方式切换为HTTP
     UpgradeControl.set_firmware_protocal(self, 'HTTP')
     #设置固件服务器,输入的地址为本机的ip地址
     UpgradeControl.set_FM_server(self, addr)
     #取消启动时检查
     UpgradeControl.set_on_boot(self)
     #点击保存
     UpgradeControl.save(self)
     UpgradeControl.apply(self)
     #点击重启
     UpgradeControl.reboot(self)
     #弹出的提示窗口中,点击确认
     UpgradeControl.notice_ok(self)
     # time.sleep(500)
     UpgradeBusiness.confirm_AP_upgrade_finish_after_reboot(
         self, host, user, pwd, version)
     print "reboot and upgrade ap successfully!"
     #ping AP的ip,ping通返回0
     result1 = UpgradeControl.get_ping(self, host)
     #登录AP后台取出版本号
     #登录AP后台取出版本号
     result2 = UpgradeControl.get_router_version(self, host, user, pwd)
     print result1, result2
     if (result1 == 0) and (version in result2):
         return True
     else:
         return False
 def upgrade_web(self, host, user, pwd, version, addr, mode):
     #在ap页面上设置升级方式
     UpgradeBusiness.set_upgrade_mode(self, addr, mode)
     #点击升级按钮
     UpgradeControl.upgrade_button(self)
     #弹出的提示窗口中,点击确认
     UpgradeControl.notice_ok(self)
     UpgradeBusiness.confirm_AP_upgrade_finish(self, host, user, pwd,
                                               version)
     print "upgrade FW through %s in AP's webpage successfully!" % mode
     #ping AP的ip,ping通返回0
     result1 = UpgradeControl.get_ping(self, host)
     #登录AP后台取出版本号
     result2 = UpgradeControl.get_router_version(self, host, user, pwd)
     print result1, result2
     if (result1 == 0) and (version in result2):
         return True
     else:
         return False
 def confirm_AP_upgrade_finish(self, host, user, pwd, version):
     try:
         #登录AP后台取出版本号
         tmp = UpgradeControl.get_router_version(self, host, user, pwd)
         #如果版本号不相同则等待,如果不相同则直接退出
         if version not in tmp:
             print "AP need to be upgraded!"
             print "-----------rick.zeng upgrade debug:1.start upgrade,go in intelligent wait!-----------"
             print "the result of ping %s is :" % host
             #以下检查是否能够ping通ap,能够ping通就循环等待5s继续检查,不能ping通就跳出,持续20分钟后还能ping通跳异常
             WebDriverWait(self.driver, 1200, 5).until_not(
                 lambda ping: UpgradeControl.get_ping(self, host) == 0)
             print "-----------rick.zeng upgrade debug:2.can't ping %s,and wait 2mins continue to ping-----------" % host
             time.sleep(120)
             WebDriverWait(self.driver, 200, 5).until(
                 lambda ping: UpgradeControl.get_ping(self, host) == 0)
             time.sleep(30)
             print "-----------rick.zeng upgrade debug:3.Quit:can ping %s,quit Smart wait time detection-----------" % host
         else:
             print "-----------rick.zeng upgrade debug:4.version is same,AP can't need to be upgraded!-----------"
         print "AP upgrade finish!"
     except Exception as e:
         raise Exception("AP upgrade occur error! The reason is %s" % e)