-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·72 lines (53 loc) · 2.15 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/python
# -*- coding: utf-8 -*-
#############################################################################
# Test : #
# Fichier pour tester la lecture et écriture XML. #
# #
# #
#############################################################################
from objets import *
from objets.cpu import *
from objets.disk import *
from objets.process import *
from objets.ram import *
from objets.server import *
from objets.swap import *
from objets.user import *
def main():
f = open("data/test.xml", "r")
xml = f.read()
print "Test serveur:"
s = Server()
s.parse_objet_xml(xml, "./server", ["name", "ip", "uptime"])
print s.name, " ", s.ip, " ", s.uptime
print "Test CPU:"
c = CPU()
c.parse_objet_xml(xml, "./cpu", ["used"])
print c.used
print "Test RAM:"
ram = ArrayDataObject()
ram.parse_objet_xml(xml, "./ram", ["used", "total"])
print ram.used, " ", ram.total, " ", int(ram.used) * 100 / int(ram.total), "%"
print "\nTest disques"
disques = ArrayDataObject.parse_list_xml(xml, "./disks", ["used", "total"])
for d in disques:
print d.used, " ", d.total
print "\nTest utilisateurs"
users = User.parse_list_xml(xml, "./users", ["name", "uid", "groupid", "isroot", "gname", "logintime"])
for d in users:
print d.name, " ", d.uid, " ", d.groupid, " ", d.isroot, " ", d.gname, " ", d.logintime
print "\nTest swap"
swap = Swap()
swap.parse_objet_xml(xml, "./swap", ["used", "total"])
print swap.used, " ", swap.total
print "\nTest processus"
proc = Process()
proc.parse_objet_xml(xml, "./processes", ["count", "zombies"])
print proc.count, " ", proc.zombies
print "\nTest greedy"
greedies = Process.parse_list_xml(xml, "./processes/greedy", ["pid", "cpu", "ram", "command"])
for g in greedies:
print g.pid, " ", g.cpu, " ", g.ram, " ", g.command
if __name__=="__main__":
main()