-
Notifications
You must be signed in to change notification settings - Fork 2
/
info.py
71 lines (58 loc) · 1.51 KB
/
info.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
67
68
69
70
from sets import Set
from sh import ssh
from sh import grep
from sh import sort
#ssh [email protected] module -l avail 2>&1 >/dev/null | grep default | awk '{print $1}'
user="gvonlasz"
#
#"delta.futuregrid.org",
#
# "foxtrot.futuregrid.org",
#"alamo.futuregrid.org",
hosts=[
"hotel.futuregrid.org",
"india.futuregrid.org",
"sierra.futuregrid.org",
]
def get_default_modules(user,host):
list = {}
print host
result = sort(ssh("{0}@{1}".format(user,host), "module", "-l", "avail", "2>&1"))
print "ok"
for line in result:
if "default" in line:
content = line.split()
print content
try:
(module_package, module_version) = content[0].split("/")
list[module_package] = module_version
except:
pass
return list
allkeys = Set()
modules = {}
for host in hosts:
list = get_default_modules(user, host)
modules[host] = list
print modules[host]
allkeys = allkeys.union(modules[host].keys())
print allkeys
table = []
line = ","
for host in hosts:
line = line + host + ","
line = line[:-1] + "\n"
for key in sorted(allkeys):
line = line + key + ","
for host in hosts:
try:
line = line + modules[host][key]
except:
pass
line = line + ","
line = line[:-1] + "\n"
#, >/dev/null | grep default | awk '{print $1}'
f = open ("module-list.rst", "w")
f.write(line)
close(f)
print line