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

#183037159 ; alert when using battery power #238

Merged
merged 2 commits into from
Aug 29, 2022
Merged

#183037159 ; alert when using battery power #238

merged 2 commits into from
Aug 29, 2022

Conversation

lawhead
Copy link
Collaborator

@lawhead lawhead commented Aug 26, 2022

Overview

Added an alert to check for battery power before performing a task.

Ticket

https://www.pivotaltracker.com/story/show/183037159

Contributions

  • New system utility to check for battery power
  • New validation entry

Test

  • Ran unit tests
  • Ran calibration task both with laptop plugged in and once while unplugged to confirm that the alert appears correctly.

@lawhead lawhead requested a review from tab-cmd August 26, 2022 22:11
@@ -43,6 +43,12 @@ def is_connected(hostname: str = "1.1.1.1", port=80) -> bool:
return False


def is_battery_powered() -> bool:
"""Check if this current computer is a laptop currently using its battery."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Some more context may be useful! Returns True if the computer is currently running on battery power. This can impact the performance of hardware (ex. GPU) needed for BciPy operation by entering power saving operations.

@@ -25,7 +26,8 @@ def validate_bcipy_session(parameters: dict) -> bool:
True if it's okay to continue, otherwise False
"""
possible_alerts = [(parameters['fake_data'], '* Fake data is on.'),
(is_connected(), '* Internet is on.')]
(is_connected(), '* Internet is on.'),
(is_battery_powered(), '* Operating on battery power')]
Copy link
Contributor

Choose a reason for hiding this comment

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

This pattern is really coming in handy. It's clean 😎

@lawhead lawhead merged commit d9ddf4a into 2.0.0rc2 Aug 29, 2022
@lawhead lawhead deleted the power-alert branch August 29, 2022 18:18
@tab-cmd tab-cmd mentioned this pull request Sep 26, 2022
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