[840] | 1 | # -*- coding: ISO-8859-1 -*- |
---|
| 2 | |
---|
| 3 | ################################## |
---|
[866] | 4 | # @program smon |
---|
[840] | 5 | # @description simulation monitor |
---|
[866] | 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 $ |
---|
[840] | 10 | # @lastrevision $Date: 2013-03-24 20:01:23 +0100 (Sun, 24 Mar 2013) $ |
---|
[866] | 11 | # @license CeCILL (http://dods.ipsl.jussieu.fr/jripsl/smon/LICENSE) |
---|
[840] | 12 | ################################## |
---|
| 13 | |
---|
[842] | 14 | import networkx as nx |
---|
| 15 | import pickle |
---|
| 16 | |
---|
[840] | 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 | |
---|
[866] | 27 | def __str__(self): |
---|
| 28 | return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) |
---|
[840] | 29 | |
---|
| 30 | class Tree(): |
---|
| 31 | |
---|
[866] | 32 | def __init__(self,**kw): |
---|
[840] | 33 | pass |
---|
| 34 | |
---|
[866] | 35 | def __str__(self): |
---|
| 36 | return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) |
---|
[840] | 37 | |
---|
[865] | 38 | class Simulation(): |
---|
| 39 | |
---|
[866] | 40 | def __init__(self,**kw): |
---|
[865] | 41 | self.exec_start_date=kw.get("exec_start_date") |
---|
| 42 | self.exec_end_date=kw.get("exec_end_date") |
---|
| 43 | self.status=kw.get("status") |
---|
[866] | 44 | self.name=kw.get("name") |
---|
[865] | 45 | |
---|
[866] | 46 | def __str__(self): |
---|
| 47 | return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) |
---|
[865] | 48 | |
---|
[866] | 49 | class Message(): |
---|
[875] | 50 | file=None |
---|
[866] | 51 | |
---|
| 52 | def __init__(self,JSON_KW): |
---|
| 53 | for key in JSON_KW: |
---|
| 54 | setattr(self, key, JSON_KW[key]) |
---|
| 55 | |
---|
| 56 | def __str__(self): |
---|
| 57 | return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) |
---|
| 58 | |
---|
[840] | 59 | class SimulationTree(Tree): |
---|
| 60 | |
---|
[866] | 61 | def __init__(self,**kw): |
---|
[842] | 62 | dg = nx.DiGraph() |
---|
[840] | 63 | |
---|
[842] | 64 | def update(cls): |
---|
| 65 | dg.add_edge('a','b') |
---|
[866] | 66 | |
---|
| 67 | def print__TODO(cls): |
---|
| 68 | print dg.edges() |
---|
[842] | 69 | |
---|
| 70 | def write(cls): |
---|
| 71 | pickle.dump(dg, open('/tmp/graph.txt', 'w')) |
---|
| 72 | |
---|
| 73 | def read(cls): |
---|
| 74 | dg = pickle.load(open('/tmp/graph.txt')) |
---|
| 75 | |
---|
[866] | 76 | def __str__(self): |
---|
| 77 | return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) |
---|
[840] | 78 | |
---|
| 79 | class SimulationTrees(): |
---|
| 80 | |
---|
[866] | 81 | def __init__(self,**kw): |
---|
| 82 | self.sample=kw.get("sample",[]) |
---|
[840] | 83 | |
---|
[866] | 84 | def __str__(self): |
---|
| 85 | return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) |
---|