Exemple #1
0
 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
Exemple #2
0
 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