mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Python remote interpreters refactored. Common code moved to remote-sdk-api and remote-sdk-impl modules.
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
package com.jetbrains.python.remote;
|
||||
|
||||
/**
|
||||
* @author traff
|
||||
*/
|
||||
public class PyRemoteCancelledException extends PyRemoteInterpreterException {
|
||||
public PyRemoteCancelledException(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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<String, Integer> obtainRemoteSocket() throws PyRemoteInterpreterException;
|
||||
|
||||
void addRemoteForwarding(int remotePort, int localPort);
|
||||
|
||||
List<PyPathMappingSettings.PyPathMapping> getFileMappings();
|
||||
}
|
||||
@@ -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<String, Integer> obtainRemoteSocket(String interpreterPath) throws PyRemoteInterpreterException;
|
||||
|
||||
public abstract boolean hasPty();
|
||||
|
||||
public abstract boolean sendCtrlC();
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user