Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified dist/lib/funz-client-1.17.jar
Binary file not shown.
Binary file modified dist/lib/funz-core-1.17.jar
Binary file not shown.
Binary file modified lib/Rsession-3.1.9.jar
Binary file not shown.
6 changes: 5 additions & 1 deletion src/main/java/org/funz/run/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.List;
import java.util.Map;
import org.funz.*;
import org.funz.log.Log;

import static org.funz.Protocol.END_OF_REQ;
import static org.funz.Protocol.RET_HEARTBEAT;
import static org.funz.Protocol.RET_INFO;
Expand Down Expand Up @@ -75,7 +77,7 @@ public static class PluginInfo {
boolean log = false;

public void log(String s) {
//System.err.println("<<<<<<<<<<<<<<<<<<<<<<<<< " + s);
//Log.out("[Client] "+ s, 10);
}

public static String getProtocol() {
Expand Down Expand Up @@ -240,6 +242,8 @@ public void flush() {
_dis = new DataInputStream(_socket.getInputStream());

} catch (Exception e) {
log("Exception on Socket instanciation on "+_host+":"+_port+"\n "+e);
e.printStackTrace();
disconnect();
}
}
Expand Down
31 changes: 22 additions & 9 deletions src/main/java/org/funz/script/RMathExpression.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.math.R.RserveSession;
import org.math.R.RserverConf;
import org.math.R.Rsession;
import org.math.R.Rsession.RException;

/**
*
Expand Down Expand Up @@ -196,15 +197,25 @@ public RMathExpression(String name, File log) {
}

void initR() {
try { // Fix for windows when /cygdrive/c/.. remains in HOME
R.voidEval("Sys.setenv(HOME='"
+ new File(System.getProperty("user.home")).getAbsolutePath().
replace('\\', '/') // Fix path sep
+ "')");
} catch (Rsession.RException ex) {
Log.err("Failed to setup user homedir: " + ex.getMessage(), 3);
}
R.log("######################### INFORMATION ###########################", Level.WARNING);

boolean RisLocal = (R instanceof R2jsSession) ||(R instanceof RenjinSession) || (R instanceof RserveSession && ((RserveSession) R).RserveConf.isLocal());
if (RisLocal) // otherwise will force to use local username HOME, which may be not available on remote Rserve (if used)
try { // Fix for windows when /cygdrive/c/.. remains in HOME
R.log("Force user homedir: "+new File(System.getProperty("user.home")).getAbsolutePath().replace('\\', '/'), Level.WARNING);
R.voidEval("Sys.setenv(HOME='"
+ new File(System.getProperty("user.home")).getAbsolutePath().replace('\\', '/') // Fix path sep
+ "')");
} catch (Rsession.RException ex) {
Log.err("Failed to setup user homedir: " + ex.getMessage(), 3);
}
else
try {
R.log("Let default remote homedir: "+R.eval("Sys.getenv('HOME')"), Level.WARNING);
} catch (RException e) {
Log.err("Failed to get remote homedir: " + e.getMessage(), 3);
}

printInformation(R);
initLibPath(R);
R.log("#################################################################", Level.WARNING);
Expand Down Expand Up @@ -341,8 +352,10 @@ String asRList(Map m) {

public static void printInformation(Rsession R) {
try {
R.log(R.toString(), Level.WARNING);
String nodename = (String) R.eval("Sys.info()[['nodename']]");
String rhome = (String) R.eval("Sys.getenv('R_HOME')");
String home = (String) R.eval("Sys.getenv('HOME')");
String host = (nodename == null ? "?" : nodename) + ":" + (rhome == null ? "?" : rhome);
R.log("Host " + host, Level.WARNING);
String dir = R.eval("getwd()").toString();
Expand Down Expand Up @@ -402,7 +415,7 @@ public static void initLibPath(Rsession R) {
}
try {
//if (RLibPath == null) {
String RLibPath = "file.path('"+Constants.APP_USER_DIR.getAbsolutePath().replace('\\', '/')+"','R')";
String RLibPath = "file.path(Sys.getenv('HOME'),'R')"; // use getenv(HOME) which is also consistent remotely
//}
//if (RLibPath != null) {
R.voidEval("if (!file.exists(" + RLibPath + ")) dir.create(" + RLibPath + ",recursive=TRUE)");
Expand Down
Loading