Commit 9f7a4a03 authored by Devaev Maxim's avatar Devaev Maxim

Added uptime() function to common_info

parent a0ec3f64
......@@ -14,6 +14,7 @@ SERVICE_NAME = "common_info"
COMMON_INFO_LSB_RELASE_METHODS_NAMESPACE = "commonInfo.lsb.release"
COMMON_INFO_UNAME_METHODS_NAMESPACE = "commonInfo.uname"
COMMON_INFO_TIME_METHODS_NAMESPACE = "commonInfo.time"
LSB_OPTION_VERSION = "--version"
LSB_OPTION_ID = "--id"
......@@ -95,6 +96,17 @@ class CommonInfo(service.FunctionObject) :
def operatingSystem(self) :
return self.unameOption(UNAME_OPTION_OPERATING_SYSTEM)
###
@service.functionMethod(COMMON_INFO_TIME_METHODS_NAMESPACE, out_signature="d")
def uptime(self) :
uptime_file = open("/proc/uptime")
uptime = float(uptime_file.read().split()[0])
try :
uptime_file.close()
except : pass
return uptime
### Private ###
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment