diff --git a/pyproject.toml b/pyproject.toml index 0789a53..0640e58 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,7 @@ dependencies = [ "geopy[aiohttp]==2.4.1", "httpx>=0.28.1", "numpy==2.4.3", + "psutil>=7.2.2", "pydantic==2.12.5", "pyicloud>=2.4.1", "pymobiledevice3==9.8.1", diff --git a/src/pymd3_vue_location_sim/simulation_service.py b/src/pymd3_vue_location_sim/simulation_service.py index f2c3a5b..a085f29 100644 --- a/src/pymd3_vue_location_sim/simulation_service.py +++ b/src/pymd3_vue_location_sim/simulation_service.py @@ -1,4 +1,6 @@ import asyncio +import psutil +import datetime import math import random import traceback @@ -563,10 +565,10 @@ class SimulationService: } def get_uptime(self) -> float: - with open('/proc/uptime', 'r') as f: - # The first number is total uptime seconds - uptime_seconds = float(f.readline().split()[0]) - return uptime_seconds + boot_time_timestamp = psutil.boot_time() + boot_time = datetime.datetime.fromtimestamp(boot_time_timestamp) + uptime = datetime.datetime.now() - boot_time + return uptime def get_status(self) -> dict: return { diff --git a/uv.lock b/uv.lock index 8ee3e58..feb774b 100644 --- a/uv.lock +++ b/uv.lock @@ -1347,6 +1347,7 @@ dependencies = [ { name = "geopy", extra = ["aiohttp"] }, { name = "httpx" }, { name = "numpy" }, + { name = "psutil" }, { name = "pydantic" }, { name = "pyicloud" }, { name = "pymobiledevice3" }, @@ -1368,6 +1369,7 @@ requires-dist = [ { name = "geopy", extras = ["aiohttp"], specifier = "==2.4.1" }, { name = "httpx", specifier = ">=0.28.1" }, { name = "numpy", specifier = "==2.4.3" }, + { name = "psutil", specifier = ">=7.2.2" }, { name = "pydantic", specifier = "==2.12.5" }, { name = "pyicloud", specifier = ">=2.4.1" }, { name = "pymobiledevice3", specifier = "==9.8.1" },