1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2015 Pierre Ratinaud
7 from chemins import PathOut
8 from functions import exec_rcode, check_Rresult
9 from dialog import MergeDialog
11 from time import sleep
12 from PrintRScript import MergeGraphes
14 def merge_graphes(lgraphes):
15 script = MergeGraphes({'lgraphes':lgraphes, 'grapheout' : '/tmp/graphe.graphml'})
21 def __init__(self, ira, parametres, dlg = None):
24 self.parametres = parametres
25 if 'pathout' not in self.parametres :
26 self.parametres['pathout'] = PathOut(self.parametres['fileout'], analyse_type = self.parametres['type'], dirout = os.path.dirname(self.parametres['fileout'])).mkdirout()
27 self.pathout = PathOut(analyse_type = self.parametres['type'], dirout = self.parametres['pathout'])
29 self.pathout = PathOut(dirout = self.parametres['pathout'], analyse_type = self.parametres['type'])
30 if self.doparametres(dlg=dlg) is not None :
31 script = merge_graphes(self.parametres['graphs'])
32 self.doR(script.scriptout, dlg=False)
36 def doparametres(self, dlg=None):
38 dial = MergeDialog(self.ira)
39 res = dial.ShowModal()
41 self.parametres['graphs'] = [graph.GetPath() for graph in dial.graphs if graph.GetPath() != '']
45 def doR(self, Rscript, wait = False, dlg = None, message = '') :
46 #log.info('R code...')
47 pid = exec_rcode(self.ira.RPath, Rscript, wait = wait)
48 while pid.poll() is None :
50 self.dlg.Pulse(message)
54 return check_Rresult(self.ira, pid)