self.dlg = dlg
self.dialok = True
self.parametres = parametres
+ self.val = False
self.pathout = PathOut(corpus.parametres['originalpath'], analyse_type = parametres['type'], dirout = corpus.parametres['pathout'])
self.parametres = self.make_config(parametres)
log.info(self.pathout.dirout)
sleep(0.2)
else :
sleep(0.2)
- check_Rresult(self.ira, pid)
+ return check_Rresult(self.ira, pid)
import sys
import shutil
from chemins import ConstructConfigPath
-from functions import exec_rcode
+from functions import exec_rcode, exec_RCMD
import wx
import tempfile
from ConfigParser import *
from time import sleep
+import logging
+
+log = logging.getLogger('iramuteq.checkinstall')
def IsNew(self):
version_glob = self.ConfigGlob.get('DEFAULT', 'version_nb').split('.')
BestPath='/usr/local/bin/R'
return BestPath
-def CheckRapp(Path):
- return os.path.exists(Path)
-
def RLibsAreInstalled(self) :
rlibs = self.pref.get('iramuteq', 'rlibs')
- if rlibs == 'false' :
+ if rlibs == 'false' or rlibs == 'False' :
return False
else :
return True
+def install_textometrieR(self) :
+ dlg = wx.ProgressDialog("Installation de textometrieR",
+ "Veuillez patientez...",
+ maximum= 2,
+ parent=self,
+ style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME | wx.PD_CAN_ABORT
+ )
+ dlg.Center()
+ dlg.Update(1, 'Installation de textometrieR')
+ path = os.path.join(self.AppliPath, 'Rlib', 'textometrieR')
+ exec_RCMD(self.RPath, path)
+ dlg.Update(2,'fini')
+ dlg.Destroy()
+
def CheckRPackages(self):
- listdep = ['ca', 'gee', 'ape', 'igraph','proxy', 'Matrix','wordcloud']
+ listdep = ['ca', 'gee', 'ape', 'igraph','proxy', 'wordcloud', 'textometrieR']
nolib = []
i=0
dlg = wx.ProgressDialog("Test des librairies de R", "test en cours...", maximum = len(listdep), parent=self, style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME | wx.PD_CAN_ABORT)
dlg.Update(i, "test de %s" % bib)
txt = """library("%s")""" % bib
tmpscript = tempfile.mktemp(dir=self.TEMPDIR)
- file = open(tmpscript, 'w')
- file.write(txt)
- file.close()
+ with open(tmpscript, 'w') as f :
+ f.write(txt)
test = exec_rcode(self.RPath, tmpscript, wait = True)
if test :
+ log.info('packages %s : NOT INSTALLED' % bib)
nolib.append(bib)
+ else :
+ log.info('packages %s : OK' % bib)
dlg.Update(len(listdep),'fini')
dlg.Destroy()
+ install_textoR = False
+ if 'textometrieR' in nolib :
+ nolib.pop(nolib.index('textometrieR'))
+ install_textoR = True
if nolib != [] :
txt = '\n'.join(nolib)
msg = u"""Les bibliothèques de R suivantes sont manquantes :
Tapez install.packages('nom de la bibiothèque')
- ou laisser IRamuteq les installer automatiquement en cliquant sur VALIDER .
- Les bibliothèques seront téléchargées depuis le site miroir de R du CICT de Toulouse.
- """ % txt
+ Les bibliothèques seront téléchargées depuis le site miroir de R %s.
+ """ % (txt, self.pref.get('iramuteq','rmirror'))
dial = wx.MessageDialog(self, msg, u"Installation incomplète", wx.OK | wx.CANCEL | wx.NO_DEFAULT | wx.ICON_WARNING)
dial.CenterOnParent()
val = dial.ShowModal()
dlg.Center()
dlg.Update(1, u"installation...")
compt = 0
+
for bib in nolib :
compt += 1
dlg.Update(compt, u"installation librairie %s" % bib)
.libPaths
"""
txt += """
- install.packages("%s", repos = 'http://cran.cict.fr')
- """ % bib
+ install.packages("%s", repos = "%s")
+ """ % (bib, self.pref.get('iramuteq','rmirror'))
tmpscript = tempfile.mktemp(dir=self.TEMPDIR)
- file = open(tmpscript, 'w')
- file.write(txt)
- file.close()
+ with open(tmpscript, 'w') as f :
+ f.write(txt)
test = exec_rcode(self.RPath, tmpscript, wait = False)
while test.poll() == None :
dlg.Pulse(u"installation librairie %s" % bib)
sleep(0.2)
dlg.Update(len(nolib) + 1, 'fin')
dlg.Destroy()
- else :
- pass
dial.Destroy()
- else :
+ if install_textoR :
+ install_textometrieR(self)
+ if nolib == [] and not install_textoR :
self.pref.set('iramuteq', 'rlibs', True)
with open(self.ConfigPath['preferences'], 'w') as f :
self.pref.write(f)
[PATHS]\r
rpath = \r
lastpath = \r
-rapp = /Applications/R.app/Contents/MacOS/R\r
lim -= 1
else :
stop = nbmax - 1
- log.info('nb actives = %i - eff min = %i ' % (stop, lim))
+ lim = effs[stop]
+ log.info('nb actives = %i - eff min = %i ' % (stop + 1, lim))
return [val[1] for val in allactives[0:stop + 1]], lim
def make_and_write_profile(self, actives, ucecl, fileout) :
txt += exc
dial = BugDialog(parent)
- #for line in formatExceptionInfo():
- # if type(line) == type([]):
- # for don in line:
- # txt += don.replace(' ', ' ')
- # else:
- # txt += line + '\n'
if 'Rerror' in dir(parent) :
txt += parent.Rerror
parent.Rerror = ''
- #if error is not None :
- # txt += '\n%s\n' %error
- print formatExceptionInfo()
- log.error(txt)
+ log.info(txt)
dial.text_ctrl_1.write(txt)
dial.CenterOnParent()
dial.ShowModal()
- #raise Exception('Bug')
+ dial.Destroy()
def PlaySound(parent):
if parent.pref.getboolean('iramuteq', 'sound') :
i += 1
return dict, first
+def exec_RCMD(rpath, command) :
+ log.info('R CMD INSTALL %s' % command)
+ rpath = rpath.replace('\\','\\\\')
+ error = call(["%s" % rpath, 'CMD', 'INSTALL', "%s" % command])
+ return error
+
def exec_rcode(rpath, rcode, wait = True, graph = False):
log.info("R Script : %s" % rcode)
needX11 = False
if error[1] is None :
error[1] = 'None'
parent.Rerror = '\n'.join([str(pid.returncode), '\n'.join(error)])
- try :
- raise Exception('\n'.join(u'Erreur R', '\n'.join(error[1:])))
- except :
- BugReport(parent)
+ #try :
+ raise Exception('\n'.join([u'Erreur R', '\n'.join(error[1:])]))
+ return False
+ #except :
+ # BugReport(parent)
else :
if pid != 0 :
- try :
- raise Exception(u'Erreur R')
- except :
- BugReport(parent)
+ #try :
+ raise Exception(u'Erreur R')
+ return False
+ #except :
+ # BugReport(parent)
def print_liste(filename,liste):
with open(filename,'w') as f :
from openanalyse import OpenAnalyse
from corpusNG import BuildFromAlceste, Builder
from sheet import MySheet
-from checkinstall import CreateIraDirectory, CheckRPath, FindRPAthWin32, FindRPathNix, CheckRapp, CheckRPackages, IsNew, UpgradeConf, CopyConf, RLibsAreInstalled
+from checkinstall import CreateIraDirectory, CheckRPath, FindRPAthWin32, FindRPathNix, CheckRPackages, IsNew, UpgradeConf, CopyConf, RLibsAreInstalled
from chemins import ConstructRscriptsPath, ConstructConfigPath, ConstructDicoPath, ConstructGlobalPath, PathOut
from parse_factiva_xml import ImportFactiva
from tree import LeftTree
log.addHandler(ch)
log.addHandler(fh)
log.setLevel(logging.INFO)
+
+
+class writer(object):
+ def write(self, data):
+ if data.strip() != '' :
+ log.info('BUG : %s' % data)
+sys.stderr = writer()
ConfigPath = ConstructConfigPath(UserConfigPath)
#####################################################################
Le chemin de l'executable de R n'a pas été trouvé.
Si R n'est pas installé, vous devez l'installer (http://www.r-project.org/).
Si R n'est pas installé dans le répertoire par défaut
-(C:\Program Files\R\R-2.x.x\R.exe sous windows ou /usr/bin/R sous linux ou Mac Os X)
+(souvent C:\Program Files\R\R-2.x.x\R.exe sous windows ou /usr/bin/R sous linux ou Mac Os X)
vous devez signaler le chemin de l'éxecutable de R dans les préférences."""
dlg = wx.MessageDialog(self, msg, u"Problème de configuration", wx.OK | wx.NO_DEFAULT | wx.ICON_WARNING)
dlg.CenterOnParent()
if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
evt.Veto()
- else :
- print 'ok'
- if sys.platform == 'darwin':
- self.Rapp = self.PathPath.get('PATHS', 'rapp')
- RappOk = CheckRapp(self.Rapp)
+ dlg.Destroy()
self.DataPop = False
self.DataTxt = False
self.Text = ''
BugReport(self)
def OnSimiTxt(self, evt, corpus = None) :
- print 'PLUS DE BUG SUR SIMITXT'
- #try :
+ # print 'PLUS DE BUG SUR SIMITXT'
+ try :
#self.Text = SimiTxt(self)
+ if corpus is None :
+ corpus = self.tree.getcorpus()
self.Text = SimiTxt(self, corpus, parametres = {'type': 'simitxt'}, dlg = progressbar(self, 3))
if self.Text.val == wx.ID_OK :
PlaySound(self)
- #except :
- # BugReport(self)
+ except :
+ BugReport(self)
def OnWordCloud(self, evt, corpus = None) :
# print 'PLUS DE BUG SUR WORDCLOUD'
try :
+ if corpus is None :
+ corpus = self.tree.getcorpus()
self.Text = WordCloud(self, corpus, parametres = {'type' : 'wordcloud'}, dlg = progressbar(self, 3))
if self.Text.val == wx.ID_OK :
PlaySound(self)
def OnTextStat(self, event, corpus = None):
print 'PAS DE BUG SUR TEXT STAT'
#try:
+ if corpus is None :
+ corpus = self.tree.getcorpus()
self.Text = Stat(self, corpus, parametres = {'type': 'stat'}, dlg = progressbar(self, 7))
if self.Text.val == wx.ID_OK :
#try:
#self.Text = AsLexico(self)
print('ATTENTION : PLUS DE BUG SUR LEXICO')
+ if corpus is None :
+ corpus = self.tree.getcorpus()
self.Text = Lexico(self, corpus, parametres = {'type' : 'spec'}, dlg = progressbar(self, 3))
if self.Text.val == wx.ID_OK :
PlaySound(self)
BugReport(self)
def OnTextAlceste(self, event, corpus = None):
- #try:
- print('ATTENTION : PLUS DE BUG SUR ALCESTE')
+ try:
+ #print('ATTENTION : PLUS DE BUG SUR ALCESTE')
#RunAnalyse(self, corpus, Alceste, OptAlceste)
+ if corpus is None :
+ corpus = self.tree.getcorpus()
self.Text = Alceste(self, corpus, parametres = {'type': 'alceste'}, dlg = progressbar(self,6))
- #self.history.addtab(self.Text.parametres)
- #OpenAnalyse(self, self.Text.parametres['ira'])
if self.Text.val == wx.ID_OK:
PlaySound(self)
- #except:
- # BugReport(self)
+ except:
+ BugReport(self)
def OnPamSimple(self, event):
try:
def do_layout(self) :
SelectTab = self.parent.nb.GetSelection()
page = self.parent.nb.GetPage(SelectTab).TabChdSim
- prof_seg = ReadProfileAsDico(self, self.dictpathout['prof_seg'], True, self.parent.syscoding)
+ prof_seg = ReadProfileAsDico(self.dictpathout['prof_seg'], True, self.parent.syscoding)
prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition)
for i in range(0,len(self.corpus.lc)) :
ntab = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
page = self.parent.nb.GetPage(SelectTab).TabChdSim
prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition)
if alceste :
- prof_seg = ReadProfileAsDico(self, self.outprof, True)
+ prof_seg = ReadProfileAsDico(self.outprof, True)
for i in range(0,len(self.corpus.lc)) :
ntab = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
prof_seg_nb.AddPage(ntab, 'classe %i' % (i + 1))
self.makefiles()
script = PrintSimiScript(self)
script.make_script()
- self.doR(script.scriptout)
+ if not self.doR(script.scriptout) :
+ return False
if self.parametres['type_graph'] == 1:
if os.path.exists(self.pathout['liste_graph']):
graph_simi = read_list_file(self.pathout['liste_graph'])
itemtype = self.GetItemType(item)
text = self.GetItemText(item)
pydata = self.GetPyData(item)
+ self.pydata = pydata
self.current = item
self.itemdict = {"ishtml": ishtml, "back": back, "fore": fore, "isbold": isbold,
self.PopupMenu(menu)
menu.Destroy()
- def getcorpus(self, itemdict):
- if itemdict['pydata']['uuid'] in self.parent.history.openedcorpus :
- return copycorpus(self.parent.history.openedcorpus[itemdict['pydata']['uuid']])
+ def getcorpus(self):
+ if self.pydata['uuid'] in self.parent.history.openedcorpus :
+ return copycorpus(self.parent.history.openedcorpus[self.pydata['uuid']])
+ elif 'corpus_name' in self.pydata :
+ return Corpus(self.parent, parametres = DoConf(self.pydata['ira']).getoptions('corpus'), read = True)
else :
- return Corpus(self.parent, parametres = DoConf(itemdict['pydata']['ira']).getoptions('corpus'), read = True)
+ cuuid = self.pydata['corpus']
+ if cuuid in self.parent.history.openedcorpus :
+ return copycorpus(self.parent.history.openedcorpus[cuuid])
+ else :
+ irapath = self.parent.history.corpus[cuuid]['ira']
+ return Corpus(self.parent, parametres = DoConf(irapath).getoptions('corpus'), read = True)
def OnSpec(self, evt) :
- self.parent.OnTextSpec(evt, self.getcorpus(self.itemdict))
+ self.parent.OnTextSpec(evt, self.getcorpus())
def OnStat(self, evt) :
- self.parent.OnTextStat(evt, self.getcorpus(self.itemdict))
+ self.parent.OnTextStat(evt, self.getcorpus())
def OnAlceste(self, evt) :
- self.parent.OnTextAlceste(evt, self.getcorpus(self.itemdict))
+ self.parent.OnTextAlceste(evt, self.getcorpus())
def OnPam(self, evt) :
print 'rien'
def OnSimiTxt(self, evt) :
- self.parent.OnSimiTxt(evt, self.getcorpus(self.itemdict))
+ self.parent.OnSimiTxt(evt, self.getcorpus())
def OnWordCloud(self, evt) :
- self.parent.OnWordCloud(evt, self.getcorpus(self.itemdict))
+ self.parent.OnWordCloud(evt, self.getcorpus())
def OnProfSR(self, evt) :
ProfileSegment(self.parent, self.page.dictpathout, self.page.parametres, self.page.corpus)
item = event.GetItem()
pydata = self.GetPyData(item)
if pydata is not None :
+ self.pydata = pydata
if pydata['uuid'] in self.parent.history.opened :
for i in range(self.parent.nb.GetPageCount()) :
self.page = self.parent.nb.GetPage(i)