Select Git revision
-
dgelessus authored
The standard Jupyter command is always called "jupyter" regardless of Python version, so this way the default is more likely to work. If the user's Jupyter command is different, they will more likely know its name than what the underlying Python interpreter is.
dgelessus authoredThe standard Jupyter command is always called "jupyter" regardless of Python version, so this way the default is more likely to work. If the user's Jupyter command is different, they will more likely know its name than what the underlying Python interpreter is.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Main.java 9.44 KiB
package de.prob2.jupyter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.security.CodeSource;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Stage;
import io.github.spencerpark.jupyter.channels.JupyterConnection;
import io.github.spencerpark.jupyter.kernel.KernelConnectionProperties;
import org.jetbrains.annotations.Nullable;
public final class Main {
private Main() {
super();
throw new AssertionError();
}
private static AssertionError die(final int status, final @Nullable Throwable cause) {
System.exit(status);
return new AssertionError("Unreachable", cause);
}
private static AssertionError die(final int status) {
return die(status, null);
}
private static Path getJarPath() {
try {
final CodeSource cs = Main.class.getProtectionDomain().getCodeSource();
if (cs == null) {
System.err.println("Unable to determine location of kernel jar file (CodeSource is null)");
throw die(1);
}
return Paths.get(cs.getLocation().toURI());
} catch (final RuntimeException | URISyntaxException e) {
System.err.println("Unable to determine location of kernel jar file");
e.printStackTrace();
throw die(1, e);
}
}
private static Path getDestPath(final Path jarPath) {
return Paths.get(de.prob.Main.getProBDirectory(), "jupyter", jarPath.getFileName().toString());
}
private static void copyJar(final Path jarPath, final Path destPath) {
System.out.println("Installing kernel jar file...");
System.out.println("Path to kernel jar file: " + jarPath);
System.out.println("Kernel jar will be copied to: " + destPath);
try {
Files.createDirectories(destPath.getParent());