File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
contrib/dutlink/jumpstarter_driver_dutlink Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change 33import os
44from collections .abc import AsyncGenerator
55from dataclasses import dataclass , field
6- from pathlib import Path
76
87import pyudev
98import usb .core
@@ -94,13 +93,13 @@ async def write(self, src: str):
9493 with fail_after (20 ):
9594 while True :
9695 if os .path .exists (self .storage_device ):
96+ # https://stackoverflow.com/a/2774125
97+ fd = os .open (self .storage_device , os .O_WRONLY )
9798 try :
98- Path (self .storage_device ).write_bytes (b"\0 " )
99- except OSError :
100- pass # wait for device ready
101- else :
102- break
103-
99+ if os .lseek (fd , 0 , os .SEEK_END ) > 0 :
100+ break
101+ finally :
102+ os .close (fd )
104103 await sleep (1 )
105104
106105 async with await FileWriteStream .from_path (self .storage_device ) as stream :
You can’t perform that action at this time.
0 commit comments