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