source: trunk/Monitoring/smon/types.py @ 876

Last change on this file since 876 was 876, checked in by jripsl, 11 years ago

Timeout test impl.
Add timestamp.

File size: 2.1 KB
Line 
1# -*- coding: ISO-8859-1 -*-
2
3##################################
4#  @program                smon
5#  @description    simulation monitor
6#  @copyright      Copyright “(c)2009 Centre National de la Recherche Scientifique CNRS.
7#                                                         All Rights Reserved”
8#  @svn_file       $Id: types.py 2599 2013-03-24 19:01:23Z jripsl $
9#  @version                $Rev: 2599 $
10#  @lastrevision   $Date: 2013-03-24 20:01:23 +0100 (Sun, 24 Mar 2013) $
11#  @license                CeCILL (http://dods.ipsl.jussieu.fr/jripsl/smon/LICENSE)
12##################################
13
14import networkx as nx
15import pickle
16
17CSTE_SAMPLE="2.2"
18
19class SMONException(Exception):
20        code=None
21        msg=None
22
23        def __init__(self, code=None,msg=None):
24                self.code=code
25                self.msg=msg
26
27        def __str__(self):
28                return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
29
30class MessageNotFoundException(SMONException):
31        pass
32
33class Tree():
34
35        def __init__(self,**kw):
36                pass
37
38        def __str__(self):
39                return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
40
41class Simulation():
42
43        def __init__(self,**kw):
44                self.exec_start_date=kw.get("exec_start_date")
45                self.exec_end_date=kw.get("exec_end_date")
46                self.status=kw.get("status")
47                self.name=kw.get("name")
48                self.id=kw.get("id")
49
50        def __str__(self):
51                return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
52
53class Message():
54        file=None
55        simuid=None
56        jobid=None
57        timestamp=None
58        command=None
59
60        def __init__(self,JSON_KW):
61                for key in JSON_KW:
62                        setattr(self, key, JSON_KW[key])
63
64        def __str__(self):
65                return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
66
67class SimulationTree(Tree):
68
69        def __init__(self,**kw):
70                dg = nx.DiGraph()
71
72        def update(cls):
73                dg.add_edge('a','b')
74       
75        def print__TODO(cls):
76                print dg.edges() 
77
78        def write(cls):
79                pickle.dump(dg, open('/tmp/graph.txt', 'w'))
80
81        def read(cls):
82                dg = pickle.load(open('/tmp/graph.txt'))
83
84        def __str__(self):
85                return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
86
87class SimulationTrees():
88
89        def __init__(self,**kw):
90                self.sample=kw.get("sample",[])
91
92        def __str__(self):
93                return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
Note: See TracBrowser for help on using the repository browser.