Search in sources :

Example 6 with PythonRemoteInterpreterManager

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());
    }
}
Also used : PyRemoteSdkAdditionalDataBase(com.jetbrains.python.remote.PyRemoteSdkAdditionalDataBase) PythonRemoteInterpreterManager(com.jetbrains.python.remote.PythonRemoteInterpreterManager) ExecutionException(com.intellij.execution.ExecutionException) IOException(java.io.IOException) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with PythonRemoteInterpreterManager

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();
}
Also used : PythonProjectGenerator(com.jetbrains.python.newProject.PythonProjectGenerator) Sdk(com.intellij.openapi.projectRoots.Sdk) PythonRemoteInterpreterManager(com.jetbrains.python.remote.PythonRemoteInterpreterManager)

Example 8 with PythonRemoteInterpreterManager

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;
}
Also used : PyRemoteSdkAdditionalDataBase(com.jetbrains.python.remote.PyRemoteSdkAdditionalDataBase) RemoteProcess(com.intellij.remote.RemoteProcess) PythonRemoteInterpreterManager(com.jetbrains.python.remote.PythonRemoteInterpreterManager)

Example 9 with PythonRemoteInterpreterManager

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"));
    }
}
Also used : PythonRemoteInterpreterManager(com.jetbrains.python.remote.PythonRemoteInterpreterManager)

Example 10 with PythonRemoteInterpreterManager

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));
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) ExecutionException(com.intellij.execution.ExecutionException) PythonRemoteInterpreterManager(com.jetbrains.python.remote.PythonRemoteInterpreterManager) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Aggregations

PythonRemoteInterpreterManager (com.jetbrains.python.remote.PythonRemoteInterpreterManager)10 ExecutionException (com.intellij.execution.ExecutionException)5 Sdk (com.intellij.openapi.projectRoots.Sdk)3 PyRemoteSdkAdditionalDataBase (com.jetbrains.python.remote.PyRemoteSdkAdditionalDataBase)3 Nullable (org.jetbrains.annotations.Nullable)3 RemoteProcess (com.intellij.remote.RemoteProcess)2 PyRemotePathMapper (com.jetbrains.python.remote.PyRemotePathMapper)2 IOException (java.io.IOException)2 NotNull (org.jetbrains.annotations.NotNull)2 Function (com.google.common.base.Function)1 ProcessOutput (com.intellij.execution.process.ProcessOutput)1 Notification (com.intellij.notification.Notification)1 NotificationListener (com.intellij.notification.NotificationListener)1 Application (com.intellij.openapi.application.Application)1 SdkAdditionalData (com.intellij.openapi.projectRoots.SdkAdditionalData)1 SdkModificator (com.intellij.openapi.projectRoots.SdkModificator)1 RemoteSdkAdditionalData (com.intellij.remote.RemoteSdkAdditionalData)1 RemoteSdkCredentials (com.intellij.remote.RemoteSdkCredentials)1 PathMappingSettings (com.intellij.util.PathMappingSettings)1 XDebugProcess (com.intellij.xdebugger.XDebugProcess)1