fix uptime for MacOS

This commit is contained in:
William Bruno
2026-06-10 11:34:34 -04:00
parent 9dac5fe744
commit 6b5a1ea6ba
3 changed files with 9 additions and 4 deletions
+1
View File
@@ -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",
@@ -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 {
Generated
+2
View File
@@ -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" },