Search in sources :

Example 1 with HtmlNotebookOutput

use of com.simiacryptus.util.io.HtmlNotebookOutput in project MindsEye by SimiaCryptus.

the class NotebookReportBase method getLog.

/**
 * Gets log.
 *
 * @param logPath the log path
 * @return the log
 */
@Nonnull
public NotebookOutput getLog(CharSequence... logPath) {
    try {
        if (useMarkdown) {
            return MarkdownNotebookOutput.get(getTargetClass(), absoluteUrl, logPath);
        } else {
            @Nonnull final CharSequence directoryName = new SimpleDateFormat("YYYY-MM-dd-HH-mm").format(new Date());
            @Nonnull final File path = new File(Util.mkString(File.separator, "www", directoryName));
            path.mkdirs();
            @Nonnull final File logFile = new File(path, "index.html");
            @Nonnull final HtmlNotebookOutput log;
            if (preferStatic) {
                log = new HtmlNotebookOutput(path, new FileOutputStream(logFile));
                Desktop.getDesktop().browse(logFile.toURI());
            } else {
                @Nonnull final StreamNanoHTTPD server = new StreamNanoHTTPD(1999, "text/html", logFile).init();
                log = new HtmlNotebookOutput(path, server.dataReciever);
            }
            return log;
        }
    } catch (@Nonnull final IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : HtmlNotebookOutput(com.simiacryptus.util.io.HtmlNotebookOutput) Nonnull(javax.annotation.Nonnull) FileOutputStream(java.io.FileOutputStream) StreamNanoHTTPD(com.simiacryptus.util.StreamNanoHTTPD) IOException(java.io.IOException) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) Date(java.util.Date) Nonnull(javax.annotation.Nonnull)

Example 2 with HtmlNotebookOutput

use of com.simiacryptus.util.io.HtmlNotebookOutput in project MindsEye by SimiaCryptus.

the class ImageDecompositionLab method report.

/**
 * Gets log.
 *
 * @return the log
 */
@Nonnull
public HtmlNotebookOutput report() {
    try {
        @Nonnull final CharSequence directoryName = new SimpleDateFormat("YYYY-MM-dd-HH-mm").format(new Date());
        @Nonnull final File path = new File(Util.mkString(File.separator, "www", directoryName));
        path.mkdirs();
        @Nonnull final File logFile = new File(path, "index.html");
        @Nonnull final StreamNanoHTTPD server = new StreamNanoHTTPD(1999, "text/html", logFile).init();
        @Nonnull final HtmlNotebookOutput log = new HtmlNotebookOutput(path, server.dataReciever);
        return log;
    } catch (@Nonnull final IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : HtmlNotebookOutput(com.simiacryptus.util.io.HtmlNotebookOutput) Nonnull(javax.annotation.Nonnull) StreamNanoHTTPD(com.simiacryptus.util.StreamNanoHTTPD) IOException(java.io.IOException) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) Date(java.util.Date) Nonnull(javax.annotation.Nonnull)

Aggregations

StreamNanoHTTPD (com.simiacryptus.util.StreamNanoHTTPD)2 HtmlNotebookOutput (com.simiacryptus.util.io.HtmlNotebookOutput)2 File (java.io.File)2 IOException (java.io.IOException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 Nonnull (javax.annotation.Nonnull)2 FileOutputStream (java.io.FileOutputStream)1