Skip to content

Commit 42363e8

Browse files
committed
- Fixed bug introduced in recent changes to pycboard.transfer_file which could cause file transfer to fail silently.
1 parent c9b94ef commit 42363e8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

com/pycboard.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ def transfer_file(self, file_path, target_path=None):
183183
target_path = os.path.split(file_path)[-1]
184184
file_size = os.path.getsize(file_path)
185185
file_hash = _djb2_file(file_path)
186-
for i in range(3):
186+
error_message = '\n\nError: Unable to transfer file. See the troubleshooting docs:\n' \
187+
'https://pycontrol.readthedocs.io/en/latest/user-guide/troubleshooting/'
188+
# Try to load file, return once file hash on board matches that on computer.
189+
for i in range(10):
187190
if file_hash == self.get_file_hash(target_path):
188191
return
189192
self.exec_raw_no_follow("_receive_file('{}',{})"
@@ -199,12 +202,15 @@ def transfer_file(self, file_path, target_path=None):
199202
if response_bytes == b'NS':
200203
self.print('\n\nInsufficient space on pyboard filesystem to transfer file.')
201204
else:
202-
self.print('\n\nError: Unable to transfer file. See the troubleshooting docs:\n'
203-
'https://pycontrol.readthedocs.io/en/latest/user-guide/troubleshooting/')
205+
self.print(error_message)
204206
time.sleep(0.01)
205207
self.serial.reset_input_buffer()
206208
raise PyboardError
207209
self.follow(3)
210+
# Unable to transfer file.
211+
self.print(error_message)
212+
raise PyboardError
213+
208214

209215
def transfer_folder(self, folder_path, target_folder=None, file_type='all',
210216
show_progress=False):

0 commit comments

Comments
 (0)