fix: Log the used method as well.
This commit is contained in:
parent
4943536a14
commit
e6bf1b3b1d
@ -1418,12 +1418,15 @@ def time_rfc2822():
|
|||||||
|
|
||||||
def uptime():
|
def uptime():
|
||||||
uptime_str = '??'
|
uptime_str = '??'
|
||||||
|
method = 'unknown'
|
||||||
try:
|
try:
|
||||||
if os.path.exists("/proc/uptime"):
|
if os.path.exists("/proc/uptime"):
|
||||||
|
method = '/proc/uptime'
|
||||||
contents = load_file("/proc/uptime").strip()
|
contents = load_file("/proc/uptime").strip()
|
||||||
if contents:
|
if contents:
|
||||||
uptime_str = contents.split()[0]
|
uptime_str = contents.split()[0]
|
||||||
else:
|
else:
|
||||||
|
method = 'ctypes'
|
||||||
libc = ctypes.CDLL('/lib/libc.so.7')
|
libc = ctypes.CDLL('/lib/libc.so.7')
|
||||||
size = ctypes.c_size_t()
|
size = ctypes.c_size_t()
|
||||||
buf = ctypes.c_int()
|
buf = ctypes.c_int()
|
||||||
@ -1434,7 +1437,7 @@ def uptime():
|
|||||||
uptime_str = now - bootup
|
uptime_str = now - bootup
|
||||||
|
|
||||||
except:
|
except:
|
||||||
logexc(LOG, "Unable to read uptime")
|
logexc(LOG, "Unable to read uptime using method: %s" % method)
|
||||||
return uptime_str
|
return uptime_str
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user