From 6f8094c750a4b06dda31e969fec51c47cd1aca03 Mon Sep 17 00:00:00 2001 From: Nayil Mukhametshin <66028747+nlscc@users.noreply.github.com> Date: Wed, 30 Sep 2020 00:05:27 +0100 Subject: add better error handling, fix #9 --- samloader/main.py | 3 +++ samloader/versionfetch.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/samloader/main.py b/samloader/main.py index 9088e45..f828208 100644 --- a/samloader/main.py +++ b/samloader/main.py @@ -16,6 +16,9 @@ def getbinaryfile(client, fw, region, model): req = request.binaryinform(fw, region, model, client.nonce) resp = client.makereq("NF_DownloadBinaryInform.do", req) root = ET.fromstring(resp) + status = root.find("./FUSBody/Results/Status").text + if status != 200: + raise Exception("DownloadBinaryInform returned {}, firmware could not be found?".format(status)) filename = root.find("./FUSBody/Put/BINARY_NAME/Data").text path = root.find("./FUSBody/Put/MODEL_PATH/Data").text return path, filename diff --git a/samloader/versionfetch.py b/samloader/versionfetch.py index 98200b8..d173486 100644 --- a/samloader/versionfetch.py +++ b/samloader/versionfetch.py @@ -11,6 +11,8 @@ def getlatestver(region, model): r.raise_for_status() root = ET.fromstring(r.text) vercode = root.find("./firmware/version/latest").text + if vercode is None: + raise Exception("No latest firmware found") vc = vercode.split("/") if len(vc) == 3: vc.append(vc[0]) -- cgit v1.2.3