# -*- coding: ISO-8859-1 -*- ################################## # @program smon # @description simulation monitor # @copyright Copyright “(c)2009 Centre National de la Recherche Scientifique CNRS. # All Rights Reserved” # @svn_file $Id: types.py 2599 2013-03-24 19:01:23Z jripsl $ # @version $Rev: 2599 $ # @lastrevision $Date: 2013-03-24 20:01:23 +0100 (Sun, 24 Mar 2013) $ # @license CeCILL (http://dods.ipsl.jussieu.fr/jripsl/smon/LICENSE) ################################## import networkx as nx import pickle CSTE_SAMPLE="2.2" class SMONException(Exception): code=None msg=None def __init__(self, code=None,msg=None): self.code=code self.msg=msg def __str__(self): return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) class MessageNotFoundException(SMONException): pass class Tree(): def __init__(self,**kw): pass def __str__(self): return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) class Simulation(): def __init__(self,**kw): self.exec_start_date=kw.get("exec_start_date") self.exec_end_date=kw.get("exec_end_date") self.status=kw.get("status") self.name=kw.get("name") self.id=kw.get("id") def __str__(self): return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) class Message(): type=None file=None simuid=None jobid=None timestamp=None crea_date=None command=None body=None def __init__(self,JSON_KW): for key in JSON_KW: setattr(self, key, JSON_KW[key]) def __str__(self): return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) class SimulationTree(Tree): def __init__(self,**kw): dg = nx.DiGraph() def update(cls): dg.add_edge('a','b') def print__TODO(cls): print dg.edges() def write(cls): pickle.dump(dg, open('/tmp/graph.txt', 'w')) def read(cls): dg = pickle.load(open('/tmp/graph.txt')) def __str__(self): return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()]) class SimulationTrees(): def __init__(self,**kw): self.sample=kw.get("sample",[]) def __str__(self): return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])