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 | |
---|
14 | import networkx as nx |
---|
15 | import pickle |
---|
16 | |
---|
17 | CSTE_SAMPLE="2.2" |
---|
18 | |
---|
19 | class 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 | |
---|
30 | class Tree(): |
---|
31 | |
---|
32 | def __init__(self,**kw): |
---|
33 | pass |
---|
34 | |
---|
35 | def __str__(self): |
---|
36 | return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) |
---|
37 | |
---|
38 | class SimulationTree(Tree): |
---|
39 | |
---|
40 | def __init__(self,**kw): |
---|
41 | dg = nx.DiGraph() |
---|
42 | |
---|
43 | def update(cls): |
---|
44 | dg.add_edge('a','b') |
---|
45 | |
---|
46 | def print(cls): |
---|
47 | print dg.edges() |
---|
48 | |
---|
49 | def write(cls): |
---|
50 | pickle.dump(dg, open('/tmp/graph.txt', 'w')) |
---|
51 | |
---|
52 | def read(cls): |
---|
53 | dg = pickle.load(open('/tmp/graph.txt')) |
---|
54 | |
---|
55 | def __str__(self): |
---|
56 | return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) |
---|
57 | |
---|
58 | class SimulationTrees(): |
---|
59 | |
---|
60 | def __init__(self,**kw): |
---|
61 | self.sample=kw.get("sample",[]) |
---|
62 | |
---|
63 | def __str__(self): |
---|
64 | return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) |
---|