summaryrefslogtreecommitdiff
path: root/python/src/com/jetbrains/python/sdk
diff options
context:
space:
mode:
Diffstat (limited to 'python/src/com/jetbrains/python/sdk')
-rw-r--r--python/src/com/jetbrains/python/sdk/PythonSdkType.java12
-rw-r--r--python/src/com/jetbrains/python/sdk/skeletons/PySkeletonRefresher.java36
-rw-r--r--python/src/com/jetbrains/python/sdk/skeletons/SkeletonErrorsDialog.form61
-rw-r--r--python/src/com/jetbrains/python/sdk/skeletons/SkeletonErrorsDialog.java94
4 files changed, 33 insertions, 170 deletions
diff --git a/python/src/com/jetbrains/python/sdk/PythonSdkType.java b/python/src/com/jetbrains/python/sdk/PythonSdkType.java
index f194f359e1a9..58de09370d37 100644
--- a/python/src/com/jetbrains/python/sdk/PythonSdkType.java
+++ b/python/src/com/jetbrains/python/sdk/PythonSdkType.java
@@ -910,6 +910,16 @@ public class PythonSdkType extends SdkType {
return null;
}
+ @Nullable
+ public static Sdk findPython2Sdk(List<Sdk> sdks) {
+ Collections.sort(sdks, PreferredSdkComparator.INSTANCE);
+ for (Sdk sdk : sdks) {
+ if (!getLanguageLevelForSdk(sdk).isPy3K()) {
+ return sdk;
+ }
+ }
+ return null;
+ }
@Nullable
public static Sdk findLocalCPython(@Nullable Module module) {
@@ -997,7 +1007,7 @@ public class PythonSdkType extends SdkType {
public static boolean isIncompleteRemote(Sdk sdk) {
if (PySdkUtil.isRemote(sdk)) {
//noinspection ConstantConditions
- if (!((PyRemoteSdkAdditionalDataBase)sdk.getSdkAdditionalData()).isInitialized()) {
+ if (!((PyRemoteSdkAdditionalDataBase)sdk.getSdkAdditionalData()).isValid()) {
return true;
}
}
diff --git a/python/src/com/jetbrains/python/sdk/skeletons/PySkeletonRefresher.java b/python/src/com/jetbrains/python/sdk/skeletons/PySkeletonRefresher.java
index 284a125e8736..4e4a43102202 100644
--- a/python/src/com/jetbrains/python/sdk/skeletons/PySkeletonRefresher.java
+++ b/python/src/com/jetbrains/python/sdk/skeletons/PySkeletonRefresher.java
@@ -20,7 +20,6 @@ import com.google.common.collect.Lists;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.execution.ExecutionException;
import com.intellij.notification.Notification;
-import com.intellij.notification.NotificationListener;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.application.ApplicationManager;
@@ -35,6 +34,7 @@ import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
@@ -58,7 +58,6 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import javax.swing.event.HyperlinkEvent;
import java.awt.*;
import java.io.*;
import java.util.*;
@@ -164,18 +163,27 @@ public class PySkeletonRefresher {
else {
message = PyBundle.message("sdk.errorlog.$0.mods.fail.in.$1.sdks", module_errors, errors.size());
}
- Notifications.Bus.notify(
- new Notification(
- PythonSdkType.SKELETONS_TOPIC, PyBundle.message("sdk.some.skeletons.failed"), message,
- NotificationType.WARNING,
- new NotificationListener() {
- @Override
- public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
- new SkeletonErrorsDialog(errors, failedSdks).setVisible(true);
- }
- }
- )
- );
+ logErrors(errors, failedSdks, message);
+ }
+ }
+
+ private static void logErrors(@NotNull final Map<String, List<String>> errors, @NotNull final List<String> failedSdks,
+ @NotNull final String message) {
+ LOG.warn(PyBundle.message("sdk.some.skeletons.failed"));
+ LOG.warn(message);
+
+ if (failedSdks.size() > 0) {
+ LOG.warn(PyBundle.message("sdk.error.dialog.failed.sdks"));
+ LOG.warn(StringUtil.join(failedSdks, ", "));
+ }
+
+ if (errors.size() > 0) {
+ LOG.warn(PyBundle.message("sdk.error.dialog.failed.modules"));
+ for (String sdkName : errors.keySet()) {
+ for (String moduleName : errors.get(sdkName)) {
+ LOG.warn(moduleName);
+ }
+ }
}
}
diff --git a/python/src/com/jetbrains/python/sdk/skeletons/SkeletonErrorsDialog.form b/python/src/com/jetbrains/python/sdk/skeletons/SkeletonErrorsDialog.form
deleted file mode 100644
index c82d5fa91b00..000000000000
--- a/python/src/com/jetbrains/python/sdk/skeletons/SkeletonErrorsDialog.form
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.jetbrains.python.sdk.skeletons.SkeletonErrorsDialog">
- <grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
- <margin top="10" left="10" bottom="10" right="10"/>
- <constraints>
- <xy x="48" y="54" width="436" height="409"/>
- </constraints>
- <properties/>
- <border type="none"/>
- <children>
- <grid id="94766" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
- <margin top="0" left="0" bottom="0" right="0"/>
- <constraints>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties/>
- <border type="none"/>
- <children>
- <grid id="9538f" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
- <margin top="0" left="0" bottom="0" right="0"/>
- <constraints>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties/>
- <border type="none"/>
- <children>
- <component id="e7465" class="javax.swing.JButton" binding="buttonOK">
- <constraints>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties>
- <text value="OK"/>
- </properties>
- </component>
- </children>
- </grid>
- <scrollpane id="d5fbd" class="com.intellij.ui.components.JBScrollPane" binding="myScroller">
- <constraints>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties/>
- <border type="none"/>
- <children>
- <component id="10d56" class="javax.swing.JTextPane" binding="myMessagePane">
- <constraints/>
- <properties>
- <editable value="false"/>
- <enabled value="true"/>
- </properties>
- <clientProperties>
- <JEditorPane.honorDisplayProperties class="java.lang.Boolean" value="true"/>
- <caretAspectRatio class="java.lang.Float" value="0.04"/>
- </clientProperties>
- </component>
- </children>
- </scrollpane>
- </children>
- </grid>
- </children>
- </grid>
-</form>
diff --git a/python/src/com/jetbrains/python/sdk/skeletons/SkeletonErrorsDialog.java b/python/src/com/jetbrains/python/sdk/skeletons/SkeletonErrorsDialog.java
deleted file mode 100644
index f6c6b45ceb44..000000000000
--- a/python/src/com/jetbrains/python/sdk/skeletons/SkeletonErrorsDialog.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2000-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.jetbrains.python.sdk.skeletons;
-
-import com.intellij.ui.components.JBScrollPane;
-import com.jetbrains.python.PyBundle;
-
-import javax.swing.*;
-import javax.swing.border.EmptyBorder;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.List;
-import java.util.Map;
-
-public class SkeletonErrorsDialog extends JDialog {
- private JPanel contentPane;
- private JButton buttonOK;
- private JBScrollPane myScroller;
- private JTextPane myMessagePane;
-
- public SkeletonErrorsDialog(Map<String, List<String>> errors, List<String> failed_sdks) {
- setContentPane(contentPane);
- setModal(true);
- getRootPane().setDefaultButton(buttonOK);
-
- buttonOK.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- dispose();
- }
- });
-
- // fill data
- myMessagePane.setContentType("text/html");
- myMessagePane.setBorder(new EmptyBorder(0, 0, 0, 0));
- StringBuilder sb = new StringBuilder("<html><body style='margin: 4pt;' ");
- final Color foreground = getParent().getForeground();
- final Color background = getParent().getBackground();
- if (foreground != null && background != null) {
- sb.append("text='").append(getHTMLColor(foreground)).append("' ");
- sb.append("bgcolor='").append(getHTMLColor(background)).append("'");
- }
- sb.append(">");
-
- if (failed_sdks.size() > 0) {
- sb.append("<h1>").append(PyBundle.message("sdk.error.dialog.failed.sdks")).append("</h1>");
- sb.append("<ul>");
- for (String sdk_name : failed_sdks) {
- sb.append("<li>").append(sdk_name).append("</li>");
- }
- sb.append("</ul><br>");
- }
-
- if (errors.size() > 0) {
- sb.append("<h1>").append(PyBundle.message("sdk.error.dialog.failed.modules")).append("</h1>");
- for (String sdk_name : errors.keySet()) {
- sb.append("<b>").append(sdk_name).append("</b><br>");
- sb.append("<ul>");
- for (String module_name : errors.get(sdk_name)) {
- sb.append("<li>").append(module_name).append("</li>");
- }
- sb.append("</ul>");
- }
- sb.append(PyBundle.message("sdk.error.dialog.were.blacklisted"));
- }
-
- sb.append("</body></html>");
- myMessagePane.setText(sb.toString());
-
- setTitle(PyBundle.message("sdk.error.dialog.problems"));
-
- pack();
- setLocationRelativeTo(getParent());
- }
-
- private static String getHTMLColor(Color color) {
- StringBuilder sb = new StringBuilder("#");
- sb.append(Integer.toHexString(color.getRGB() & 0xffffff));
- return sb.toString();
- }
-}