build/generic_programmer: catch 404 not found when downloading config/proxy.
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 5 May 2020 10:16:29 +0000 (12:16 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 5 May 2020 10:16:29 +0000 (12:16 +0200)
litex/build/generic_programmer.py

index 2927d82987141f02ab447fb5858a7a416201f2a1..cb0597d1db3f169b6235b0966d3bdcb57b1bdd4e 100644 (file)
@@ -47,9 +47,10 @@ class GenericProgrammer:
             fullname = tools.cygpath(os.path.join(self.prog_local, self.flash_proxy_basename))
             try:
                 r = requests.get(d + self.flash_proxy_basename)
-                with open(fullname, "wb") as f:
-                    f.write(r.content)
-                return fullname
+                if r.status_code != 404:
+                    with open(fullname, "wb") as f:
+                        f.write(r.content)
+                    return fullname
             except:
                 pass
         raise OSError("Failed to find flash proxy bitstream")
@@ -70,9 +71,10 @@ class GenericProgrammer:
             fullname = tools.cygpath(os.path.join(self.prog_local, self.config))
             try:
                 r = requests.get(d + self.config)
-                with open(fullname, "wb") as f:
-                    f.write(r.content)
-                return fullname
+                if r.status_code != 404:
+                    with open(fullname, "wb") as f:
+                        f.write(r.content)
+                    return fullname
             except:
                 pass
         raise OSError("Failed to find config file")