[arch.cpu_manager] improvement: using '/bin/cp' instead of only 'cp' when changing cpu governor (only 'cp' may require confirmation)

This commit is contained in:
Vinicius Moreira
2022-04-12 10:10:31 -03:00
parent 1dc7ce327a
commit 4271d94b26

View File

@@ -1,5 +1,6 @@
import multiprocessing import multiprocessing
import os import os
import shutil
import traceback import traceback
from logging import Logger from logging import Logger
from typing import Optional, Set, Tuple, Dict from typing import Optional, Set, Tuple, Dict
@@ -42,7 +43,7 @@ def set_governor(governor: str, root_password: Optional[str], cpu_idxs: Optional
def _change_governor(cpu_idx: int, new_gov_file_path: str, root_password: Optional[str]): def _change_governor(cpu_idx: int, new_gov_file_path: str, root_password: Optional[str]):
try: try:
gov_file = f'/sys/devices/system/cpu/cpu{cpu_idx}/cpufreq/scaling_governor' gov_file = f'/sys/devices/system/cpu/cpu{cpu_idx}/cpufreq/scaling_governor'
replace = new_root_subprocess(['cp', new_gov_file_path, gov_file], root_password=root_password) replace = new_root_subprocess((shutil.which('cp'), new_gov_file_path, gov_file), root_password=root_password)
replace.wait() replace.wait()
except Exception: except Exception:
traceback.print_exc() traceback.print_exc()