Skip to content

Commit

Permalink
flash: close files (c.f. #256)
Browse files Browse the repository at this point in the history
jordens committed May 16, 2016
1 parent 355af3e commit 3ae44e7
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion artiq/frontend/artiq_flash.py
Original file line number Diff line number Diff line change
@@ -97,7 +97,8 @@ def main():
elif action == "gateware":
bin = os.path.join(opts.dir, "top.bin")
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")
conv = True
prog.append("jtagspi_program {} 0x{:x}".format(
3 changes: 2 additions & 1 deletion artiq/frontend/bit2bin.py
Original file line number Diff line number Diff line change
@@ -60,7 +60,8 @@ def bit2bin(bit, bin, flip=False):
d = bitfile.read(l)
if flip:
d = flip32(d)
open(bin, "wb").write(d)
with open(bin, "wb") as f:
f.write(d)
else:
d = bitfile.read(*struct.unpack(">H", bitfile.read(2)))
print("Unexpected key: ", key, d)

0 comments on commit 3ae44e7

Please sign in to comment.