use of com.jetbrains.python.remote.PythonRemoteInterpreterManager in project intellij-community by JetBrains.
the class PythonSdkType method getVersionString.
@Nullable
@Override
public String getVersionString(@NotNull Sdk sdk) {
if (isRemote(sdk)) {
final PyRemoteSdkAdditionalDataBase data = (PyRemoteSdkAdditionalDataBase) sdk.getSdkAdditionalData();
assert data != null;
String versionString = data.getVersionString();
if (StringUtil.isEmpty(versionString)) {
final PythonRemoteInterpreterManager remoteInterpreterManager = PythonRemoteInterpreterManager.getInstance();
if (remoteInterpreterManager != null) {
try {
versionString = remoteInterpreterManager.getInterpreterVersion(null, data);
} catch (Exception e) {
LOG.warn("Couldn't get interpreter version:" + e.getMessage(), e);
versionString = "undefined";
}
}
data.setVersionString(versionString);
}
return versionString;
} else {
return getVersionString(sdk.getHomePath());
}
}
use of com.jetbrains.python.remote.PythonRemoteInterpreterManager in project intellij-community by JetBrains.
the class ProjectSpecificSettingsStep method createBasePanel.
@Override
protected JPanel createBasePanel() {
if (myProjectGenerator instanceof PythonProjectGenerator) {
final BorderLayout layout = new BorderLayout();
final JPanel locationPanel = new JPanel(layout);
final JPanel panel = new JPanel(new VerticalFlowLayout(0, 2));
final LabeledComponent<TextFieldWithBrowseButton> location = createLocationComponent();
locationPanel.add(location, BorderLayout.CENTER);
panel.add(locationPanel);
if (((PythonProjectGenerator) myProjectGenerator).hideInterpreter()) {
addInterpreterButton(locationPanel, location);
} else {
final LabeledComponent<PythonSdkChooserCombo> labeled = createInterpreterCombo();
UIUtil.mergeComponentsWithAnchor(labeled, location);
panel.add(labeled);
}
final PythonRemoteInterpreterManager remoteInterpreterManager = PythonRemoteInterpreterManager.getInstance();
final Sdk sdk = getSdk();
if (remoteInterpreterManager != null && sdk != null) {
createRemotePathField(panel, remoteInterpreterManager);
}
final JPanel basePanelExtension = ((PythonProjectGenerator) myProjectGenerator).extendBasePanel();
if (basePanelExtension != null) {
panel.add(basePanelExtension);
}
return panel;
}
return super.createBasePanel();
}
use of com.jetbrains.python.remote.PythonRemoteInterpreterManager in project intellij-community by JetBrains.
the class PydevConsoleRunnerImpl method createProcessHandler.
private PyConsoleProcessHandler createProcessHandler(final Process process) {
if (PySdkUtil.isRemote(mySdk)) {
PythonRemoteInterpreterManager manager = PythonRemoteInterpreterManager.getInstance();
if (manager != null) {
PyRemoteSdkAdditionalDataBase data = (PyRemoteSdkAdditionalDataBase) mySdk.getSdkAdditionalData();
assert data != null;
myProcessHandler = manager.createConsoleProcessHandler((RemoteProcess) process, myConsoleView, myPydevConsoleCommunication, myCommandLine, CharsetToolkit.UTF8_CHARSET, manager.setupMappings(myProject, data, null), myRemoteProcessHandlerBase.getRemoteSocketToLocalHostProvider());
} else {
LOG.error("Can't create remote console process handler");
}
} else {
myProcessHandler = new PyConsoleProcessHandler(process, myConsoleView, myPydevConsoleCommunication, myCommandLine, CharsetToolkit.UTF8_CHARSET);
}
return myProcessHandler;
}
use of com.jetbrains.python.remote.PythonRemoteInterpreterManager in project intellij-community by JetBrains.
the class PythonSdkDetailsStep method createRemoteSdk.
private void createRemoteSdk() {
PythonRemoteInterpreterManager remoteInterpreterManager = PythonRemoteInterpreterManager.getInstance();
if (remoteInterpreterManager != null) {
remoteInterpreterManager.addRemoteSdk(myProject, myOwnerComponent, Lists.newArrayList(myExistingSdks), mySdkAddedCallback);
} else {
final String pathToPluginsPage = ShowSettingsUtil.getSettingsMenuName() + " | Plugins";
Messages.showErrorDialog(PyBundle.message("remote.interpreter.error.plugin.missing", pathToPluginsPage), PyBundle.message("remote.interpreter.add.title"));
}
}
use of com.jetbrains.python.remote.PythonRemoteInterpreterManager in project intellij-community by JetBrains.
the class PythonSdkType method notifyRemoteSdkSkeletonsFail.
public static void notifyRemoteSdkSkeletonsFail(final InvalidSdkException e, @Nullable final Runnable restartAction) {
NotificationListener notificationListener;
String notificationMessage;
if (e.getCause() instanceof VagrantNotStartedException) {
notificationListener = new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
final PythonRemoteInterpreterManager manager = PythonRemoteInterpreterManager.getInstance();
if (manager != null) {
try {
VagrantNotStartedException cause = (VagrantNotStartedException) e.getCause();
manager.runVagrant(cause.getVagrantFolder(), cause.getMachineName());
} catch (ExecutionException e1) {
throw new RuntimeException(e1);
}
}
if (restartAction != null) {
restartAction.run();
}
}
};
notificationMessage = e.getMessage() + "\n<a href=\"#\">Launch vagrant and refresh skeletons</a>";
} else if (ExceptionUtil.causedBy(e, ExceptionFix.class)) {
//noinspection ThrowableResultOfMethodCallIgnored
final ExceptionFix fix = ExceptionUtil.findCause(e, ExceptionFix.class);
notificationListener = new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
fix.apply();
if (restartAction != null) {
restartAction.run();
}
}
};
notificationMessage = fix.getNotificationMessage(e.getMessage());
} else {
notificationListener = null;
notificationMessage = e.getMessage();
}
Notifications.Bus.notify(new Notification(SKELETONS_TOPIC, "Couldn't refresh skeletons for remote interpreter", notificationMessage, NotificationType.WARNING, notificationListener));
}
Aggregations