MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / GetBootTime

Method GetBootTime

class/system.py:316–338  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

314 return version
315
316 def GetBootTime(self):
317 # 取系统启动时间
318 key = 'sys_time'
319 sys_time = cache.get(key)
320 if sys_time: return sys_time
321 import public, math
322 conf = public.readFile('/proc/uptime').split()
323 tStr = float(conf[0])
324 min = tStr / 60
325 hours = min / 60
326 days = math.floor(hours / 24)
327 hours = math.floor(hours - (days * 24))
328 min = math.floor(min - (days * 60 * 24) - (hours * 60))
329
330 sys_time = "{}天".format(int(days))
331 if int(days) == 0:
332 sys_time = "{}小时".format(int(hours))
333 if int(hours) == 0:
334 sys_time = "{}分钟".format(int(min))
335
336 cache.set(key, sys_time, 300)
337 return sys_time
338 # return public.getMsg('SYS_BOOT_TIME',(str(int(days)),str(int(hours)),str(int(min))))
339
340 def GetCpuInfo(self, interval=1):
341 # 取CPU信息

Callers 3

GetSystemTotalMethod · 0.95
GetAllInfoMethod · 0.95
GetNetWorkMethod · 0.95

Calls 6

readFileMethod · 0.80
floorMethod · 0.80
getMethod · 0.45
splitMethod · 0.45
formatMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected