Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tammymakesthings
Copy link
Contributor

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.

Copy link
Owner

@mraleson mraleson left a 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
Copy link
Owner

@mraleson mraleson May 6, 2022

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}?'):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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}?'):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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}?'):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants