-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add prompting to deploy even when the board configuration is unexpected #17
base: main
Are you sure you want to change the base?
add prompting to deploy even when the board configuration is unexpected #17
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Tammy, looks great. I left 2 suggestions, removing the unused imports and I think we should only allow the override if someone specified the device (the device wasn't auto-detected). I don't think it should be possible to auto-detect an incorrect device but just in case we missed something.
|
||
import shutil | ||
import platform | ||
import os # pylint:disable=unused-import |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If imports are unused, please remove instead of ignoring.
return | ||
if not has_correct_size(device): | ||
print('Specified CircuitPython drive is larger than expected (~{:0d}MB).'.format(int(DEFAULT_BOARD_CAPACITY // 1E6))) | ||
if not warning_prompt(f'Are you sure you want to deploy to {device}?'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not warning_prompt(f'Are you sure you want to deploy to {device}?'): | |
if not args.device or not warning_prompt(f'Are you sure you want to deploy to {device}?'): |
Only allow override only if the device was specified (not auto detected). Otherwise someone might blast through the warning and erase their hard drive.
user_confirmed = True | ||
if not has_correct_label(device, expected_label): | ||
print(f'Expected device to have {expected_label} in path.') | ||
if not warning_prompt(f'Are you sure you want to deploy to {device}?'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not warning_prompt(f'Are you sure you want to deploy to {device}?'): | |
if not args.device or not warning_prompt(f'Are you sure you want to deploy to {device}?'): |
This is a fix for #14 and implements some checking to make the code (cautiously) deploy even when the target directory doesn't appear to be a valid CircuitPython device. If the directory the user is deploying to does not have the right label, or appears to be larger than what we'd expect a microcontroller device to be, the user will be prompted for confirmation before deploying to that device.