Show More
@@ -94,7 +94,7 b' class ContentManager(LoggingConfigurable):' | |||||
94 | "path": content_path, |
|
94 | "path": content_path, | |
95 | "type": type, |
|
95 | "type": type, | |
96 | "MIME-type": "", |
|
96 | "MIME-type": "", | |
97 | "last_modified": last_modified.ctime(), |
|
97 | "last_modified (UTC)": last_modified.ctime(), | |
98 | "size": size} |
|
98 | "size": size} | |
99 | return model |
|
99 | return model | |
100 |
|
100 |
@@ -53,6 +53,20 b' class ContentHandler(IPythonHandler):' | |||||
53 | self.set_status(204) |
|
53 | self.set_status(204) | |
54 | self.finish() |
|
54 | self.finish() | |
55 |
|
55 | |||
|
56 | class ServicesRedirectHandler(IPythonHandler): | |||
|
57 | ||||
|
58 | @web.authenticated | |||
|
59 | def get(self): | |||
|
60 | url = self.base_project_url + 'api' | |||
|
61 | self.redirect(url) | |||
|
62 | ||||
|
63 | class ServicesHandler(IPythonHandler): | |||
|
64 | ||||
|
65 | @web.authenticated | |||
|
66 | def get(self): | |||
|
67 | services = ['contents', 'notebooks', 'sessions', 'kernels', 'clusters'] | |||
|
68 | self.finish(jsonapi.dumps(services)) | |||
|
69 | ||||
56 |
|
70 | |||
57 | #----------------------------------------------------------------------------- |
|
71 | #----------------------------------------------------------------------------- | |
58 | # URL to handler mappings |
|
72 | # URL to handler mappings | |
@@ -62,7 +76,10 b' _content_path_regex = r"(?P<content_path>.+)"' | |||||
62 |
|
76 | |||
63 | default_handlers = [ |
|
77 | default_handlers = [ | |
64 | (r"api/contents/%s" % _content_path_regex, ContentHandler), |
|
78 | (r"api/contents/%s" % _content_path_regex, ContentHandler), | |
65 | (r"api/contents", ContentRootHandler) |
|
79 | (r"api/contents", ContentRootHandler), | |
|
80 | (r"api/", ServicesRedirectHandler), | |||
|
81 | (r"api", ServicesHandler) | |||
|
82 | ||||
66 | ] |
|
83 | ] | |
67 |
|
84 | |||
68 |
|
85 |
@@ -76,13 +76,13 b' class MappingKernelManager(MultiKernelManager):' | |||||
76 | """Shutdown a kernel by kernel_id""" |
|
76 | """Shutdown a kernel by kernel_id""" | |
77 | i = 0 |
|
77 | i = 0 | |
78 | for kernel in self.kernels: |
|
78 | for kernel in self.kernels: | |
79 |
if kernel[' |
|
79 | if kernel['id'] == kernel_id: | |
80 | del self.kernels[i] |
|
80 | del self.kernels[i] | |
81 | i = i+1 |
|
81 | i = i+1 | |
82 | super(MappingKernelManager, self).shutdown_kernel(kernel_id, now=now) |
|
82 | super(MappingKernelManager, self).shutdown_kernel(kernel_id, now=now) | |
83 |
|
83 | |||
84 | def kernel_model(self, kernel_id, ws_url): |
|
84 | def kernel_model(self, kernel_id, ws_url): | |
85 |
model = {" |
|
85 | model = {"id":kernel_id, "ws_url": ws_url} | |
86 | self.kernels.append(model) |
|
86 | self.kernels.append(model) | |
87 | return model |
|
87 | return model | |
88 |
|
88 |
@@ -135,9 +135,9 b' class NotebookManager(LoggingConfigurable):' | |||||
135 | def notebook_model(self, notebook_name, notebook_path=None, content=True): |
|
135 | def notebook_model(self, notebook_name, notebook_path=None, content=True): | |
136 | """ Creates the standard notebook model """ |
|
136 | """ Creates the standard notebook model """ | |
137 | last_modified, contents = self.read_notebook_object(notebook_name, notebook_path) |
|
137 | last_modified, contents = self.read_notebook_object(notebook_name, notebook_path) | |
138 |
model = {" |
|
138 | model = {"name": notebook_name, | |
139 |
" |
|
139 | "path": notebook_path, | |
140 | "last_modified": last_modified.ctime()} |
|
140 | "last_modified (UTC)": last_modified.ctime()} | |
141 | if content == True: |
|
141 | if content == True: | |
142 | model['content'] = contents |
|
142 | model['content'] = contents | |
143 | return model |
|
143 | return model |
@@ -38,8 +38,8 b' class SessionManager(LoggingConfigurable):' | |||||
38 | """Get an existing session or create a new one""" |
|
38 | """Get an existing session or create a new one""" | |
39 | model = None |
|
39 | model = None | |
40 | for session in self.sessions: |
|
40 | for session in self.sessions: | |
41 |
if session[' |
|
41 | if session['name'] == nb_name and session['path'] == nb_path: | |
42 |
session_id = session[' |
|
42 | session_id = session['id'] | |
43 | model = session |
|
43 | model = session | |
44 | if model != None: |
|
44 | if model != None: | |
45 | return session_id, model |
|
45 | return session_id, model | |
@@ -49,12 +49,12 b' class SessionManager(LoggingConfigurable):' | |||||
49 |
|
49 | |||
50 | def session_model(self, session_id, notebook_name=None, notebook_path=None, kernel=None): |
|
50 | def session_model(self, session_id, notebook_name=None, notebook_path=None, kernel=None): | |
51 | """ Create a session that links notebooks with kernels """ |
|
51 | """ Create a session that links notebooks with kernels """ | |
52 |
model = dict( |
|
52 | model = dict(id=session_id, | |
53 |
|
|
53 | name=notebook_name, | |
54 |
|
|
54 | path=notebook_path, | |
55 | kernel=kernel) |
|
55 | kernel=kernel) | |
56 | if notebook_path == None: |
|
56 | if notebook_path == None: | |
57 |
model[' |
|
57 | model['path']="" | |
58 | self.sessions.append(model) |
|
58 | self.sessions.append(model) | |
59 | return model |
|
59 | return model | |
60 |
|
60 | |||
@@ -65,33 +65,33 b' class SessionManager(LoggingConfigurable):' | |||||
65 | def set_kernel_for_sessions(self, session_id, kernel_id): |
|
65 | def set_kernel_for_sessions(self, session_id, kernel_id): | |
66 | """Maps the kernel_ids to the session_id in session_mapping""" |
|
66 | """Maps the kernel_ids to the session_id in session_mapping""" | |
67 | for session in self.sessions: |
|
67 | for session in self.sessions: | |
68 |
if session[' |
|
68 | if session['id'] == session_id: | |
69 |
session['kernel |
|
69 | session['kernel']['id'] = kernel_id | |
70 | return self.sessions |
|
70 | return self.sessions | |
71 |
|
71 | |||
72 | def delete_mapping_for_session(self, session_id): |
|
72 | def delete_mapping_for_session(self, session_id): | |
73 | """Delete the session from session_mapping with the given session_id""" |
|
73 | """Delete the session from session_mapping with the given session_id""" | |
74 | i = 0 |
|
74 | i = 0 | |
75 | for session in self.sessions: |
|
75 | for session in self.sessions: | |
76 |
if session[' |
|
76 | if session['id'] == session_id: | |
77 | del self.sessions[i] |
|
77 | del self.sessions[i] | |
78 | i = i + 1 |
|
78 | i = i + 1 | |
79 | return self.sessions |
|
79 | return self.sessions | |
80 |
|
80 | |||
81 | def get_session_from_id(self, session_id): |
|
81 | def get_session_from_id(self, session_id): | |
82 | for session in self.sessions: |
|
82 | for session in self.sessions: | |
83 |
if session[' |
|
83 | if session['id'] == session_id: | |
84 | return session |
|
84 | return session | |
85 |
|
85 | |||
86 | def get_notebook_from_session(self, session_id): |
|
86 | def get_notebook_from_session(self, session_id): | |
87 | """Returns the notebook_path for the given session_id""" |
|
87 | """Returns the notebook_path for the given session_id""" | |
88 | for session in self.sessions: |
|
88 | for session in self.sessions: | |
89 |
if session[' |
|
89 | if session['id'] == session_id: | |
90 |
return session[' |
|
90 | return session['name'] | |
91 |
|
91 | |||
92 | def get_kernel_from_session(self, session_id): |
|
92 | def get_kernel_from_session(self, session_id): | |
93 | """Returns the kernel_id for the given session_id""" |
|
93 | """Returns the kernel_id for the given session_id""" | |
94 | for session in self.sessions: |
|
94 | for session in self.sessions: | |
95 |
if session[' |
|
95 | if session['id'] == session_id: | |
96 |
return session['kernel'][' |
|
96 | return session['kernel']['id'] | |
97 |
|
97 |
@@ -1520,16 +1520,6 b' var IPython = (function (IPython) {' | |||||
1520 | // Persistance and loading |
|
1520 | // Persistance and loading | |
1521 |
|
1521 | |||
1522 | /** |
|
1522 | /** | |
1523 | * Getter method for this notebook's ID. |
|
|||
1524 | * |
|
|||
1525 | * @method get_notebook_id |
|
|||
1526 | * @return {String} This notebook's ID |
|
|||
1527 | */ |
|
|||
1528 | Notebook.prototype.get_notebook_id = function () { |
|
|||
1529 | return this.notebook_id; |
|
|||
1530 | }; |
|
|||
1531 |
|
||||
1532 | /** |
|
|||
1533 | * Getter method for this notebook's name. |
|
1523 | * Getter method for this notebook's name. | |
1534 | * |
|
1524 | * | |
1535 | * @method get_notebook_name |
|
1525 | * @method get_notebook_name | |
@@ -1757,7 +1747,7 b' var IPython = (function (IPython) {' | |||||
1757 | Notebook.prototype.notebook_rename = function (nbname) { |
|
1747 | Notebook.prototype.notebook_rename = function (nbname) { | |
1758 | var that = this; |
|
1748 | var that = this; | |
1759 | var new_name = nbname + '.ipynb' |
|
1749 | var new_name = nbname + '.ipynb' | |
1760 |
var name = {'n |
|
1750 | var name = {'name': new_name}; | |
1761 | var settings = { |
|
1751 | var settings = { | |
1762 | processData : false, |
|
1752 | processData : false, | |
1763 | cache : false, |
|
1753 | cache : false, | |
@@ -1774,7 +1764,7 b' var IPython = (function (IPython) {' | |||||
1774 |
|
1764 | |||
1775 |
|
1765 | |||
1776 | Notebook.prototype.rename_success = function (json, status, xhr) { |
|
1766 | Notebook.prototype.rename_success = function (json, status, xhr) { | |
1777 |
this.notebook_name = json. |
|
1767 | this.notebook_name = json.name | |
1778 | var notebook_path = this.notebookPath() + this.notebook_name; |
|
1768 | var notebook_path = this.notebookPath() + this.notebook_name; | |
1779 | this.session.notebook_rename(notebook_path); |
|
1769 | this.session.notebook_rename(notebook_path); | |
1780 | $([IPython.events]).trigger('notebook_renamed.Notebook'); |
|
1770 | $([IPython.events]).trigger('notebook_renamed.Notebook'); |
@@ -110,9 +110,9 b' var IPython = (function (IPython) {' | |||||
110 |
|
110 | |||
111 |
|
111 | |||
112 | Kernel.prototype._kernel_started = function (json) { |
|
112 | Kernel.prototype._kernel_started = function (json) { | |
113 |
console.log("Kernel started: ", json. |
|
113 | console.log("Kernel started: ", json.id); | |
114 | this.running = true; |
|
114 | this.running = true; | |
115 |
this.kernel_id = json. |
|
115 | this.kernel_id = json.id; | |
116 | var ws_url = json.ws_url; |
|
116 | var ws_url = json.ws_url; | |
117 | if (ws_url.match(/wss?:\/\//) == null) { |
|
117 | if (ws_url.match(/wss?:\/\//) == null) { | |
118 | // trailing 's' in https will become wss for secure web sockets |
|
118 | // trailing 's' in https will become wss for secure web sockets |
@@ -62,7 +62,7 b' var IPython = (function (IPython) {' | |||||
62 | * @method start_kernel |
|
62 | * @method start_kernel | |
63 | */ |
|
63 | */ | |
64 | Session.prototype.start_kernel = function (json) { |
|
64 | Session.prototype.start_kernel = function (json) { | |
65 |
this.session_id = json. |
|
65 | this.session_id = json.id; | |
66 | this.kernel_content = json.kernel; |
|
66 | this.kernel_content = json.kernel; | |
67 | var base_url = $('body').data('baseKernelUrl') + "api/kernels"; |
|
67 | var base_url = $('body').data('baseKernelUrl') + "api/kernels"; | |
68 | this.kernel = new IPython.Kernel(base_url, this.session_id); |
|
68 | this.kernel = new IPython.Kernel(base_url, this.session_id); |
@@ -122,13 +122,13 b' var IPython = (function (IPython) {' | |||||
122 | var len = data.length; |
|
122 | var len = data.length; | |
123 | if (len != 0) { |
|
123 | if (len != 0) { | |
124 | for (var i=0; i<len; i++) { |
|
124 | for (var i=0; i<len; i++) { | |
125 |
if (data[i][' |
|
125 | if (data[i]['path']==null) { | |
126 |
nb_path = data[i]['n |
|
126 | nb_path = data[i]['name']; | |
127 | } |
|
127 | } | |
128 | else { |
|
128 | else { | |
129 |
nb_path = data[i][' |
|
129 | nb_path = data[i]['path'] + data[i]['name']; | |
130 | } |
|
130 | } | |
131 |
this.sessions[nb_path]= data[i][' |
|
131 | this.sessions[nb_path]= data[i]['id']; | |
132 | } |
|
132 | } | |
133 | }; |
|
133 | }; | |
134 | this.load_list(); |
|
134 | this.load_list(); | |
@@ -168,7 +168,7 b' var IPython = (function (IPython) {' | |||||
168 | ) |
|
168 | ) | |
169 | } |
|
169 | } | |
170 | for (var i=0; i<len; i++) { |
|
170 | for (var i=0; i<len; i++) { | |
171 |
var name = data[i]. |
|
171 | var name = data[i].name; | |
172 | var path = this.notebookPath(); |
|
172 | var path = this.notebookPath(); | |
173 | var nbname = name.split(".")[0]; |
|
173 | var nbname = name.split(".")[0]; | |
174 | var item = this.new_notebook_item(i); |
|
174 | var item = this.new_notebook_item(i); |
General Comments 0
You need to be logged in to leave comments.
Login now