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

Fix powermetrics test asking for password on Linux #576

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix powermetrics test asking for password on Linux
  • Loading branch information
benoit-cty committed Jun 16, 2024
commit 29b5b804047b18d062afd6db250d64622df50d7b
8 changes: 8 additions & 0 deletions codecarbon/core/powermetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ def is_powermetrics_available():


def _has_powermetrics_sudo():
if shutil.which("sudo") is None:
logger.debug("sudo not available, we won't use Apple PowerMetrics.")
return False
if shutil.which("powermetrics") is None:
logger.info(
"Apple PowerMetrics not available. Please install it if you are using an Apple product."
)
return False
process = subprocess.Popen(
[
"sudo",
Expand Down
Loading