Skip to content

Commit

Permalink
Merge pull request #576 from mlco2/fix/asking_root_#565
Browse files Browse the repository at this point in the history
Fix powermetrics test asking for password on Linux
  • Loading branch information
benoit-cty committed Jun 16, 2024
2 parents bf9468d + 29b5b80 commit 5744a3e
Showing 1 changed file with 8 additions and 0 deletions.
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

0 comments on commit 5744a3e

Please sign in to comment.