[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 | |
---|
[876] | 30 | class MessageNotFoundException(SMONException): |
---|
| 31 | pass |
---|
| 32 | |
---|
[840] | 33 | class Tree(): |
---|
| 34 | |
---|
[866] | 35 | def __init__(self,**kw): |
---|
[840] | 36 | pass |
---|
| 37 | |
---|
[866] | 38 | def __str__(self): |
---|
| 39 | return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) |
---|
[840] | 40 | |
---|
[865] | 41 | class Simulation(): |
---|
| 42 | |
---|
[866] | 43 | def __init__(self,**kw): |
---|
[865] | 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") |
---|
[866] | 47 | self.name=kw.get("name") |
---|
[876] | 48 | self.id=kw.get("id") |
---|
[865] | 49 | |
---|
[866] | 50 | def __str__(self): |
---|
| 51 | return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) |
---|
[865] | 52 | |
---|
[866] | 53 | class Message(): |
---|
[879] | 54 | type=None |
---|
[875] | 55 | file=None |
---|
[876] | 56 | simuid=None |
---|
| 57 | jobid=None |
---|
| 58 | timestamp=None |
---|
[879] | 59 | crea_date=None |
---|
[876] | 60 | command=None |
---|
[879] | 61 | body=None |
---|
[866] | 62 | |
---|
| 63 | def __init__(self,JSON_KW): |
---|
| 64 | for key in JSON_KW: |
---|
| 65 | setattr(self, key, JSON_KW[key]) |
---|
| 66 | |
---|
| 67 | def __str__(self): |
---|
| 68 | return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) |
---|
| 69 | |
---|
[840] | 70 | class SimulationTree(Tree): |
---|
| 71 | |
---|
[866] | 72 | def __init__(self,**kw): |
---|
[842] | 73 | dg = nx.DiGraph() |
---|
[840] | 74 | |
---|
[842] | 75 | def update(cls): |
---|
| 76 | dg.add_edge('a','b') |
---|
[866] | 77 | |
---|
| 78 | def print__TODO(cls): |
---|
| 79 | print dg.edges() |
---|
[842] | 80 | |
---|
| 81 | def write(cls): |
---|
| 82 | pickle.dump(dg, open('/tmp/graph.txt', 'w')) |
---|
| 83 | |
---|
| 84 | def read(cls): |
---|
| 85 | dg = pickle.load(open('/tmp/graph.txt')) |
---|
| 86 | |
---|
[866] | 87 | def __str__(self): |
---|
| 88 | return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) |
---|
[840] | 89 | |
---|
| 90 | class SimulationTrees(): |
---|
| 91 | |
---|
[866] | 92 | def __init__(self,**kw): |
---|
| 93 | self.sample=kw.get("sample",[]) |
---|
[840] | 94 | |
---|
[866] | 95 | def __str__(self): |
---|
| 96 | return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) |
---|