From 1614abc8124baa63f1b9b409db8bf15df2104be1 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Wed, 26 Sep 2012 18:29:36 +0400 Subject: [PATCH] Python remote interpreters refactored. Common code moved to remote-sdk-api and remote-sdk-impl modules. --- .../remote/PyRemoteCancelledException.java | 10 -- .../remote/PyRemoteInterpreterException.java | 43 -------- .../remote/PyRemoteInterpreterSettings.java | 26 ----- .../remote/PyRemoteProcessHandlerBase.java | 19 ---- .../python/remote/PyRemoteSshProcess.java | 18 ---- .../jetbrains/python/remote/RemoteFile.java | 100 ------------------ 6 files changed, 216 deletions(-) delete mode 100644 python/src/com/jetbrains/python/remote/PyRemoteCancelledException.java delete mode 100644 python/src/com/jetbrains/python/remote/PyRemoteInterpreterException.java delete mode 100644 python/src/com/jetbrains/python/remote/PyRemoteInterpreterSettings.java delete mode 100644 python/src/com/jetbrains/python/remote/PyRemoteProcessHandlerBase.java delete mode 100644 python/src/com/jetbrains/python/remote/PyRemoteSshProcess.java delete mode 100644 python/src/com/jetbrains/python/remote/RemoteFile.java diff --git a/python/src/com/jetbrains/python/remote/PyRemoteCancelledException.java b/python/src/com/jetbrains/python/remote/PyRemoteCancelledException.java deleted file mode 100644 index 425747922612..000000000000 --- a/python/src/com/jetbrains/python/remote/PyRemoteCancelledException.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.jetbrains.python.remote; - -/** - * @author traff - */ -public class PyRemoteCancelledException extends PyRemoteInterpreterException { - public PyRemoteCancelledException(String s) { - super(s); - } -} diff --git a/python/src/com/jetbrains/python/remote/PyRemoteInterpreterException.java b/python/src/com/jetbrains/python/remote/PyRemoteInterpreterException.java deleted file mode 100644 index 175d73baecde..000000000000 --- a/python/src/com/jetbrains/python/remote/PyRemoteInterpreterException.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.jetbrains.python.remote; - -import java.net.NoRouteToHostException; - -/** - * @author traff - */ -public class PyRemoteInterpreterException extends Exception { - private final boolean myNoRouteToHost; - private final boolean myAuthFailed; - - public PyRemoteInterpreterException(String s, Throwable throwable) { - super(s, throwable); - myNoRouteToHost = throwable instanceof NoRouteToHostException; - myAuthFailed = false; - } - - public PyRemoteInterpreterException(String s) { - super(s); - myAuthFailed = false; - myNoRouteToHost = false; - } - - public boolean isNoRouteToHost() { - return myNoRouteToHost; - } - - public boolean isAuthFailed() { - return myAuthFailed; - } - - public String getMessage() { - if (myNoRouteToHost) { - return getCause().getMessage(); - } - else if (myAuthFailed) { - return "Authentication failed"; - } - else { - return super.getMessage(); - } - } -} diff --git a/python/src/com/jetbrains/python/remote/PyRemoteInterpreterSettings.java b/python/src/com/jetbrains/python/remote/PyRemoteInterpreterSettings.java deleted file mode 100644 index f8ad8f1a6a13..000000000000 --- a/python/src/com/jetbrains/python/remote/PyRemoteInterpreterSettings.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.jetbrains.python.remote; - -/** - * @author traff - */ -public interface PyRemoteInterpreterSettings { - String getHost(); - - int getPort(); - - String getInterpreterPath(); - - String getUserName(); - - String getPassword(); - - boolean isAnonymous(); - - String getPrivateKeyFile(); - - String getKnownHostsFile(); - - String getPassphrase(); - - boolean isUseKeyPair(); -} diff --git a/python/src/com/jetbrains/python/remote/PyRemoteProcessHandlerBase.java b/python/src/com/jetbrains/python/remote/PyRemoteProcessHandlerBase.java deleted file mode 100644 index dadc789e0ee4..000000000000 --- a/python/src/com/jetbrains/python/remote/PyRemoteProcessHandlerBase.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.jetbrains.python.remote; - -import com.intellij.openapi.util.Pair; -import com.jetbrains.python.debugger.remote.PyPathMappingSettings; - -import java.util.List; - -/** - * @author traff - */ -public interface PyRemoteProcessHandlerBase { - PyPathMappingSettings getMappingSettings(); - - Pair obtainRemoteSocket() throws PyRemoteInterpreterException; - - void addRemoteForwarding(int remotePort, int localPort); - - List getFileMappings(); -} diff --git a/python/src/com/jetbrains/python/remote/PyRemoteSshProcess.java b/python/src/com/jetbrains/python/remote/PyRemoteSshProcess.java deleted file mode 100644 index 36cb0bd37246..000000000000 --- a/python/src/com/jetbrains/python/remote/PyRemoteSshProcess.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.jetbrains.python.remote; - -import com.intellij.openapi.util.Pair; - -/** - * @author traff - */ -abstract public class PyRemoteSshProcess extends Process { - public abstract void addRemoteTunnel(int remotePort, String host, int localPort) throws PyRemoteInterpreterException; - - public abstract void addLocalTunnel(int localPort, String host, int remotePort) throws PyRemoteInterpreterException; - - public abstract Pair obtainRemoteSocket(String interpreterPath) throws PyRemoteInterpreterException; - - public abstract boolean hasPty(); - - public abstract boolean sendCtrlC(); -} diff --git a/python/src/com/jetbrains/python/remote/RemoteFile.java b/python/src/com/jetbrains/python/remote/RemoteFile.java deleted file mode 100644 index e5585c4a32dd..000000000000 --- a/python/src/com/jetbrains/python/remote/RemoteFile.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.jetbrains.python.remote; - -import com.intellij.openapi.util.io.FileUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author traff - */ -public class RemoteFile { - - private final boolean myWin; - private final String myPath; - - public RemoteFile(@NotNull String path, boolean isWin) { - myPath = toSystemDependent(path, isWin); - myWin = isWin; - } - - public RemoteFile(@NotNull String parent, String child) { - this(resolveChild(parent, child, isWindowsPath(parent)), isWindowsPath(parent)); - } - - public RemoteFile(@NotNull String parent, String child, boolean isWin) { - this(resolveChild(parent, child, isWin), isWin); - } - - @Nullable - public String getName() { - int ind = myPath.lastIndexOf(getSeparator(myWin)); - if (ind != -1 && ind < myPath.length() - 1) { //not last char - return myPath.substring(ind + 1); - } - else { - return null; - } - } - - private static String resolveChild(@NotNull String parent, @NotNull String child, boolean win) { - String separator = getSeparator(win); - - String path; - if (parent.endsWith(separator)) { - path = parent + child; - } - else { - path = parent + separator + child; - } - return path; - } - - private static String getSeparator(boolean win) { - String separator; - if (win) { - separator = "\\"; - } - else { - separator = "/"; - } - return separator; - } - - - public String getPath() { - return myPath; - } - - public boolean isWin() { - return isWindowsPath(myPath); - } - - public static boolean isWindowsPath(@NotNull String path) { - return path.contains("\\"); - } - - private static String toSystemDependent(@NotNull String path, boolean isWin) { - char separator = isWin ? '\\' : '/'; - return FileUtil.toSystemIndependentName(path).replace('/', separator); - } - - public static RemoteFileBuilder detectSystemByPath(@NotNull String path) { - return new RemoteFileBuilder(isWindowsPath(path)); - } - - public static class RemoteFileBuilder { - private final boolean isWin; - - private RemoteFileBuilder(boolean win) { - isWin = win; - } - - public RemoteFile createRemoteFile(String path) { - return new RemoteFile(path, isWin); - } - - public RemoteFile createRemoteFile(String path, String child) { - return new RemoteFile(path, child, isWin); - } - } -}