forked from M-Labs/artiq
flash: close files (c.f. #256)
This commit is contained in:
parent
355af3e569
commit
3ae44e762f
|
@ -97,7 +97,8 @@ def main():
|
||||||
elif action == "gateware":
|
elif action == "gateware":
|
||||||
bin = os.path.join(opts.dir, "top.bin")
|
bin = os.path.join(opts.dir, "top.bin")
|
||||||
if not os.access(bin, os.R_OK):
|
if not os.access(bin, os.R_OK):
|
||||||
bin = tempfile.mkstemp()[1]
|
bin_handle, bin = tempfile.mkstemp()
|
||||||
|
bin_handle.close()
|
||||||
bit = os.path.join(opts.dir, "top.bit")
|
bit = os.path.join(opts.dir, "top.bit")
|
||||||
conv = True
|
conv = True
|
||||||
prog.append("jtagspi_program {} 0x{:x}".format(
|
prog.append("jtagspi_program {} 0x{:x}".format(
|
||||||
|
|
|
@ -60,7 +60,8 @@ def bit2bin(bit, bin, flip=False):
|
||||||
d = bitfile.read(l)
|
d = bitfile.read(l)
|
||||||
if flip:
|
if flip:
|
||||||
d = flip32(d)
|
d = flip32(d)
|
||||||
open(bin, "wb").write(d)
|
with open(bin, "wb") as f:
|
||||||
|
f.write(d)
|
||||||
else:
|
else:
|
||||||
d = bitfile.read(*struct.unpack(">H", bitfile.read(2)))
|
d = bitfile.read(*struct.unpack(">H", bitfile.read(2)))
|
||||||
print("Unexpected key: ", key, d)
|
print("Unexpected key: ", key, d)
|
||||||
|
|
Loading…
Reference in New Issue