Skip to content

Commit

Permalink
Merge pull request #71 from mengmeet/win4_7840
Browse files Browse the repository at this point in the history
Add fans config for Win4 7840
  • Loading branch information
honjow authored Apr 25, 2024
2 parents 82358f8 + 5b5e48e commit 85e6b64
Show file tree
Hide file tree
Showing 5 changed files with 272 additions and 158 deletions.
40 changes: 35 additions & 5 deletions backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@
cpuinfo = open(cpuinfo_path, "r").read()
CPU_ID = cpuinfo.split("model name")[1].split(":")[1].split("\n")[0].strip()
PRODUCT_NAME = open("/sys/devices/virtual/dmi/id/product_name", "r").read().strip()
logging.info(f"CPU_ID: {CPU_ID}, PRODUCT_NAME: {PRODUCT_NAME}")
PRODUCT_VERSION = (
open("/sys/devices/virtual/dmi/id/product_version", "r").read().strip()
)
logging.info(
f"CPU_ID: {CPU_ID}, PRODUCT_NAME: {PRODUCT_NAME}, PRODUCT_VERSION: {PRODUCT_VERSION}"
)
except Exception as e:
logging.error(f"设备信息配置异常|{e}")

Expand Down Expand Up @@ -150,12 +155,37 @@ def load_yaml(file_path: str, chk_schema=None) -> dict:
data = load_yaml(config, ec_schema)
if data == {}:
continue
names = data["product_name"]
if not names is None:
for name in names:
names = (
data["product_name"]
if (
"product_name" in data
and data["product_name"] != None
and isinstance(data["product_name"], list)
)
else []
)
versions = (
data["product_version"]
if (
"product_version" in data
and data["product_version"] != None
and isinstance(data["product_version"], list)
)
else []
)
for name in names:
if len(versions) == 0:
FAN_EC_CONFIG_MAP[name] = data["fans"]
else:
for version in versions:
FAN_EC_CONFIG_MAP[f"{name}{version}"] = data["fans"]

FAN_EC_CONFIG = FAN_EC_CONFIG_MAP.get(PRODUCT_NAME, [])
logging.debug(f"FAN_EC_CONFIG_MAP: {FAN_EC_CONFIG_MAP}")

product_version = PRODUCT_VERSION if PRODUCT_VERSION != "Default string" else ""
key = f"{PRODUCT_NAME}{product_version}"
logging.info(f"风扇配置key: {key}")
FAN_EC_CONFIG = FAN_EC_CONFIG_MAP.get(key, [])
logging.info(f"FAN_EC_CONFIG: {FAN_EC_CONFIG}")


Expand Down
Loading

0 comments on commit 85e6b64

Please sign in to comment.