mirror of
https://github.com/Ryujinx/ryuko-ng.git
synced 2024-12-22 15:05:38 +00:00
Updated RAM regex to work with both MiB and GB units (#58)
* Updated RAM regex to work with both MiB and GB units * Set RAM values to something useful in the event of a parsing error * Ran python3 -m black .
This commit is contained in:
parent
151844fb3e
commit
7bcf3c28fe
|
@ -210,15 +210,24 @@ class LogAnalyser:
|
|||
|
||||
case "ram":
|
||||
ram_match = re.search(
|
||||
r"RAM:\s(Total)?\s([^;\n\r]*)\s;\s(Available)?\s(\d+)",
|
||||
r"RAM: Total ([\d.]+) (MiB|GB) ; Available ([\d.]+) (MiB|GB)",
|
||||
self._log_text,
|
||||
re.MULTILINE,
|
||||
)
|
||||
if ram_match is not None and ram_match.group(2) is not None:
|
||||
self._hardware_info[setting] = ram_match.group(2).rstrip()
|
||||
ram_available = ram_match.group(4).rstrip()
|
||||
if ram_available.isnumeric():
|
||||
if ram_match is not None:
|
||||
try:
|
||||
ram_available = float(ram_match.group(3))
|
||||
if ram_match.group(4) == "GB":
|
||||
ram_available *= 1024
|
||||
|
||||
self._hardware_info[
|
||||
setting
|
||||
] = f"{ram_match.group(1)} {ram_match.group(2)}"
|
||||
self._ram_available_mib = int(ram_available)
|
||||
except ValueError:
|
||||
# ram_match.group(3) couldn't be parsed as a float.
|
||||
self._hardware_info[setting] = "Error"
|
||||
self._ram_available_mib = -1
|
||||
|
||||
case "os":
|
||||
os_match = re.search(
|
||||
|
|
Loading…
Reference in a new issue