Commit c041cd35 authored by Bonnegent's avatar Bonnegent
Browse files

ok sur linux et windows

parent 990a71e8
......@@ -21,31 +21,31 @@ class MyServer(BaseHTTPRequestHandler):
- uptime
Exemple:
os;os_version;état;charge
os;os_version;charge
"""
self.send_response(200)
os = self.get_os()
os_version = self.get_os_version()
# state = self.get_state()
load = self.get_load()
message = "%s;%s;%s" % (os, os_version, load)
self.wfile.write(bytes(message, "utf-8"))
def get_os(self):
try:
# partie os: le nom du système d'exploitation
os_name = "inconnue"
os_version = platform.version()
os_load = "inconnue"
system = platform.system()
if system == 'Linux':
# Linux Fedora 26
# Linux Ubuntu 17.04
# distrib = ('Fedora', '26', 'Twenty Six')
distrib = platform.dist()
# linux = ('Fedora', '26', 'Twenty Six')
except Exception:
name = "inconnue"
else:
try:
name = " ".join(distrib[:2])
except Exception:
name = distrib[0]
return name
os_name = "Linux %s" % " ".join(distrib[:2])
os_version = self.get_os_version()
os_load = self.get_load()
elif system == 'Windows':
# Windows 10
os_name = "%s %s" % (system, platform.release())
message = "%s;%s;%s" % (os_name, os_version, os_load)
self.wfile.write(bytes(message, "utf-8"))
def get_os_version(self):
"Cas des postes pédago"
file_version = "/etc/version"
try:
fd = open(file_version, 'r')
......@@ -54,13 +54,8 @@ class MyServer(BaseHTTPRequestHandler):
version = 'inconnue'
else:
version = tmp
return version
def get_state(self):
state = 'O'
return state
def get_load(self):
try:
load = os.getloadavg()[1]
......
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