From: SnickerSun Date: Tue, 24 Sep 2024 13:32:15 +0000 (+0800) Subject: update checkota.py ,fix update isssue X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=d763c106b0906bffe47335e8febb3e0580acb12e;p=mirrors%2FFD230.git update checkota.py ,fix update isssue --- diff --git a/cat1modem/src/checkota.py b/cat1modem/src/checkota.py index a088eebe6..82efc2d78 100644 --- a/cat1modem/src/checkota.py +++ b/cat1modem/src/checkota.py @@ -14,7 +14,7 @@ import utime import log import uos -PROJECT_VERSION="PY_OTA_V13" +PROJECT_VERSION="PY_OTA_V12" CONFIG_JSON="/usr/system_config.json" CURRENT_APP_TYPE="pyota" # 设置日志输出级别 @@ -60,31 +60,31 @@ def get_version_from_json_config(app_type): return "" def result(args): - printf('download status:',args[0],'download process:',args[1]) + print('download status:',args[0],'download process:',args[1]) def check_fota(): modem_ver = modem.getDevFwVersion() imei = modem.getDevImei() url = "http://icfota.snicker.com.cn:8089/fd230ota.jsp?product=FD230&pkgver={0}&imei={1}".format(modem_ver,imei) response = request.get(url) - printf(url) + print(url) data = response.json() if(data['UptoDate'] == False): - printf("Need update python application") + print("Need update python application") fota_obj = fota() # 创建Fota对象 - printf("httpDownload...") + print("httpDownload...") srcurl = data['url'] #差分升级方式 # res = fota_obj.httpDownload(url1="http://www.example.com/fota.bin",callback=result) # mini fota方式 - printf("{},{}".format("{}/dfota_1.bin".format(srcurl),"{}/dfota_2.bin".format(srcurl))) + print("{},{}".format("{}/dfota_1.bin".format(srcurl),"{}/dfota_2.bin".format(srcurl))) res = fota_obj.httpDownload(url1="{}/dfota_1.bin".format(srcurl),url2="{}/dfota_2.bin".format(srcurl),callback=result) #差分升级FTP方式 #res = fota_obj.httpDownload(url1="ftp://user:password@ip:port/fota.bin",callback=result) #其中user,password,ip,port需要填写具体使用的FTP服务器信息 if res != 0: - printf("httpDownload error") + print("httpDownload error") return - printf("wait httpDownload update...") + print("wait httpDownload update...") else: print("No need update python application") @@ -101,7 +101,7 @@ def do_app_update_internal(app_type): print("Need update python application {}".format(data["appcount"])) for app_update in data["apps"]: srcurl = app_update['url'] - printf("run start...") + print("run start...") targetpyname = app_update['OtaPackageName'] version = app_update['OtaPackageVersion'] tmpfile_path = "/usr/.updater/{}".format(targetpyname) @@ -118,6 +118,11 @@ def do_app_update_internal(app_type): ql_fs.file_copy(targetfile_path, tmpfile_path) set_version_to_json_config(app_type,version) print("ota success") + if ql_fs.path_exists(tmpfile_path): + try: + uos.remove(tmpfile_path) + except Exception as e: + print("update remove出错 {}".format(e)) except Exception as e: print("ota failed!") else: