Skip to content

Commit

Permalink
Fix Sean's findings :) (#138)
Browse files Browse the repository at this point in the history
* Use base_url for images
* Use python from kernel instead of one from path
* Propagate task failure error if any
  • Loading branch information
Jonathan Curran authored Dec 3, 2018
1 parent 64e2abb commit 86f45d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
5 changes: 4 additions & 1 deletion rsconnect/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,10 @@ def deploy(uri, api_key, app_id, app_name, app_title, tarball):

if task['code'] != 0:
# app failed to deploy
raise RSConnectException('Failed to deploy successfully')
err_msg = 'Failed to deploy successfully'
if 'error' in task:
err_msg += ': ' + task['error']
raise RSConnectException(err_msg)

# app deployed successfully
config = api.app_config(app['id'])
Expand Down
16 changes: 10 additions & 6 deletions rsconnect/static/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,13 @@ define([
inspectEnvironment: function() {
var path = Jupyter.notebook.notebook_name;

// TODO: cannot assume rsconnect is installed in the kernel environment
var cmd = "!python -m rsconnect.environment ${PWD}/" + path;
console.log("executing: " + cmd);
try {
// cannot assume rsconnect is installed in the kernel environment
var cmd = ["!", Jupyter.notebook.kernel_selector.kernelspecs[Jupyter.notebook.kernel.name].spec.argv[0], " -m rsconnect.environment ${PWD}/", path].join("");
console.log("executing: " + cmd);
} catch (e) {
return $.Deferred().reject(e);
}

var result = $.Deferred();
var content = "";
Expand Down Expand Up @@ -760,12 +764,12 @@ define([
" <label>Publish Source Code</label>",
' <div class="list-group">',
' <a href="#" id="rsc-publish-with-source" class="list-group-item rsc-appmode" data-appmode="jupyter-static">',
' <img src="/nbextensions/rsconnect/images/publishDocWithSource.png" class="rsc-image">',
' <img src="' + Jupyter.notebook.base_url + 'nbextensions/rsconnect/images/publishDocWithSource.png" class="rsc-image">',
' <span class="rsc-label">Publish document with source code</span><br/>',
' <span class="rsc-text-light">Choose this option if you want to create a scheduled report or rebuild your document on the server</span>',
" </a>",
' <a href="#" id="rsc-publish-without-source" class="list-group-item rsc-appmode" data-appmode="static">',
' <img src="/nbextensions/rsconnect/images/publishDocWithoutSource.png" class="rsc-image">',
' <img src="' + Jupyter.notebook.base_url + 'nbextensions/rsconnect/images/publishDocWithoutSource.png" class="rsc-image">',
' <span class="rsc-label">Publish finished document only</span><br/>',
' <span class="rsc-text-light">Choose this option to publish a snapshot of the notebook as it appears in Jupyter</span>',
" </a>",
Expand Down Expand Up @@ -910,7 +914,7 @@ define([
addValidationMarkup(
false,
txtTitle,
"Failed to publish. " + xhr.responseJSON.message
xhr.responseJSON.message
);
togglePublishButton(true);
}
Expand Down

0 comments on commit 86f45d9

Please sign in to comment.