##// END OF EJS Templates
Merge pull request #5357 from minrk/smb-fails...
Thomas Kluyver -
r15872:2a9ed0e9 merge
parent child Browse files
Show More
@@ -85,7 +85,18 b' class FileNotebookManager(NotebookManager):'
85 os.mkdir(new)
85 os.mkdir(new)
86 except:
86 except:
87 raise TraitError("Couldn't create checkpoint dir %r" % new)
87 raise TraitError("Couldn't create checkpoint dir %r" % new)
88
88
89 def _copy(self, src, dest):
90 """copy src to dest
91
92 like shutil.copy2, but log errors in copystat
93 """
94 shutil.copyfile(src, dest)
95 try:
96 shutil.copystat(src, dest)
97 except OSError as e:
98 self.log.debug("copystat on %s failed", dest, exc_info=True)
99
89 def get_notebook_names(self, path=''):
100 def get_notebook_names(self, path=''):
90 """List all notebook names in the notebook dir and path."""
101 """List all notebook names in the notebook dir and path."""
91 path = path.strip('/')
102 path = path.strip('/')
@@ -432,7 +443,7 b' class FileNotebookManager(NotebookManager):'
432 self.log.debug("creating checkpoint for notebook %s", name)
443 self.log.debug("creating checkpoint for notebook %s", name)
433 if not os.path.exists(self.checkpoint_dir):
444 if not os.path.exists(self.checkpoint_dir):
434 os.mkdir(self.checkpoint_dir)
445 os.mkdir(self.checkpoint_dir)
435 shutil.copy2(nb_path, cp_path)
446 self._copy(nb_path, cp_path)
436
447
437 # return the checkpoint info
448 # return the checkpoint info
438 return self.get_checkpoint_model(checkpoint_id, name, path)
449 return self.get_checkpoint_model(checkpoint_id, name, path)
@@ -465,7 +476,7 b' class FileNotebookManager(NotebookManager):'
465 # ensure notebook is readable (never restore from an unreadable notebook)
476 # ensure notebook is readable (never restore from an unreadable notebook)
466 with io.open(cp_path, 'r', encoding='utf-8') as f:
477 with io.open(cp_path, 'r', encoding='utf-8') as f:
467 current.read(f, u'json')
478 current.read(f, u'json')
468 shutil.copy2(cp_path, nb_path)
479 self._copy(cp_path, nb_path)
469 self.log.debug("copying %s -> %s", cp_path, nb_path)
480 self.log.debug("copying %s -> %s", cp_path, nb_path)
470
481
471 def delete_checkpoint(self, checkpoint_id, name, path=''):
482 def delete_checkpoint(self, checkpoint_id, name, path=''):
General Comments 0
You need to be logged in to leave comments. Login now