Permalink
Browse files

Call the proxy to get server temp file path so it is formatted for th…

…e server, e.g. /tmp/foo.bar rather than C:\tmp\foo.bar
  • Loading branch information...
1 parent da0383a commit 03b23bd02cb63cca03e669488ab51829188cd311 @haux haux committed Oct 6, 2011
@@ -50,7 +50,7 @@ public String getClientPath() {
}
public String getServerPath() {
- return serverFile.getAbsolutePath();
+ return matlab.getFilePath(serverFile);
}
public void upload() {
@@ -72,6 +72,8 @@
//
public File createTempFile(String prefix, String suffix);
+ public String getFilePath(File file);
+
public boolean deleteFile(File file);
public int openFile(File file) throws IOException;
@@ -194,6 +194,10 @@ public File createTempFile(String prefix, String suffix) {
return matlab.createTempFile(prefix, suffix);
}
+ public String getFilePath(File file) {
+ return matlab.getFilePath(file);
+ }
+
public boolean deleteFile(File file) {
return matlab.deleteFile(file);
}
@@ -215,6 +215,10 @@ public File createTempFile(String prefix, String suffix) {
return tempFile;
}
+ public String getFilePath(File file) {
+ return file.getAbsolutePath();
+ }
+
public boolean deleteFile(File file) {
return file != null ? file.delete() : true;
}
@@ -1,31 +1,33 @@
-package de.mpicbg.sweng.pythonserver;
-
-import java.io.File;
-import java.io.IOException;
-
-
-/**
- * Remote interface to python. The used implmentation depends on the current context and is configurable by the user.
- *
- * @author Tom Haux
- */
-public interface Python {
- public String REGISTRY_NAME = "PythonServer";
- public int DEFAULT_PORT = 1198;
- public String DEFAULT_HOST = "localhost";
-
- public File createTempFile(String prefix, String suffix);
-
- public boolean deleteFile(File file);
-
- public CommandOutput executeCommand(String[] command);
-
- public int openFile(File file) throws IOException;
-
- public byte[] readFile(int descriptor) throws IOException;
-
- public void writeFile(int descriptor, byte[] bytes) throws IOException;
-
- public void closeFile(int descriptor) throws IOException;
-}
-
+package de.mpicbg.sweng.pythonserver;
+
+import java.io.File;
+import java.io.IOException;
+
+
+/**
+ * Remote interface to python. The used implmentation depends on the current context and is configurable by the user.
+ *
+ * @author Tom Haux
+ */
+public interface Python {
+ public String REGISTRY_NAME = "PythonServer";
+ public int DEFAULT_PORT = 1198;
+ public String DEFAULT_HOST = "localhost";
+
+ public File createTempFile(String prefix, String suffix);
+
+ public String getFilePath(File file);
+
+ public boolean deleteFile(File file);
+
+ public CommandOutput executeCommand(String[] command);
+
+ public int openFile(File file) throws IOException;
+
+ public byte[] readFile(int descriptor) throws IOException;
+
+ public void writeFile(int descriptor, byte[] bytes) throws IOException;
+
+ public void closeFile(int descriptor) throws IOException;
+}
+
@@ -1,67 +1,71 @@
-package de.mpicbg.sweng.pythonserver;
-
-import gnu.cajo.utils.extra.TransparentItemProxy;
-
-import java.io.File;
-import java.io.IOException;
-
-
-/**
- * Document me!
- *
- * @author Tom Haux
- */
-public class PythonClient implements Python {
- private Python python;
-
- /**
- * Create PythonClient that communicates with the PythonServer
- */
- public PythonClient() {
- this(Python.DEFAULT_HOST, Python.DEFAULT_PORT);
- }
-
-
- /**
- * Create PythonClient that communicates with the PythonServer
- */
- public PythonClient(String serverName, int serverPort) {
- try {
- String url = "//" +
- serverName + ":" + serverPort + "/" + Python.REGISTRY_NAME;
- python =
- (Python) TransparentItemProxy.getItem(url, new Class[]{Python.class});
- } catch (Throwable
- e) {
- throw new RuntimeException(e);
- }
- }
-
- public File createTempFile(String prefix, String suffix) {
- return python.createTempFile(prefix, suffix);
- }
-
- public boolean deleteFile(File file) {
- return python.deleteFile(file);
- }
-
- public CommandOutput executeCommand(String[] command) {
- return python.executeCommand(command);
- }
-
- public int openFile(File file) throws IOException {
- return python.openFile(file);
- }
-
- public byte[] readFile(int descriptor) throws IOException {
- return python.readFile(descriptor);
- }
-
- public void writeFile(int descriptor, byte[] bytes) throws IOException {
- python.writeFile(descriptor, bytes);
- }
-
- public void closeFile(int descriptor) throws IOException {
- python.closeFile(descriptor);
- }
-}
+package de.mpicbg.sweng.pythonserver;
+
+import gnu.cajo.utils.extra.TransparentItemProxy;
+
+import java.io.File;
+import java.io.IOException;
+
+
+/**
+ * Document me!
+ *
+ * @author Tom Haux
+ */
+public class PythonClient implements Python {
+ private Python python;
+
+ /**
+ * Create PythonClient that communicates with the PythonServer
+ */
+ public PythonClient() {
+ this(Python.DEFAULT_HOST, Python.DEFAULT_PORT);
+ }
+
+
+ /**
+ * Create PythonClient that communicates with the PythonServer
+ */
+ public PythonClient(String serverName, int serverPort) {
+ try {
+ String url = "//" +
+ serverName + ":" + serverPort + "/" + Python.REGISTRY_NAME;
+ python =
+ (Python) TransparentItemProxy.getItem(url, new Class[]{Python.class});
+ } catch (Throwable
+ e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public File createTempFile(String prefix, String suffix) {
+ return python.createTempFile(prefix, suffix);
+ }
+
+ public String getFilePath(File file) {
+ return python.getFilePath(file);
+ }
+
+ public boolean deleteFile(File file) {
+ return python.deleteFile(file);
+ }
+
+ public CommandOutput executeCommand(String[] command) {
+ return python.executeCommand(command);
+ }
+
+ public int openFile(File file) throws IOException {
+ return python.openFile(file);
+ }
+
+ public byte[] readFile(int descriptor) throws IOException {
+ return python.readFile(descriptor);
+ }
+
+ public void writeFile(int descriptor, byte[] bytes) throws IOException {
+ python.writeFile(descriptor, bytes);
+ }
+
+ public void closeFile(int descriptor) throws IOException {
+ python.closeFile(descriptor);
+ }
+}
Oops, something went wrong.

0 comments on commit 03b23bd

Please sign in to comment.