Project

General

Profile

Revision 54de53e3

ID54de53e3f971ad118145b9683ea128c19266c94f
Parent 09301287
Child 5b44cbbd

Added by Francis LAHEUGUERE over 14 years ago

Actualisation commentaires

git-svn-id: https://vigilo-dev.si.c-s.fr/svn@2456 b22e2e97-25c9-44ff-b637-2e5ceca36478

View differences:

vigigraph/lib/graphs.py
4 4
from tg import config
5 5

  
6 6
import string
7
import urllib
8
import urllib2
9
from pylons.i18n import ugettext as _
7 10

  
8 11
from time import gmtime, strftime
9 12
from datetime import datetime
......
18 21

  
19 22
    """
20 23
    graphslist = []
21
    format = "%d-%m-%Y %H:%M"
22
    for key in kwargs:
23
        # titre
24
        title = "Inconnu"
25
        graph = ""
26
        server = ""
27
        lca = kwargs[key].split("?")
28
        if len(lca) == 2:
29
            largs = lca[1].split("&")
30
            for arg in largs:
31
                larg = arg.split("=")
32
                if len(larg) == 2:
33
                    if larg[0] == "server":
34
                        server = larg[1]
35
                    elif larg[0] == "graphtemplate":
36
                        graph = larg[1]
37
                    elif larg[0] == "start":
38
                        start = larg[1]
39
                    elif larg[0] == "duration":
40
                        duration = larg[1]
41
        if graph != "" or server != "":
42
            title = "'%s' Graph for host %s" % \
43
              (urllib.unquote_plus(graph), server)
44
        graph = {}
45
        graph['title'] = title
46
        v = int(start)
47
        graph['sts'] = _(strftime(format, gmtime(v)))
48
        v = int(start) + int(duration)
49
        graph['ets'] = _(strftime(format, gmtime(v)))
50
        graph['src'] = urllib2.unquote(kwargs[key])
51
        graphslist.append(graph)
24
    
25
    if kwargs is not None:
26
        format = "%d-%m-%Y %H:%M"
27
        for key in kwargs:
28
            # titre
29
            title = "Inconnu"
30
            graph = ""
31
            server = ""
32
            # recherche arguments (apres ?) -> cle1=valeur1&cle2=valeur2&...
33
            lca = kwargs[key].split("?")
34
            if len(lca) == 2:
35
                # analyse de chacun des arguments -> cle=valeur
36
                largs = lca[1].split("&")
37
                for arg in largs:
38
                    larg = arg.split("=")
39
                    if len(larg) == 2:
40
                        if larg[0] == "server":
41
                            server = larg[1]
42
                        elif larg[0] == "graphtemplate":
43
                            graph = larg[1]
44
                        elif larg[0] == "start":
45
                            start = larg[1]
46
                        elif larg[0] == "duration":
47
                            duration = larg[1]
48
            if graph != "" or server != "":
49
                title = "'%s' Graph for host %s" % \
50
                  (urllib.unquote_plus(graph), server)
51
            graph = {}
52
            graph['title'] = title
53
            v = int(start)
54
            graph['sts'] = _(strftime(format, gmtime(v)))
55
            v = int(start) + int(duration)
56
            graph['ets'] = _(strftime(format, gmtime(v)))
57
            graph['src'] = urllib2.unquote(kwargs[key])
58
            graphslist.append(graph)
59

  
52 60
    return graphslist
53 61

  
54 62
def tempoDelayRefresh():
......
141 149
    # format pour valeur temps
142 150
    format = '%Y/%m/%d %H:%M:%S'
143 151

  
144
    result = (dict_values is not None or dict_values != "{}")
152
    result = (writer is not None)
153
    result &= (dict_values is not None or dict_values != "{}")
145 154
    if result:
146 155
        # parcours valeurs
147 156
        for key_tv in dict_values:

Also available in: Unified diff