def check_reboot_and_enter_installui_and_cancle(self, sn): ''' :param sn: :param flag: :return: ''' try: co.reboot_device(sn) time.sleep(5) if co.wait_hu_recovery(sn) == 0: if co.alway_send_signal(sn, SL.ActiveUpgrade) == 0: if co.cancle_install_through_ui(sn) == 0: return 0 else : return 1 else: logger.log_error("can not find install ui", \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1 else: logger.log_error("wait hu recovery fail",\ sys._getframe().f_code.co_filename,sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1 except Exception as e: logger.log_error("%s" %(e),\ sys._getframe().f_code.co_filename,sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1
def cancleinstall_through_setting(self, sn): ''' :param sn: :param flag: :return: ''' try: co.reboot_device(sn) time.sleep(5) if co.wait_hu_recovery(sn) == 0: if co.cancleinstall_through_setting(sn, SL.ActiveUpgrade) == 0: return 0 else: logger.log_error("cancle upgrade failed", \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name, sys._getframe().f_lineno) return 1 else: logger.log_error("wait hu recovery fail",\ sys._getframe().f_code.co_filename,sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1 except Exception as e: logger.log_error("%s" %(e),\ sys._getframe().f_code.co_filename,sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1
def check_reboot_and_enter_installui(self, sn): ''' :param sn: :param flag: :return: ''' try: # co.reboot_device(sn) co.reboot_device(sn) # co.wait_hu_recovery(sn) time.sleep(5) if co.wait_hu_recovery(sn) == 0: if co.alway_send_signal(sn, SL.ActiveUpgrade) == 0: return 0 else: pcan = SC.PCAN() pcan.poweron_and_clean() return 1 else: logger.log_error("wait hu recovery fail", \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name, sys._getframe().f_lineno) return 1 except Exception as e: logger.log_error("%s" % (e), \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name, sys._getframe().f_lineno) return 1
def check_break_point_resume_with_reboot(self, sn, flag): ''' function : break point resume through reboot :param sn: :return: ''' co.delete_file(sn) time.sleep(5) value_list = [] try: # package.flash_through_system(sn) if package.update_system_through_fastboot(retry_times) == 0 and co.start_fota_daemon(sn) == 0: # if co.start_fota_daemon(sn) == 0: time.sleep(5) if self.get_requestdata_to_file(sn) == 1: logger.log_error("maybe has no network",\ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name,sys._getframe().f_lineno) if co.check_package_exist(sn,flag) == 0: expect_size = int(co.get_packagesize_from_json_file(sn,flag)) while True: actual_size = co.check_package_size(sn,flag,30) value_list.append(int(actual_size)) # print(actual_size) if actual_size is not None and int(actual_size) < expect_size: time.sleep(random.randint(60,100)) co.reboot_device(sn) co.wait_hu_recovery(sn) # co.start_fota_daemon(sn) elif actual_size is None and co.check_package_exist(sn,flag,30) == 1: return 1 if int(actual_size) == expect_size: co.start_fota_daemon(sn) logger.log_info("check break point resume with network successfully",\ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 0 if len(value_list) >=5 : i=0 while i <= len(value_list) -2: if value_list[i] == value_list[i+1]: i = i + 1 else : break if i == len(value_list) -1: logger.error("package size can not change,and package always is :%s" % (actual_size), \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1 else: logger.log_error("can not find package", \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1 else: logger.log_error("flash system failed or start fota module failed", \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1 except Exception as e: logger.log_error("%s" %(e),\ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1
def check_data_json(self,sn,delay_time): ''' function: return data.json if exist :param sn: :return: ''' if self.prepare_old_system(sn) == 0: co.delete_file(sn) time.sleep(5) co.reboot_device(sn) time.sleep(2) co.wait_hu_recovery(sn) return co.check_json_file(sn,delay_time)
def check_package_upgradeprogress(self,sn,flag): ''' function:check full package upgrade progress :param sn: :param flag: :return: ''' co.delete_file(sn) time.sleep(5) try: # package.flash_through_system(sn) if package.update_system_through_fastboot(retry_times) == 0 and co.start_fota_daemon(sn) == 0: # if co.start_fota_daemon(sn) == 0: time.sleep(5) if self.get_requestdata_to_file(sn) == 1: logger.log_error("may be has not network", \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1 if co.check_package_exist(sn,flag) == 0: time.sleep(5) if package.check_download_progress(sn,flag) == 0 and self.check_libHu_fota(sn): time.sleep(5) co.reboot_device(sn) time.sleep(2) co.wait_hu_recovery(sn) if self.check_system_version(sn) == 0: logger.log_info("upgrade system success",\ sys._getframe().f_code.co_filename,sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 0 elif self.check_system_version(sn) == 1: logger.log_error("upgrade system failed",\ sys._getframe().f_code.co_filename,sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1 else: logger.log_error("download failed or install failed",\ sys._getframe().f_code.co_filename,sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1 else: logger.log_error("can not find %s" %(co.get_packagename_from_json_file(sn,flag)),\ sys._getframe().f_code.co_filename,sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1 else: logger.log_error("flash system failed or start fota module failed",\ sys._getframe().f_code.co_filename,sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1 except Exception as e: logger.log_error("%s" %(e),\ sys._getframe().f_code.co_filename,sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1
def check_delete_updatedirectory(self, sn, flag): ''' function: check delete /update directory and reboot system :param sn: :return: ''' try: if package.update_system_through_fastboot(retry_times) == 0 and co.start_fota_daemon(sn) == 0: # if co.start_fota_daemon(sn) == 0: time.sleep(5) if self.get_requestdata_to_file(sn) == 1: logger.log_error("maybe has no network",\ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1 if co.check_package_exist(sn, flag) == 0: expect_size = int(co.get_packagesize_from_json_file(sn, flag)) while True: actual_size = co.check_package_size(sn, flag, 30) if int(actual_size) == expect_size: break while True: if check_message.check_libHUfota_exist(sn): time.sleep(random.randint(5,10)) co.delete_file(sn) time.sleep(random.randint(5,10)) co.reboot_device(sn) return co.wait_hu_recovery(sn) else : logger.log_error("can not find libHUfota log", \ sys._getframe().f_code.co_filename,sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1 else: logger.log_error("check delete updated directory failed",\ sys._getframe().f_code.co_filename,sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1 else: logger.log_error("flash system failed or start fota module failed", \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1 except Exception as e: logger.log_error("%s" %(e),\ sys._getframe().f_code.co_filename,sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1
def check_md5_file(self,sn, flag): ''' function: check md5 file :param sn: :return: ''' co.delete_file(sn) time.sleep(5) # package.flash_through_system(sn) try: if package.update_system_through_fastboot(retry_times) == 0 and co.start_fota_daemon(sn) == 0: # if co.start_fota_daemon(sn) == 0: time.sleep(5) if self.get_requestdata_to_file(sn) == 1: logger.log_error("maybe has no network",\ sys._getframe().f_code.co_filename,sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1 if co.check_package_exist(sn,flag) == 0: try: sign_value = co.get_md5_value_from_datafile(sn,flag) package_name = co.get_packagename_from_json_file(sn,flag) expect_size = int(co.get_packagesize_from_json_file(sn,flag)) while True: time.sleep(random.randint(20,60)) co.reboot_device(sn) co.wait_hu_recovery(sn) actual_size = co.check_package_size(sn,flag,30) if int(actual_size) == expect_size: break if co.get_md5_value(sn, package_name, "hu_package.zip") == sign_value: return 0 else: return 1 except Exception as e: logger.log_error("%s" %(e),\ sys._getframe().f_code.co_filename,sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1 else: return 1 except Exception as e: logger.log_error("%s" %(e),\ sys._getframe().f_code.co_filename,sys._getframe().f_code.co_name,sys._getframe().f_lineno) return 1
def prepare_activeupgrade_environment(self, sn, flag_mcu, flag_mpu): ''' function: check active upgrade :param sn: :return: ''' co.delete_file(sn) co.reboot_device(sn) co.wait_hu_recovery(sn) self.check_hu_network(sn) # time.sleep(5) try: if self.get_requestdata_to_file(sn) == 1: logger.log_error("maybe has no network", \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name, sys._getframe().f_lineno) return 1 pcan = SC.PCAN() pcan.poweron_and_clean() if self.mcu_mpu_download_status( sn, flag_mpu) == 0 and self.mcu_mpu_download_status( sn, flag_mcu) == 0: try: if co.check_md5_status(sn) == 0: return 0 else: return 1 except Exception as e: logger.log_error("%s" % (e), \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name, sys._getframe().f_lineno) return 1 else: logger.log_error("can not find pakcage", \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name, sys._getframe().f_lineno) return 1 except Exception as e: logger.log_error("%s" % (e), \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name, sys._getframe().f_lineno) return 1
def upgrade_through_setting(self, sn, flag_mcu, flag_mpu): co.delete_file(sn) co.reboot_device(sn) co.wait_hu_recovery(sn) self.check_hu_network(sn) # time.sleep(5) try: if self.get_requestdata_to_file(sn) == 1: logger.log_error("maybe has no network", \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name, sys._getframe().f_lineno) return 1 pcan = SC.PCAN() pcan.poweron_and_clean() if self.mcu_mpu_download_status( sn, flag_mpu) == 0 and self.mcu_mpu_download_status( sn, flag_mcu) == 0: try: if co.check_md5_status(sn) == 0: if co.activeupgrade_through_setting( sn, SL.ActiveUpgrade, tbox_flag) == 0: time.sleep(20) if co.wait_hu_recovery(sn) == 0: while True: if Tbox_Information.check_ping_value( sn) == 0: co.open_tbox_adb() time.sleep(5) break Tbox_Information.copy_version_to_hu(sn) if Tbox_Information.check_system_version( sn) == 0: Tbox_Information.modify_tbox_config(sn) pcan = SC.PCAN() pcan.poweron_and_clean() return 0 else: Tbox_Information.modify_tbox_config(sn) pcan = SC.PCAN() pcan.poweron_and_clean() return 1 else: pcan = SC.PCAN() pcan.poweron_and_clean() logger.log_error("can not enter system", \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name, sys._getframe().f_lineno) return 1 else: pcan = SC.PCAN() pcan.poweron_and_clean() return 1 else: logger.log_error("check md5 value failed", \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name, sys._getframe().f_lineno) return 1 except Exception as e: logger.log_error("%s" % (e), \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name, sys._getframe().f_lineno) return 1 else: logger.log_error("can not find pakcage", \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name, sys._getframe().f_lineno) return 1 except Exception as e: logger.log_error("%s" % (e), \ sys._getframe().f_code.co_filename, sys._getframe().f_code.co_name, sys._getframe().f_lineno) return 1