From 20aeb0b72e5696027d7748e061a1659d97d84ba5 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 10 Nov 2023 21:55:41 +0100 Subject: [PATCH] [`system`] Some versions of `cpuinfo` may return cache sizes in human-readable format. --- platypush/schemas/system/_cpu/_base.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/platypush/schemas/system/_cpu/_base.py b/platypush/schemas/system/_cpu/_base.py index a1a5b1e6d..c1bbf78bd 100644 --- a/platypush/schemas/system/_cpu/_base.py +++ b/platypush/schemas/system/_cpu/_base.py @@ -16,6 +16,19 @@ class CpuInfoBaseSchema(SystemBaseSchema): if data.get('hz_actual'): data['frequency_actual'] = data.pop('hz_actual')[0] + for key, value in data.items(): + if key.endswith("_cache_size") and isinstance(value, str): + value, unit = value.split(" ") + value = int(value) + if unit == "KiB": + value *= 1024 + elif unit == "MiB": + value *= 1024 * 1024 + elif unit == "GiB": + value *= 1024 * 1024 * 1024 + + data[key] = value + return data