Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / other / foldingathome_activecpu @ a7139bca

Historique | Voir | Annoter | Télécharger (1,7 ko)

1
#!/usr/bin/env python
2

    
3
# Written by Bertrand Grelot
4
# requires python-beautifulsoup
5

    
6
import os
7
import re
8
import sys
9
import urllib
10

    
11
from BeautifulSoup import BeautifulSoup
12

    
13
url = 'http://fah-web.stanford.edu/cgi-bin/main.py?qtype=osstats'
14

    
15
code = os.environ.get('code', sys.argv[0][(sys.argv[0].rfind('_') + 1):])
16

    
17
if code == None: sys.exit(1)
18

    
19
if len(sys.argv) == 2 and sys.argv[1] == "autoconf":
20
        print "yes"
21
elif len(sys.argv) == 2 and sys.argv[1] == "config":
22
        print 'graph_title Active CPU in FoldingAtHome project'
23
        print 'graph_vlabel Systems'
24
        print 'graph_category htc'
25

    
26
        print 'windows.label Windows'
27
        print 'ppc.label MacOS/PowerPC'
28
        print 'intel.label MacOS/Intel'
29
        print 'linux.label Linux'
30
        print 'ati.label ATI_gpu'
31
        print 'nvidia.label NVIDIA_gpu'
32
        print 'ps3.label Playstation3'
33

    
34
        print 'graph_args --base 1000 -l 0'
35
else:
36
        u = urllib.urlopen(url)
37
        soup = BeautifulSoup(u)
38
        u.close()
39

    
40
        l=[]
41
        i=0
42

    
43
        table = soup.find('table')
44
        rows = table.findAll('tr', bgcolor="#f5f5dc")
45

    
46
        for tr in rows:
47
                cols = tr.findAll('td')
48
                l.append([])
49
                for td in cols:
50
                        l[i].append(td.find(text=True))
51
                i+=1
52

    
53
        WIN=l[0][3]
54
        MPPC=l[1][3]
55
        MINTEL=l[2][3]
56
        LINUX=l[3][3]
57
        ATI=l[4][3]
58
        NVIDIA=l[5][3]
59
        PS3=l[6][3]
60

    
61
        print 'windows.value %s' % WIN
62
        print 'ppc.value %s' % MPPC
63
        print 'intel.value %s' % MINTEL
64
        print 'linux.value %s' % LINUX
65
        print 'ati.value %s' % ATI
66
        print 'nvidia.value %s' % NVIDIA
67
        print 'ps3.value %s' % PS3
68