Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
honjow committed Jun 28, 2024
1 parent 420bb95 commit 02c2e29
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 101 deletions.
13 changes: 7 additions & 6 deletions backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
if f.read().strip() == "1":
AMD_GPU_DEVICE_PATH = f"{p}/device"
AMD_GPUFREQ_PATH = f"{AMD_GPU_DEVICE_PATH}/pp_od_clk_voltage"
AMD_GPULEVEL_PATH = f"{AMD_GPU_DEVICE_PATH}/power_dpm_force_performance_level"
AMD_GPULEVEL_PATH = (
f"{AMD_GPU_DEVICE_PATH}/power_dpm_force_performance_level"
)

# read adn write
INTEL_GPU_MIN_FREQ = f"{p}/gt_min_freq_mhz"
Expand Down Expand Up @@ -178,7 +180,7 @@ def get_all_howmon_fans():
if data == {}:
continue
name = data["hwmon_name"]
if not name is None:
if name is not None:
fans_confs[name] = data["fans"]
return fans_confs

Expand All @@ -196,7 +198,7 @@ def get_device_ec_fans(p_name, p_version):
data["product_name"]
if (
"product_name" in data
and data["product_name"] != None
and data["product_name"] is not None
and isinstance(data["product_name"], list)
)
else []
Expand All @@ -205,7 +207,7 @@ def get_device_ec_fans(p_name, p_version):
data["product_version"]
if (
"product_version" in data
and data["product_version"] != None
and data["product_version"] is not None
and isinstance(data["product_version"], list)
)
else []
Expand All @@ -226,7 +228,7 @@ def get_device_ec_fans(p_name, p_version):
logging.info(f"conf of {p_name}: {conf}")
if (
p_version in conf["product_version"]
and conf["product_version"] != None
and conf["product_version"] is not None
and isinstance(conf["product_version"], list)
and len(conf["product_version"]) > 0
):
Expand All @@ -246,7 +248,6 @@ def get_device_ec_fans(p_name, p_version):

# 风扇配置
try:

FAN_HWMON_LIST = get_all_howmon_fans()

FAN_EC_CONFIG = get_device_ec_fans(PRODUCT_NAME, PRODUCT_VERSION)
Expand Down
6 changes: 3 additions & 3 deletions backend/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def set_cpuTDP_Intel(self, value: int):
with open(rapl_short, "w") as file:
file.write(str(tdp))
return True

except Exception as e:
logging.error(e, exc_info=True)
return False
Expand Down Expand Up @@ -523,15 +523,15 @@ def get_ryzenadj_info(self):
except Exception as e:
logging.error(e)
return f"get_ryzenadj_info error:\n{e}"

def get_max_perf_pct(self):
max_perf_pct_path = "/sys/devices/system/cpu/intel_pstate/max_perf_pct"
if os.path.exists(max_perf_pct_path):
with open(max_perf_pct_path, "r") as file:
return int(file.read().strip())
else:
return 0

def set_max_perf_pct(self, value: int):
max_perf_pct_path = "/sys/devices/system/cpu/intel_pstate/max_perf_pct"
try:
Expand Down
Loading

0 comments on commit 02c2e29

Please sign in to comment.