Skip to content

Commit b735de6

Browse files
committed
send the new file to the hub upon change
1 parent 8e89cfb commit b735de6

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

pybricksdev/cli/__init__.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -291,22 +291,28 @@ async def reconnect_hub():
291291
).ask_async()
292292
)
293293
)
294-
with _get_script_path(args.file) as script_path:
295-
if response == response_options[0]:
296-
args.file.close()
297-
args.file = open(
298-
await hub.race_disconnect(
299-
hub.race_power_button_press(
300-
questionary.path(
301-
"What file would you like to use?"
302-
).ask_async()
303-
)
294+
295+
if response == response_options[0]:
296+
args.file.close()
297+
args.file = open(
298+
await hub.race_disconnect(
299+
hub.race_power_button_press(
300+
questionary.path(
301+
"What file would you like to use?"
302+
).ask_async()
304303
)
305304
)
305+
)
306+
307+
with _get_script_path(args.file) as script_path:
308+
# send the new target file to the hub
309+
if (
310+
response == response_options[0]
311+
or response == response_options[2]
312+
):
313+
await hub.download(script_path)
306314
elif response == response_options[1]:
307315
await hub.run(script_path, wait=True)
308-
elif response == response_options[2]:
309-
await hub.download(script_path)
310316
else:
311317
return
312318

@@ -326,6 +332,9 @@ async def reconnect_hub():
326332
await asyncio.sleep(0.3)
327333
hub = await reconnect_hub()
328334

335+
except FileNotFoundError:
336+
print("Your file is invalid.")
337+
329338
finally:
330339
await hub.disconnect()
331340

0 commit comments

Comments
 (0)