reprozip-jupyter/reprozip_jupyter/notebook-extension.js
// Called when the user clicks the "trace" action
Called when the user clicks the "trace" action
Called when the user clicks the " trace " action
function fn_trace(env) {
        var cancel = function cancel() {};
        var modal = dialog.modal({
            body: "Executing notebook under trace...",
            title: "Packing notebook with ReproZip",
            buttons: {
                "Cancel": {
                    class: "btn-warning",
                    click: cancel
                }
            },
            notebook: env.notebook,
            keyboard_manager: env.notebook.keyboard_manager
        });
        var saved = function saved() {
            env.notebook.events.off("notebook_saved.Notebook", saved);
            console.log("reprozip: notebook saved, triggering trace");
            ajax(utils.url_path_join(IPython.notebook.base_url,
                                         "reprozip/trace"), {
                method: "POST",
                data: {file: IPython.notebook.notebook_path}
            }).then(function packed(response) {
                if(response.error) {
                    console.log("reprozip: got error response");
                    modal.modal("hide");
                    var m = dialog.modal({
                        body: response.error,
                        title: "Packing notebook with ReproZip",
                        buttons: {
                            "Close": {
                                class: "btn-danger"
                            }
                        }
                    });
                } else {
                    console.log("reprozip: packing successful");
                    modal.modal("hide");
                    dialog.modal({
                        body: "Created package " + response.bundle,
                        title: "Packing notebook with ReproZip",
                        buttons: {
                            "Close": {
                                class: "btn-primary"
                            }
                        }
                    });
                }
            }, function failed() {
                console.error("reprozip: packing failed");
                modal.modal("hide");
                var m = dialog.modal({
                    body: "Packing failed!",
                    title: "Packing notebook with ReproZip",
                    show: false,
                    buttons: {
                        "Close": {
                            class: "btn-danger"
                        }
                    }
                });
                m.find(".modal-body").html("<div class=\"alert alert-danger\"><strong>Packing failed!</strong> Check the server console for details.</div>");
                m.modal("show");
            });
        };
        console.log("reprozip: saving notebook")
        env.notebook.events.on("notebook_saved.Notebook", saved);
        env.notebook.save_checkpoint();
    }
function fn_trace ( env ) { var cancel = function cancel ( ) { } ; var modal = dialog . modal ( { body : "Executing notebook under trace..." , title : "Packing notebook with ReproZip" , buttons : { "Cancel" : { class : "btn-warning" , click : cancel } } , notebook : env . notebook , keyboard_manager : env . notebook . keyboard_manager } ) ; var saved = function saved ( ) { env . notebook . events . off ( "notebook_saved.Notebook" , saved ) ; console . log ( "reprozip: notebook saved, triggering trace" ) ; ajax ( utils . url_path_join ( IPython . notebook . base_url , "reprozip/trace" ) , { method : "POST" , data : { file : IPython . notebook . notebook_path } } ) . then ( function packed ( response ) { if ( response . error ) { console . log ( "reprozip: got error response" ) ; modal . modal ( "hide" ) ; var m = dialog . modal ( { body : response . error , title : "Packing notebook with ReproZip" , buttons : { "Close" : { class : "btn-danger" } } } ) ; } else { console . log ( "reprozip: packing successful" ) ; modal . modal ( "hide" ) ; dialog . modal ( { body : "Created package " + response . bundle , title : "Packing notebook with ReproZip" , buttons : { "Close" : { class : "btn-primary" } } } ) ; } } , function failed ( ) { console . error ( "reprozip: packing failed" ) ; modal . modal ( "hide" ) ; var m = dialog . modal ( { body : "Packing failed!" , title : "Packing notebook with ReproZip" , show : false , buttons : { "Close" : { class : "btn-danger" } } } ) ; m . find ( ".modal-body" ) . html ( "<div class=\"alert alert-danger\"><strong>Packing failed!</strong> Check the server console for details.</div>" ) ; m . modal ( "show" ) ; } ) ; } ; console . log ( "reprozip: saving notebook" ) env . notebook . events . on ( "notebook_saved.Notebook" , saved ) ; env . notebook . save_checkpoint ( ) ; }
Called when the user clicks the "trace" action
Called when the user clicks the " trace " action
// TODO: Cancel trace? // Save the notebook first, get called back when it is done // (there is a round-trip to the server)