mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-18604 Rename ipython notebook to the jupyter notebook and use jupyter runner if any
This commit is contained in:
@@ -38,7 +38,7 @@ public class IpnbFileType implements FileType {
|
||||
|
||||
@NotNull
|
||||
public String getDescription() {
|
||||
return "IPython Notebook";
|
||||
return "Jupyter Notebook";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="IPython Notebook URL:"/>
|
||||
<text value="Jupyter Notebook URL:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="5a5b" class="com.intellij.ui.components.JBTextField" binding="myFieldUrl">
|
||||
|
||||
@@ -23,7 +23,7 @@ public class IpnbConfigurable implements SearchableConfigurable {
|
||||
@Nls
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "IPython Notebook";
|
||||
return "Jupyter Notebook";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+35
-13
@@ -125,7 +125,7 @@ public final class IpnbConnectionManager implements ProjectComponent {
|
||||
|
||||
@Nullable
|
||||
public static String showDialogUrl(@NotNull final String initialUrl) {
|
||||
final String url = Messages.showInputDialog("IPython Notebook URL:", "Start IPython Notebook", null, initialUrl,
|
||||
final String url = Messages.showInputDialog("Jupyter Notebook URL:", "Start Jupyter Notebook", null, initialUrl,
|
||||
new InputValidator() {
|
||||
@Override
|
||||
public boolean checkInput(String inputString) {
|
||||
@@ -195,16 +195,16 @@ public final class IpnbConnectionManager implements ProjectComponent {
|
||||
catch (URISyntaxException e) {
|
||||
if (showNotification && codePanel != null) {
|
||||
showWarning(codePanel.getFileEditor(),
|
||||
"Please, check IPython Notebook URL in <a href=\"\">Settings->Tools->IPython Notebook</a>",
|
||||
"Please, check Jupyter Notebook URL in <a href=\"\">Settings->Tools->Jupyter Notebook</a>",
|
||||
new IpnbSettingsAdapter());
|
||||
LOG.warn("IPython Notebook connection refused: " + e.getMessage());
|
||||
LOG.warn("Jupyter Notebook connection refused: " + e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
if (showNotification) {
|
||||
LOG.warn("IPython Notebook connection refused: " + e.getMessage());
|
||||
LOG.warn("Jupyter Notebook connection refused: " + e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -269,7 +269,7 @@ public final class IpnbConnectionManager implements ProjectComponent {
|
||||
try {
|
||||
final PyPackage ipythonPackage = PyPackageManager.getInstance(sdk).findPackage("ipython", false);
|
||||
if (ipythonPackage == null) {
|
||||
showWarning(fileEditor, "Add IPython to the interpreter of the current project.", null);
|
||||
showWarning(fileEditor, "Add Jupyter to the interpreter of the current project.", null);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -278,7 +278,7 @@ public final class IpnbConnectionManager implements ProjectComponent {
|
||||
|
||||
final Pair<String, String> hostPort = getHostPortFromUrl(url);
|
||||
if (hostPort == null) {
|
||||
showWarning(fileEditor, "Please, check IPython Notebook URL in <a href=\"\">Settings->Tools->IPython Notebook</a>",
|
||||
showWarning(fileEditor, "Please, check Jupyter Notebook URL in <a href=\"\">Settings->Tools->Jupyter Notebook</a>",
|
||||
new IpnbSettingsAdapter());
|
||||
return false;
|
||||
}
|
||||
@@ -287,14 +287,23 @@ public final class IpnbConnectionManager implements ProjectComponent {
|
||||
showWarning(fileEditor, "Python Sdk is invalid, please check Python Interpreter in Settings->Python Interpreter", null);
|
||||
return false;
|
||||
}
|
||||
String ipython = findIPythonRunner(homePath);
|
||||
Map<String, String> env = null;
|
||||
final ArrayList<String> parameters = Lists.newArrayList(homePath);
|
||||
String ipython = findJupyterRunner(homePath);
|
||||
if (ipython == null) {
|
||||
ipython = PythonHelper.LOAD_ENTRY_POINT.asParamString();
|
||||
env = ImmutableMap.of("PYCHARM_EP_DIST", "ipython", "PYCHARM_EP_NAME", "ipython");
|
||||
ipython = findIPythonRunner(homePath);
|
||||
if (ipython == null) {
|
||||
ipython = PythonHelper.LOAD_ENTRY_POINT.asParamString();
|
||||
env = ImmutableMap.of("PYCHARM_EP_DIST", "ipython", "PYCHARM_EP_NAME", "ipython");
|
||||
}
|
||||
parameters.add(ipython);
|
||||
parameters.add("notebook");
|
||||
}
|
||||
else {
|
||||
parameters.add(ipython);
|
||||
}
|
||||
parameters.add("--no-browser");
|
||||
|
||||
final ArrayList<String> parameters = Lists.newArrayList(homePath, ipython, "notebook", "--no-browser");
|
||||
if (hostPort.getFirst() != null) {
|
||||
parameters.add("--ip");
|
||||
parameters.add(hostPort.getFirst());
|
||||
@@ -336,7 +345,7 @@ public final class IpnbConnectionManager implements ProjectComponent {
|
||||
@Override
|
||||
public void run() {
|
||||
new RunContentExecutor(myProject, processHandler)
|
||||
.withTitle("IPython Notebook")
|
||||
.withTitle("Jupyter Notebook")
|
||||
.withStop(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -372,7 +381,8 @@ public final class IpnbConnectionManager implements ProjectComponent {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String findIPythonRunner(String homePath) {
|
||||
@Deprecated
|
||||
private static String findIPythonRunner(@NotNull final String homePath) {
|
||||
for (String name : Lists.newArrayList("ipython", "ipython-script.py")) {
|
||||
String runnerPath = PythonSdkType.getExecutablePath(homePath, name);
|
||||
if (runnerPath != null) {
|
||||
@@ -383,6 +393,18 @@ public final class IpnbConnectionManager implements ProjectComponent {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String findJupyterRunner(@NotNull final String homePath) {
|
||||
for (String name : Lists.newArrayList("jupyter-notebook", "jupyter")) {
|
||||
String runnerPath = PythonSdkType.getExecutablePath(homePath, name);
|
||||
if (runnerPath != null) {
|
||||
return runnerPath;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Pair<String, String> getHostPortFromUrl(@NotNull String url) {
|
||||
try {
|
||||
@@ -435,7 +457,7 @@ public final class IpnbConnectionManager implements ProjectComponent {
|
||||
class IpnbSettingsAdapter extends HyperlinkAdapter {
|
||||
@Override
|
||||
protected void hyperlinkActivated(HyperlinkEvent e) {
|
||||
ShowSettingsUtil.getInstance().showSettingsDialog(myProject, "IPython Notebook");
|
||||
ShowSettingsUtil.getInstance().showSettingsDialog(myProject, "Jupyter Notebook");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,18 +24,18 @@ import org.jetbrains.plugins.ipnb.IpnbFileType;
|
||||
|
||||
public class IpnbCreateFileAction extends CreateFileFromTemplateAction implements DumbAware {
|
||||
public IpnbCreateFileAction() {
|
||||
super("IPython Notebook", "Creates an IPython Notebook file from the specified template", IpnbFileType.INSTANCE.getIcon());
|
||||
super("Jupyter Notebook", "Creates an Jupyter Notebook file from the specified template", IpnbFileType.INSTANCE.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) {
|
||||
builder
|
||||
.setTitle("New IPython Notebook")
|
||||
.addKind("IPython Notebook", IpnbFileType.INSTANCE.getIcon(), "IPython Notebook");
|
||||
.setTitle("New Jupyter Notebook")
|
||||
.addKind("Jupyter Notebook", IpnbFileType.INSTANCE.getIcon(), "Jupyter Notebook");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getActionName(PsiDirectory directory, String newName, String templateName) {
|
||||
return "Create IPython Notebook " + newName;
|
||||
return "Create Jupyter Notebook " + newName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,8 @@ public class IpnbParser {
|
||||
if (sdk != null) {
|
||||
try {
|
||||
final PyPackage ipython = PyPackageManager.getInstance(sdk).findPackage("ipython", true);
|
||||
if (ipython != null && VersionComparatorUtil.compare(ipython.getVersion(), "3.0") <= 0) {
|
||||
final PyPackage jupyter = PyPackageManager.getInstance(sdk).findPackage("jupyter", true);
|
||||
if (jupyter == null && ipython != null && VersionComparatorUtil.compare(ipython.getVersion(), "3.0") <= 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user