From: <de...@us...> - 2004-03-12 10:35:40
|
Update of /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/calcul In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9059/src/org/fudaa/dodico/calcul Modified Files: CalculExec.java Log Message: Correction bufg EbliFlles... Ajout commentaire tr Finalisation superviseur Index: CalculExec.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/calcul/CalculExec.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CalculExec.java 12 Dec 2003 10:30:52 -0000 1.5 --- CalculExec.java 12 Mar 2004 10:16:13 -0000 1.6 *************** *** 8,18 **** */ package org.fudaa.dodico.calcul; import java.io.File; import java.io.PrintStream; - import org.fudaa.ctulu.CtuluLib; - import com.memoire.fu.FuLib; - import org.fudaa.dodico.commun.DodicoLib; import org.fudaa.dodico.commun.DodicoPreferences; --- 8,16 ---- */ package org.fudaa.dodico.calcul; + import java.io.File; import java.io.PrintStream; import org.fudaa.ctulu.CtuluLib; import com.memoire.fu.FuLib; import org.fudaa.dodico.commun.DodicoLib; import org.fudaa.dodico.commun.DodicoPreferences; *************** *** 23,58 **** import org.fudaa.dodico.objet.CExecListener; /** ! * Classe permettant d'utiliser facilement la classe Cexec et de creer ! * des fichiers de lancement. * @author deniger * @version $Id$ */ public abstract class CalculExec { ! PrintStream outError_; ! PrintStream outStandard_; ProgressionInterface progress_; ! DodicoUI ui_; ! String pathForExec_; ! boolean changeWorkingDirectory_; ! boolean launchInNewTerm_; ! String exec_; public CalculExec() { ! outError_= System.err; ! outStandard_= System.out; } public void launch(File _f, CExecListener _l) { ! if (ui_ == null) ! ui_= DodicoUIDefault.INSTANCE; ! String[] cmd=getLaunchCmd(_f, ui_); ! if(launchInNewTerm_) cmd=getCmdWithNewTermCmd(cmd); ! CExec ex= new CExec(cmd); ! ex.setCatchExceptions(true); if (changeWorkingDirectory_) { ex.setExecDirectory(_f.getParentFile()); } ! // if (pathForExec_ != null){ ! // Runtime.getRuntime(); ! // ex.setEnvVariable(new String[] { "PATH=" + pathForExec_ }); ! // } ex.setErrStream(outError_); --- 21,60 ---- import org.fudaa.dodico.objet.CExecListener; /** ! * Classe permettant d'utiliser facilement la classe Cexec et de creer des fichiers de lancement. ! * * @author deniger * @version $Id$ */ public abstract class CalculExec { ! ! PrintStream outError_; ! PrintStream outStandard_; ProgressionInterface progress_; ! DodicoUI ui_; ! String pathForExec_; ! boolean changeWorkingDirectory_; ! boolean launchInNewTerm_; ! String exec_; ! public CalculExec() { ! outError_ = System.err; ! outStandard_ = System.out; } + public void launch(File _f, CExecListener _l) { ! if (ui_ == null) ! ui_ = DodicoUIDefault.INSTANCE; ! String[] cmd = getLaunchCmd(_f, ui_); ! if (launchInNewTerm_) cmd = getCmdWithNewTermCmd(cmd); ! DodicoLib.printStringArray(cmd); ! CExec ex = new CExec(cmd); ! ex.setCatchExceptions(false); if (changeWorkingDirectory_) { ex.setExecDirectory(_f.getParentFile()); } ! // if (pathForExec_ != null){ ! // Runtime.getRuntime(); ! // ex.setEnvVariable(new String[] { "PATH=" + pathForExec_ }); ! // } ex.setErrStream(outError_); *************** *** 73,187 **** } } public String[] getTermCmd() { if (FuLib.isWindows()) { if (FuLib.getSystemProperty("os.name").indexOf("9") > 0) { ! String[] r= new String[2]; ! r[0]= "command.com"; ! r[1]= "/C"; return r; } ! String[] r= new String[2]; ! r[0]= "cmd.exe"; ! r[1]= "/C"; return r; } ! String[] r= new String[2]; ! r[0]= "xterm"; ! r[1]= "-e"; return r; } public String[] getCmdWithNewTermCmd(String[] _cmd) { ! StringBuffer s= new StringBuffer(_cmd.length * 10); ! int n= _cmd.length; ! s.append(_cmd); ! for (int i= 1; i < n; i++) { ! s.append(CtuluLib.ESPACE).append(_cmd); } ! String cmd= ! DodicoPreferences.DODICO.getStringProperty("cexec.term.launch", null); ! if (cmd != null) { ! String[] init= DodicoLib.parseString(cmd, CtuluLib.ESPACE); ! int nInit= init.length; ! String[] r= new String[nInit + 1]; ! System.arraycopy(init, 0, r, 0, nInit); ! r[nInit]= s.toString(); ! return r; } ! String[] deb=getTermCmd(); ! if(FuLib.isLinux() || FuLib.isUnix()){ ! s.append("sh -c"); } ! String[] r=new String[deb.length+_cmd.length]; System.arraycopy(deb, 0, r, 0, deb.length); ! System.arraycopy(_cmd, 0, r, deb.length, _cmd.length); return r; } public abstract String[] getLaunchCmd( ! File _paramsFile, ! DodicoUI _ui); /** ! * Permet de creer (si necessaire) un launcher special pour le code ! * <code>_serveurName</code>. A partir d'un template ! * (le fichier serveur/<code>_launchertplFile</code>) ! * cree un launcher <code>_launcherFile</code> qui pourra ! * lancer l'executable <code>_exeFile</code> depuis n'importe quel ! * dossier. Le calculManager ne sert qu'a recuperer les erreurs. ! * Voir le serveur reflux pour exemple. ! * @return renvoie un tableau du type [_launchFile,_launcherArgs[0],_launcherArgs[i],...] * */ ! public static String[] manageLauncher( ! String _serveurName, ! String _exeFile, ! String _launchtplFile, ! String _launchFile, ! String[] _launcherArgs, ! DodicoUI _ui) { ! File serveurDir= new File("serveurs/" + _serveurName + "/"); ! File launchFile= new File(serveurDir, _launchFile); ! File in= new File(serveurDir, _launchtplFile); ! if (!launchFile.exists() || (in.lastModified()>launchFile.lastModified())) { ! ! File serveur= new File(serveurDir, _exeFile); ! String newToken= serveur.getAbsolutePath(); if (!DodicoLib.replaceAndCopyFile(in, launchFile, "@exe@", newToken)) { _ui.error( ! "Copie de fichier", ! "Erreur lors de la copie de " + _launchtplFile); } } ! int n= _launcherArgs == null ? 0 : _launcherArgs.length; ! String[] r= new String[1 + n]; ! r[0]= launchFile.getAbsolutePath(); ! for (int i= 0; i < n; i++) { ! r[i + 1]= _launcherArgs[i]; ! } ! return r; } /** ! * */ public PrintStream getOutError() { return outError_; } /** ! * */ public PrintStream getOutStandard() { return outStandard_; } /** ! * */ public void setOutError(PrintStream _writer) { ! outError_= _writer; } /** ! * */ public void setOutStandard(PrintStream _writer) { ! outStandard_= _writer; } /** * @return --- 75,186 ---- } } + public String[] getTermCmd() { if (FuLib.isWindows()) { if (FuLib.getSystemProperty("os.name").indexOf("9") > 0) { ! String[] r = new String[2]; ! r[0] = "command.com"; ! r[1] = "/C"; return r; } ! String[] r = new String[2]; ! r[0] = "cmd.exe"; ! r[1] = "/C"; return r; } ! String[] r = new String[2]; ! r[0] = "xterm"; ! r[1] = "-e"; return r; } + public String[] getCmdWithNewTermCmd(String[] _cmd) { ! StringBuffer s = new StringBuffer(_cmd.length * 10); ! int n = _cmd.length; ! if (FuLib.isLinux() || FuLib.isUnix()) { ! s.append("sh -c "); } ! s.append(_cmd[0]); ! for (int i = 1; i < n; i++) { ! s.append(CtuluLib.ESPACE).append(_cmd[i]); } ! String cmd = ! DodicoPreferences.DODICO.getStringProperty("cexec.term.launch", null); ! String[] deb=null; ! if (cmd != null) { ! String[] init = DodicoLib.parseString(cmd, CtuluLib.ESPACE); ! int nInit = init.length; ! deb = new String[nInit + 1]; ! System.arraycopy(init, 0, deb, 0, nInit); } ! if(deb==null) deb = getTermCmd(); ! String[] r = new String[deb.length + 1]; System.arraycopy(deb, 0, r, 0, deb.length); ! r[r.length - 1] = "\""+s.toString()+"\""; return r; } + public abstract String[] getLaunchCmd( ! File _paramsFile, ! DodicoUI _ui); /** ! * Permet de creer (si necessaire) un launcher special pour le code <code>_serveurName</code>. ! * A partir d'un template (le fichier serveur/ <code>_launchertplFile</code>) cree un launcher ! * <code>_launcherFile</code> qui pourra lancer l'executable <code>_exeFile</code> depuis ! * n'importe quel dossier. Le calculManager ne sert qu'a recuperer les erreurs. Voir le serveur ! * reflux pour exemple. * + * @return renvoie un tableau du type [_launchFile,_launcherArgs[0],_launcherArgs[i],...] */ ! public static File manageLauncher( ! String _serveurName, ! String _exeFile, ! String _launchtplFile, ! String _launchFile, ! DodicoUI _ui) { ! File serveurDir = new File("serveurs/" + _serveurName + "/"); ! File launchFile = new File(serveurDir, _launchFile); ! File in = new File(serveurDir, _launchtplFile); ! if (!launchFile.exists() || (in.lastModified() > launchFile.lastModified())) { ! File serveur = new File(serveurDir, _exeFile); ! String newToken = serveur.getAbsolutePath(); if (!DodicoLib.replaceAndCopyFile(in, launchFile, "@exe@", newToken)) { _ui.error( ! "Copie de fichier", ! "Erreur lors de la copie de " + _launchtplFile); } } ! return launchFile; } + /** ! * * */ public PrintStream getOutError() { return outError_; } + /** ! * * */ public PrintStream getOutStandard() { return outStandard_; } + /** ! * * */ public void setOutError(PrintStream _writer) { ! outError_ = _writer; } + /** ! * * */ public void setOutStandard(PrintStream _writer) { ! outStandard_ = _writer; } + /** * @return *************** *** 190,199 **** return progress_; } /** * @param _interface */ public void setProgression(ProgressionInterface _interface) { ! progress_= _interface; } /** * @return --- 189,200 ---- return progress_; } + /** * @param _interface */ public void setProgression(ProgressionInterface _interface) { ! progress_ = _interface; } + /** * @return *************** *** 202,247 **** return ui_; } /** * @param _dodicoUI */ public void setUI(DodicoUI _dodicoUI) { ! if (_dodicoUI != null) ! ui_= _dodicoUI; } /** ! * */ public boolean isChangeWorkingDirectory() { return changeWorkingDirectory_; } /** ! * */ public boolean isLauchInNewTerm() { return launchInNewTerm_; } /** ! * */ public String getPathForExec() { return pathForExec_; } /** ! * */ public void setChangeWorkingDirectory(boolean _b) { ! changeWorkingDirectory_= _b; } /** ! * */ public void setLauchInNewTerm(boolean _b) { ! launchInNewTerm_= _b; } /** ! * */ public void setPathForExec(String _string) { ! pathForExec_= _string; } } --- 203,255 ---- return ui_; } + /** * @param _dodicoUI */ public void setUI(DodicoUI _dodicoUI) { ! if (_dodicoUI != null) ! ui_ = _dodicoUI; } + /** ! * * */ public boolean isChangeWorkingDirectory() { return changeWorkingDirectory_; } + /** ! * * */ public boolean isLauchInNewTerm() { return launchInNewTerm_; } + /** ! * * */ public String getPathForExec() { return pathForExec_; } + /** ! * * */ public void setChangeWorkingDirectory(boolean _b) { ! changeWorkingDirectory_ = _b; } + /** ! * * */ public void setLauchInNewTerm(boolean _b) { ! launchInNewTerm_ = _b; } + /** ! * * */ public void setPathForExec(String _string) { ! pathForExec_ = _string; } } |