Révision 3860
TXM/trunk/bundles/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RWorkspace.java (revision 3860) | ||
---|---|---|
192 | 192 |
try { |
193 | 193 |
Log.fine(RCoreMessages.bind(RCoreMessages.info_connectingToRAt, host, port)); |
194 | 194 |
connection = new RConnection(host, port); |
195 |
connection.setStringEncoding("utf8"); // mandatory ! |
|
195 |
connection.setStringEncoding("utf8"); // mandatory ! //$NON-NLS-1$
|
|
196 | 196 |
return isConnected(); |
197 | 197 |
} |
198 | 198 |
catch (RserveException x) { |
... | ... | |
215 | 215 |
Log.fine(TXMCoreMessages.bind(RCoreMessages.info_connectingToRAtWithUser, new Object[] { host, port, user })); |
216 | 216 |
connection = new RConnection(host, port); |
217 | 217 |
connection.login(user, password); |
218 |
connection.setStringEncoding("utf8"); // mandatory ! |
|
218 |
connection.setStringEncoding("utf8"); // mandatory ! //$NON-NLS-1$
|
|
219 | 219 |
return isConnected(); |
220 | 220 |
|
221 | 221 |
} |
... | ... | |
255 | 255 |
// TODO: this method uses the right directory ? |
256 | 256 |
// Bundle bundle = FrameworkUtil.getBundle(RWorkspace.class); |
257 | 257 |
// File userdir = new File(bundle.getLocation()); |
258 |
File userDir = new File(Toolbox.getTxmHomePath(), "R"); |
|
258 |
File userDir = new File(Toolbox.getTxmHomePath(), "R"); //$NON-NLS-1$
|
|
259 | 259 |
// System.out.println("BUNDLE LOCATION OF '" + bundle.getSymbolicName() + "': " + userDir); |
260 | 260 |
workspace = new RWorkspace(userDir); |
261 | 261 |
} |
... | ... | |
394 | 394 |
* @throws StatException the stat exception |
395 | 395 |
*/ |
396 | 396 |
public File plot(File file, String expr) throws REXPMismatchException, StatException, RserveException { |
397 |
return plot(file, expr, "svg"); |
|
397 |
return plot(file, expr, "svg"); //$NON-NLS-1$
|
|
398 | 398 |
} |
399 | 399 |
|
400 | 400 |
/** |
... | ... | |
419 | 419 |
|
420 | 420 |
String path; |
421 | 421 |
if (OSDetector.isFamilyWindows()) { |
422 |
path = file.getCanonicalPath().replaceAll("\\\\", "/"); |
|
422 |
path = file.getCanonicalPath().replaceAll("\\\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
423 | 423 |
} |
424 | 424 |
else { |
425 | 425 |
path = file.getAbsolutePath(); |
426 | 426 |
} |
427 | 427 |
|
428 |
if (devicename.equals("devSVG")) safeEval("library(RSvgDevice);"); |
|
428 |
if (devicename.equals("devSVG")) safeEval("library(RSvgDevice);"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
429 | 429 |
|
430 | 430 |
// FIXME : test for window dimensions so the large plots can be entirely displayed. Need to pass width and height to RWorkspace.plot() so |
431 | 431 |
// RChartsEngine will be able to dynamically compute the width from the number of bars in a barplot for example. |
... | ... | |
1142 | 1142 |
} |
1143 | 1143 |
catch (RserveException e) { |
1144 | 1144 |
RWorkspace.printLastSafeEvalExpr(); |
1145 |
throw new RWorkspaceException(e.getMessage()+ "; " +exp.trim(), e); |
|
1145 |
throw new RWorkspaceException(e.getMessage()+ "; " +exp.trim(), e); //$NON-NLS-1$
|
|
1146 | 1146 |
} |
1147 | 1147 |
catch (Exception e) { |
1148 | 1148 |
throw new RException(e.getMessage()+ "; " +exp.trim(), e); //$NON-NLS-1$ |
... | ... | |
1340 | 1340 |
public void initializeRWorkspaceConnectionConfiguration(SystemProxyDetector conf) throws RserveException { |
1341 | 1341 |
|
1342 | 1342 |
// reduce time out |
1343 |
Log.fine("Setting R connection time out to 3 seconds."); |
|
1343 |
Log.fine("Setting R connection time out to 3 seconds."); //$NON-NLS-1$
|
|
1344 | 1344 |
this.getConnection().eval("options(timeout = 3);"); //$NON-NLS-1$ |
1345 | 1345 |
|
1346 | 1346 |
// configure the HTTP proxy |
1347 | 1347 |
if (conf.isSystemProxyDetected()) { |
1348 | 1348 |
String proxyUrl = conf.getHttpProxyUrl(); |
1349 |
Log.fine("Setting R proxy configuration from system proxy configuration to: " + proxyUrl); |
|
1349 |
Log.fine("Setting R proxy configuration from system proxy configuration to: " + proxyUrl); //$NON-NLS-1$
|
|
1350 | 1350 |
this.getConnection().eval("Sys.setenv(http_proxy=\"" + proxyUrl + "\")"); //$NON-NLS-1$ //$NON-NLS-2$ |
1351 | 1351 |
} |
1352 | 1352 |
} |
... | ... | |
1403 | 1403 |
System.out.println("TXM R workspace directory not found: " + userdir); |
1404 | 1404 |
} |
1405 | 1405 |
else { |
1406 |
Log.fine("Setting TXM R workspace directory: " + userdir.getAbsolutePath()); |
|
1406 |
Log.fine("Setting TXM R workspace directory: " + userdir.getAbsolutePath()); //$NON-NLS-1$
|
|
1407 | 1407 |
connection.eval("setwd(\"" + userdir.getAbsolutePath().replace("\\", "/") + "\")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
1408 | 1408 |
} |
1409 | 1409 |
|
1410 | 1410 |
// set the libraries directory to install new R packages |
1411 |
File RLibrariesWorkspaceDirectory = new File(userdir, "libraries"); |
|
1411 |
File RLibrariesWorkspaceDirectory = new File(userdir, "libraries"); //$NON-NLS-1$
|
|
1412 | 1412 |
RLibrariesWorkspaceDirectory.mkdir(); |
1413 | 1413 |
if (!RLibrariesWorkspaceDirectory.exists()) { |
1414 | 1414 |
System.out.println("TXM R libraries workspace directory not found: " + RLibrariesWorkspaceDirectory); |
1415 | 1415 |
} |
1416 | 1416 |
else { |
1417 |
Log.fine("Setting TXM R libraries workspace directory: " + RLibrariesWorkspaceDirectory.getAbsolutePath()); |
|
1417 |
Log.fine("Setting TXM R libraries workspace directory: " + RLibrariesWorkspaceDirectory.getAbsolutePath()); //$NON-NLS-1$
|
|
1418 | 1418 |
connection.eval(".libPaths(c(\"" + RLibrariesWorkspaceDirectory.getAbsolutePath().replace("\\", "/") + "\",.libPaths()))");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
1419 | 1419 |
} |
1420 | 1420 |
|
... | ... | |
1425 | 1425 |
// set the default R repository |
1426 | 1426 |
String repos = RPreferences.getInstance().getString(RPreferences.DEFAULT_REPOS); |
1427 | 1427 |
if (repos.length() > 0) { |
1428 |
Log.fine("Set the 'repos' R option to " + repos); |
|
1428 |
Log.fine("Set the 'repos' R option to " + repos); //$NON-NLS-1$
|
|
1429 | 1429 |
connection.eval("options(repos=\"" + repos + "\")");//$NON-NLS-1$ //$NON-NLS-2$ |
1430 | 1430 |
} |
1431 | 1431 |
|
... | ... | |
1543 | 1543 |
} |
1544 | 1544 |
lastSafeevalExpr = expr; |
1545 | 1545 |
|
1546 |
expr = "try({" + expr + "}, silent=FALSE)"; |
|
1546 |
expr = "try({" + expr + "}, silent=FALSE)"; //$NON-NLS-1$ //$NON-NLS-2$
|
|
1547 | 1547 |
|
1548 | 1548 |
if (isLoggingEvalCommandLines()) { |
1549 | 1549 |
// TODO SJ: for debuggin puprose |
... | ... | |
1564 | 1564 |
throw e;//new RException(expr, e.getMessage()); |
1565 | 1565 |
} |
1566 | 1566 |
finally { |
1567 |
if (r != null && r.inherits("try-error")) { |
|
1567 |
if (r != null && r.inherits("try-error")) { //$NON-NLS-1$
|
|
1568 | 1568 |
throw new RException(expr, r.asString()); |
1569 | 1569 |
} |
1570 | 1570 |
} |
... | ... | |
1608 | 1608 |
|
1609 | 1609 |
if (ret instanceof org.rosuda.REngine.REXPString) { |
1610 | 1610 |
if (ret.isVector()) { |
1611 |
out = "result: " + StringUtils.join(ret.asStrings(), ", "); |
|
1611 |
out = "result: " + StringUtils.join(ret.asStrings(), ", "); //$NON-NLS-1$ //$NON-NLS-2$
|
|
1612 | 1612 |
} |
1613 | 1613 |
else { |
1614 |
out = "result: " + ret.asString(); |
|
1614 |
out = "result: " + ret.asString(); //$NON-NLS-1$
|
|
1615 | 1615 |
} |
1616 | 1616 |
} |
1617 | 1617 |
else if (ret instanceof org.rosuda.REngine.REXPDouble) { |
1618 | 1618 |
if (ret.isVector()) { |
1619 |
out = "result: " + ret.asDouble(); |
|
1619 |
out = "result: " + ret.asDouble(); //$NON-NLS-1$
|
|
1620 | 1620 |
} |
1621 | 1621 |
else { |
1622 |
out = "result: " + Arrays.toString(ret.asDoubles()); |
|
1622 |
out = "result: " + Arrays.toString(ret.asDoubles()); //$NON-NLS-1$
|
|
1623 | 1623 |
} |
1624 | 1624 |
} |
1625 | 1625 |
else if (ret instanceof org.rosuda.REngine.REXPInteger) { |
1626 | 1626 |
if (ret.isVector()) { |
1627 |
out = "result: " + ret.asInteger(); |
|
1627 |
out = "result: " + ret.asInteger(); //$NON-NLS-1$
|
|
1628 | 1628 |
} |
1629 | 1629 |
else { |
1630 |
out = "result: " + Arrays.toString(ret.asIntegers()); |
|
1630 |
out = "result: " + Arrays.toString(ret.asIntegers()); //$NON-NLS-1$
|
|
1631 | 1631 |
} |
1632 | 1632 |
} |
1633 | 1633 |
else if (ret instanceof org.rosuda.REngine.REXPNull) { |
1634 |
out = "NULL"; |
|
1634 |
out = "NULL"; //$NON-NLS-1$
|
|
1635 | 1635 |
} |
1636 | 1636 |
else { |
1637 |
out = "result: " + ret; |
|
1637 |
out = "result: " + ret; //$NON-NLS-1$
|
|
1638 | 1638 |
} |
1639 | 1639 |
|
1640 | 1640 |
} |
TXM/trunk/bundles/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/preferences/RPreferences.java (revision 3860) | ||
---|---|---|
70 | 70 |
*/ |
71 | 71 |
public static final String SHOW_EVAL_LOGS = "show_eval_logs"; //$NON-NLS-1$ |
72 | 72 |
|
73 |
public static final String DEFAULT_REPOS = "default_repos"; |
|
73 |
public static final String DEFAULT_REPOS = "default_repos"; //$NON-NLS-1$
|
|
74 | 74 |
|
75 | 75 |
|
76 | 76 |
/** |
... | ... | |
96 | 96 |
|
97 | 97 |
Preferences preferences = this.getDefaultPreferencesNode(); |
98 | 98 |
|
99 |
String RFRAGMENT = "org.txm.statsengine.r.core." + System.getProperty("osgi.os"); //$NON-NLS-1$ |
|
99 |
String RFRAGMENT = "org.txm.statsengine.r.core." + System.getProperty("osgi.os"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
100 | 100 |
|
101 |
Log.fine("RPreferences.initializeDefaultPreferences()"); |
|
101 |
Log.fine("RPreferences.initializeDefaultPreferences()"); //$NON-NLS-1$
|
|
102 | 102 |
|
103 | 103 |
String saved = this.getString(RPreferences.VERSION); |
104 | 104 |
Version currentVersion = BundleUtils.getBundleVersion(RFRAGMENT); // the RFRAGMENT plugin contains the right version |
... | ... | |
107 | 107 |
String os = ""; //$NON-NLS-1$ |
108 | 108 |
String ext = ""; //$NON-NLS-1$ |
109 | 109 |
String osName = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$ |
110 |
String extraSubPath = ""; |
|
110 |
String extraSubPath = ""; //$NON-NLS-1$
|
|
111 | 111 |
if (osName.contains("windows")) { //$NON-NLS-1$ |
112 | 112 |
os = "win32"; //$NON-NLS-1$ |
113 |
extraSubPath = "x64/"; |
|
113 |
extraSubPath = "x64/"; //$NON-NLS-1$
|
|
114 | 114 |
ext = ".exe"; //$NON-NLS-1$ |
115 | 115 |
} |
116 | 116 |
else if (osName.contains("mac")) { //$NON-NLS-1$ |
... | ... | |
131 | 131 |
File rRootDir = new File(rpluginDir, os); |
132 | 132 |
File execFile = new File(rRootDir, "bin/" + extraSubPath + "R" + ext); //$NON-NLS-1$ //$NON-NLS-2$ |
133 | 133 |
File execFile2 = new File(rRootDir, "bin/exec/" + extraSubPath + "R" + ext); //$NON-NLS-1$ //$NON-NLS-2$ |
134 |
if (osName.contains("windows")) { // R second exec file path is different |
|
134 |
if (osName.contains("windows")) { // R second exec file path is different //$NON-NLS-1$
|
|
135 | 135 |
execFile2 = new File(rRootDir, "bin/x64/" + extraSubPath + "R" + ext); //$NON-NLS-1$ //$NON-NLS-2$ |
136 | 136 |
} |
137 | 137 |
if (!execFile.canExecute() && !execFile.setExecutable(true)) { // first test if file is executable then try setting it executable |
... | ... | |
167 | 167 |
return; |
168 | 168 |
} |
169 | 169 |
|
170 |
preferences.put(DEFAULT_REPOS, "https://cloud.r-project.org"); |
|
170 |
preferences.put(DEFAULT_REPOS, "https://cloud.r-project.org"); //$NON-NLS-1$
|
|
171 | 171 |
preferences.put(PATH_TO_EXECUTABLE, execFile.getAbsolutePath()); |
172 | 172 |
preferences.putBoolean(IS_MANDATORY, false); |
173 |
preferences.put(SERVER_ADDRESS, "127.0.0.1"); |
|
173 |
preferences.put(SERVER_ADDRESS, "127.0.0.1"); //$NON-NLS-1$
|
|
174 | 174 |
preferences.putBoolean(REMOTE, false); |
175 | 175 |
preferences.putBoolean(DISABLE, false); |
176 | 176 |
preferences.putBoolean(DEBUG, false); |
177 |
preferences.put(PORT, "6311"); |
|
178 |
preferences.put(USER, ""); |
|
179 |
preferences.put(PASSWORD, ""); |
|
180 |
preferences.put(RARGS, ""); |
|
181 |
preferences.put(RSERVEARGS, ""); |
|
177 |
preferences.put(PORT, "6311"); //$NON-NLS-1$
|
|
178 |
preferences.put(USER, ""); //$NON-NLS-1$
|
|
179 |
preferences.put(PASSWORD, ""); //$NON-NLS-1$
|
|
180 |
preferences.put(RARGS, ""); //$NON-NLS-1$
|
|
181 |
preferences.put(RSERVEARGS, ""); //$NON-NLS-1$
|
|
182 | 182 |
preferences.putBoolean(FILE_TRANSFERT, false); |
183 |
preferences.put(SVG_DEVICE, "svg"); |
|
183 |
preferences.put(SVG_DEVICE, "svg"); //$NON-NLS-1$
|
|
184 | 184 |
preferences.putBoolean(SHOW_EVAL_LOGS, false); |
185 | 185 |
|
186 | 186 |
if (saved != null && saved.length() > 0) { |
TXM/trunk/bundles/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/data/MatrixImpl.java (revision 3860) | ||
---|---|---|
372 | 372 |
try { |
373 | 373 |
// // cut nlines |
374 | 374 |
if (before != after) { |
375 |
REXP r = rw.eval(symbol + "<- " + symbol + "[" + before + ":" + (after) + ", ];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
375 |
REXP r = rw.eval(symbol + "<- " + symbol + "[" + before + ":" + (after) + ", ];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
|
376 | 376 |
} |
377 | 377 |
else { |
378 |
REXP r = rw.eval(symbol + "<- " + "as.matrix(" + symbol + "[" + before + ", ]);"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
378 |
REXP r = rw.eval(symbol + "<- " + "as.matrix(" + symbol + "[" + before + ", ]);"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
|
379 | 379 |
} |
380 | 380 |
// getRowNames().cut(before, after); |
381 | 381 |
// this.nrow = nlines; |
... | ... | |
700 | 700 |
values[i-1] = 0; |
701 | 701 |
} |
702 | 702 |
} |
703 |
System.out.println("values="+Arrays.toString(values)); |
|
704 |
rw.addVectorToWorkspace("tmpvec", values); |
|
705 |
rw.voidEval("tmpmat <- rbind(tmpmat, tmpvec);"); |
|
703 |
System.out.println("values="+Arrays.toString(values)); //$NON-NLS-1$
|
|
704 |
rw.addVectorToWorkspace("tmpvec", values); //$NON-NLS-1$
|
|
705 |
rw.voidEval("tmpmat <- rbind(tmpmat, tmpvec);"); //$NON-NLS-1$
|
|
706 | 706 |
} |
707 |
rw.voidEval("tmpmat <- tmpmat[-1,];"); // $NON-NLS-1$ remove the null first line |
|
707 |
rw.voidEval("tmpmat <- tmpmat[-1,];"); // $NON-NLS-1$ remove the null first line //$NON-NLS-1$
|
|
708 | 708 |
rw.addVectorToWorkspace("tmprownames", rownames.toArray(new String[rownames.size()])); //$NON-NLS-1$ |
709 |
rw.addVectorToWorkspace("tmpcolnames", rheader); |
|
710 |
rw.assignRowNamesToMatrix("tmpmat", "tmprownames"); |
|
711 |
rw.assignColNamesToMatrix("tmpmat", "tmpcolnames"); |
|
709 |
rw.addVectorToWorkspace("tmpcolnames", rheader); //$NON-NLS-1$
|
|
710 |
rw.assignRowNamesToMatrix("tmpmat", "tmprownames"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
711 |
rw.assignColNamesToMatrix("tmpmat", "tmpcolnames"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
712 | 712 |
|
713 | 713 |
rw.voidEval(symbol + "<- tmpmat;"); //$NON-NLS-1$ |
714 | 714 |
//rw.voidEval("rm(tmpmat);"); //$NON-NLS-1$ |
TXM/trunk/bundles/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RStatsEngine.java (revision 3860) | ||
---|---|---|
126 | 126 |
|
127 | 127 |
Log.finer(TXMCoreMessages.bind("Registering R transformer: {0}...", transformer)); |
128 | 128 |
|
129 |
transformers.put(contributions[i].getAttribute("type"), transformer); |
|
129 |
transformers.put(contributions[i].getAttribute("type"), transformer); //$NON-NLS-1$
|
|
130 | 130 |
} |
131 | 131 |
catch (Exception e) { |
132 |
Log.severe("Error: failed to instantiate " + contributions[i].getName() + "."); |
|
132 |
Log.severe("Error: failed to instantiate " + contributions[i].getName() + "."); //$NON-NLS-2$
|
|
133 | 133 |
e.printStackTrace(); |
134 | 134 |
} |
135 | 135 |
} |
... | ... | |
162 | 162 |
|
163 | 163 |
try { |
164 | 164 |
if (StartRserve.rProcess != null) { |
165 |
Log.finest("Quitting R process...");
|
|
165 |
Log.finest("Quiting R process..."); //$NON-NLS-1$
|
|
166 | 166 |
StartRserve.rProcess.destroy(); |
167 | 167 |
} |
168 | 168 |
} |
... | ... | |
180 | 180 |
File f = new File(execName); |
181 | 181 |
// only use taskkill if the process is running |
182 | 182 |
|
183 |
String cmd = "tasklist | find /i \""+f.getName()+"\" && taskkill /IM "+f.getName()+" /F"; //$NON-NLS-1$ |
|
183 |
String cmd = "tasklist | find /i \""+f.getName()+"\" && taskkill /IM "+f.getName()+" /F"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
184 | 184 |
//String cmd = "cmd /c FOR /F \"tokens=5 delims= \" %P IN ('netstat -ano ^| findstr :6330 ^| findstr LISTENING') DO taskkill /F /PID %P"; //$NON-NLS-1$ |
185 |
Log.finest("Executing command: " + cmd); |
|
185 |
Log.finest("Executing command: " + cmd); //$NON-NLS-1$
|
|
186 | 186 |
|
187 | 187 |
Process p = Runtime.getRuntime().exec(cmd); |
188 | 188 |
|
189 | 189 |
// consumes streams |
190 | 190 |
StreamHog errStream = new StreamHog(p.getErrorStream(), true); |
191 |
errStream.setName("ts-kill-r-err"); |
|
191 |
errStream.setName("ts-kill-r-err"); //$NON-NLS-1$
|
|
192 | 192 |
StreamHog inStream = new StreamHog(p.getInputStream(), true); |
193 |
inStream.setName("ts-kill-r"); |
|
193 |
inStream.setName("ts-kill-r"); //$NON-NLS-1$
|
|
194 | 194 |
|
195 | 195 |
p.waitFor(); |
196 | 196 |
started = false; |
... | ... | |
199 | 199 |
try { |
200 | 200 |
|
201 | 201 |
String cmd = NLS.bind("cmd /c FOR /F \"tokens=5 delims= \" %P IN (''netstat -ano ^| findstr :{0} ^| findstr LISTENING'') DO tskill %P", RPreferences.getInstance().getInt(RPreferences.PORT)); //$NON-NLS-1$ |
202 |
Log.finest("Executing command: " + cmd); |
|
202 |
Log.finest("Executing command: " + cmd); //$NON-NLS-1$
|
|
203 | 203 |
|
204 | 204 |
Process p = Runtime.getRuntime().exec( |
205 | 205 |
//"tskill Rserve.exe"); //$NON-NLS-1$ |
... | ... | |
264 | 264 |
|
265 | 265 |
@Override |
266 | 266 |
public String getName() { |
267 |
return "R"; |
|
267 |
return "R"; //$NON-NLS-1$
|
|
268 | 268 |
} |
269 | 269 |
} |
Formats disponibles : Unified diff