##// END OF EJS Templates
Fixing minor things for the Azure backed nb storage.
Brian Granger -
Show More
@@ -49,7 +49,7 b' class AzureNotebookManager(BaseNotebookManager):'
49 49 return BlobService(account_name=self.account_name, account_key=self.account_key)
50 50
51 51 def __init__(self, **kwargs):
52 super(BaseNotebookManager,self).__init__(**kwargs)
52 super(AzureNotebookManager, self).__init__(**kwargs)
53 53 self._update_service_host_base(self.blob_service_host_base)
54 54 self._create_container()
55 55
@@ -138,3 +138,6 b' class AzureNotebookManager(BaseNotebookManager):'
138 138 raise web.HTTPError(400, u'Unexpected error while deleting notebook: %s' % e)
139 139 else:
140 140 self.delete_notebook_id(notebook_id)
141
142 def log_info(self):
143 self.log.info("Serving notebooks from Azure storage: %s, %s", self.account_name, self.container)
@@ -16,13 +16,14 b' Authors:'
16 16 # Imports
17 17 #-----------------------------------------------------------------------------
18 18
19 import os
19 20 import uuid
20 21
21 22 from tornado import web
22 23
23 24 from IPython.config.configurable import LoggingConfigurable
24 25 from IPython.nbformat import current
25 from IPython.utils.traitlets import List, Dict
26 from IPython.utils.traitlets import List, Dict, Unicode, TraitError
26 27
27 28 #-----------------------------------------------------------------------------
28 29 # Classes
@@ -30,6 +31,26 b' from IPython.utils.traitlets import List, Dict'
30 31
31 32 class BaseNotebookManager(LoggingConfigurable):
32 33
34 # Todo:
35 # The notebook_dir attribute is used to mean a couple of different things:
36 # 1. Where the notebooks are stored if FileNotebookManager is used.
37 # 2. The cwd of the kernel for a project.
38 # Right now we use this attribute in a number of different places and
39 # we are going to have to disentagle all of this.
40 notebook_dir = Unicode(os.getcwdu(), config=True, help="""
41 The directory to use for notebooks.
42 """)
43 def _notebook_dir_changed(self, name, old, new):
44 """do a bit of validation of the notebook dir"""
45 if os.path.exists(new) and not os.path.isdir(new):
46 raise TraitError("notebook dir %r is not a directory" % new)
47 if not os.path.exists(new):
48 self.log.info("Creating notebook dir %s", new)
49 try:
50 os.mkdir(new)
51 except:
52 raise TraitError("Couldn't create notebook dir %r" % new)
53
33 54 allowed_formats = List([u'json',u'py'])
34 55
35 56 # Map notebook_ids to notebook names
@@ -179,3 +200,6 b' class BaseNotebookManager(LoggingConfigurable):'
179 200 nb.metadata.name = name
180 201 notebook_id = self.write_notebook_object(nb)
181 202 return notebook_id
203
204 def log_info(self):
205 self.log.info("Serving notebooks") No newline at end of file
@@ -32,20 +32,6 b' from IPython.utils.traitlets import Unicode, Dict, Bool, TraitError'
32 32 #-----------------------------------------------------------------------------
33 33
34 34 class FileNotebookManager(BaseNotebookManager):
35
36 notebook_dir = Unicode(os.getcwdu(), config=True, help="""
37 The directory to use for notebooks.
38 """)
39 def _notebook_dir_changed(self, name, old, new):
40 """do a bit of validation of the notebook dir"""
41 if os.path.exists(new) and not os.path.isdir(new):
42 raise TraitError("notebook dir %r is not a directory" % new)
43 if not os.path.exists(new):
44 self.log.info("Creating notebook dir %s", new)
45 try:
46 os.mkdir(new)
47 except:
48 raise TraitError("Couldn't create notebook dir %r" % new)
49 35
50 36 save_script = Bool(False, config=True,
51 37 help="""Automatically create a Python script when saving the notebook.
@@ -86,19 +72,19 b' class FileNotebookManager(BaseNotebookManager):'
86 72
87 73 def new_notebook_id(self, name):
88 74 """Generate a new notebook_id for a name and store its mappings."""
89 notebook_id = super(BaseNotebookManager, self).new_notebook_id(name)
75 notebook_id = super(FileNotebookManager, self).new_notebook_id(name)
90 76 self.rev_mapping[name] = notebook_id
91 77 return notebook_id
92 78
93 79 def delete_notebook_id(self, notebook_id):
94 80 """Delete a notebook's id in the mapping."""
95 super(BaseNotebookManager, self).delete_notebook_id(notebook_id)
96 81 name = self.mapping[notebook_id]
82 super(FileNotebookManager, self).delete_notebook_id(notebook_id)
97 83 del self.rev_mapping[name]
98 84
99 85 def notebook_exists(self, notebook_id):
100 86 """Does a notebook exist?"""
101 exists = super(BaseNotebookManager, self).notebook_exists(notebook_id)
87 exists = super(FileNotebookManager, self).notebook_exists(notebook_id)
102 88 if not exists:
103 89 return False
104 90 path = self.get_path_by_name(self.mapping[notebook_id])
@@ -205,3 +191,6 b' class FileNotebookManager(BaseNotebookManager):'
205 191 else:
206 192 i = i+1
207 193 return name
194
195 def log_info(self):
196 self.log.info("Serving notebooks from local directory: %s", self.notebook_manager.notebook_dir)
@@ -408,7 +408,7 b' class NotebookApp(BaseIPythonApplication):'
408 408 else:
409 409 self.log.info("Using MathJax: %s", new)
410 410
411 notebook_manager_class = DottedObjectName('IPython.frontend.html.notebook.notebookmanager.NotebookManager',
411 notebook_manager_class = DottedObjectName('IPython.frontend.html.notebook.filenbmanager.FileNotebookManager',
412 412 config=True,
413 413 help='The notebook manager class to use.')
414 414
@@ -440,7 +440,7 b' class NotebookApp(BaseIPythonApplication):'
440 440 )
441 441 kls = import_item(self.notebook_manager_class)
442 442 self.notebook_manager = kls(config=self.config, log=self.log)
443 self.log.info("Serving notebooks from %s", self.notebook_manager.notebook_dir)
443 self.notebook_manager.log_info()
444 444 self.notebook_manager.load_notebook_names()
445 445 self.cluster_manager = ClusterManager(config=self.config, log=self.log)
446 446 self.cluster_manager.update_profiles()
General Comments 0
You need to be logged in to leave comments. Login now