@@ -176,11 +176,11 @@ def write_notebook_object(self, nb, notebook_id=None):
176176
177177 path = self .get_path_by_name (new_name )
178178 try :
179- self .log .debug ("Writing notebook %s" , path )
179+ self .log .debug ("Autosaving notebook %s" , path )
180180 with open (path ,'w' ) as f :
181181 current .write (nb , f , u'json' )
182182 except Exception as e :
183- raise web .HTTPError (400 , u'Unexpected error while saving notebook: %s' % e )
183+ raise web .HTTPError (400 , u'Unexpected error while autosaving notebook: %s' % e )
184184
185185 # save .py script as well
186186 if self .save_script :
@@ -202,41 +202,44 @@ def write_notebook_object(self, nb, notebook_id=None):
202202 # remove renamed original, if it exists
203203 old_path = self .get_path_by_name (old_name )
204204 if os .path .isfile (old_path ):
205- self .log .debug ("unlinking %s" , old_path )
205+ self .log .debug ("unlinking notebook %s" , old_path )
206206 os .unlink (old_path )
207207
208208 # cleanup old script, if it exists
209209 if self .save_script :
210210 old_pypath = os .path .splitext (old_path )[0 ] + '.py'
211211 if os .path .isfile (old_pypath ):
212- self .log .debug ("unlinking %s" , old_pypath )
212+ self .log .debug ("unlinking script %s" , old_pypath )
213213 os .unlink (old_pypath )
214214
215215 # rename checkpoints to follow file
216- self .log .debug ("%s" , old_checkpoints )
217216 for cp in old_checkpoints :
218- old_cp_path = self .get_checkpoint_path_by_name (old_name , cp )
219- new_cp_path = self .get_checkpoint_path_by_name (new_name , cp )
217+ checkpoint_id = cp ['checkpoint_id' ]
218+ old_cp_path = self .get_checkpoint_path_by_name (old_name , checkpoint_id )
219+ new_cp_path = self .get_checkpoint_path_by_name (new_name , checkpoint_id )
220220 if os .path .isfile (old_cp_path ):
221- self .log .debug ("renaming %s -> %s" , old_cp_path , new_cp_path )
221+ self .log .debug ("renaming checkpoint %s -> %s" , old_cp_path , new_cp_path )
222222 os .rename (old_cp_path , new_cp_path )
223223
224224 return notebook_id
225225
226226 def delete_notebook (self , notebook_id ):
227227 """Delete notebook by notebook_id."""
228- path = self .get_path (notebook_id )
229- if not os .path .isfile (path ):
228+ nb_path = self .get_path (notebook_id )
229+ if not os .path .isfile (nb_path ):
230230 raise web .HTTPError (404 , u'Notebook does not exist: %s' % notebook_id )
231- self .log .debug ("unlinking %s" , path )
232- os .unlink (path )
233231
234232 # clear checkpoints
235- for checkpoint_id in self .list_checkpoints (notebook_id ):
233+ for checkpoint in self .list_checkpoints (notebook_id ):
234+ checkpoint_id = checkpoint ['checkpoint_id' ]
236235 path = self .get_checkpoint_path (notebook_id , checkpoint_id )
236+ self .log .debug (path )
237237 if os .path .isfile (path ):
238- self .log .debug ("unlinking %s" , path )
238+ self .log .debug ("unlinking checkpoint %s" , path )
239239 os .unlink (path )
240+
241+ self .log .debug ("unlinking notebook %s" , nb_path )
242+ os .unlink (nb_path )
240243 self .delete_notebook_id (notebook_id )
241244
242245 def increment_filename (self , basename ):
0 commit comments