devtools/__init__.py
changeset 9340 b1e933b0e850
parent 9252 01bca75ee8bd
parent 9337 70f6b183085a
child 9402 2c48c091b6a2
child 9600 bde625698f44
equal deleted inserted replaced
9322:2dae5bf5ea68 9340:b1e933b0e850
    24 import logging
    24 import logging
    25 import shutil
    25 import shutil
    26 import pickle
    26 import pickle
    27 import glob
    27 import glob
    28 import warnings
    28 import warnings
       
    29 import tempfile
    29 from hashlib import sha1 # pylint: disable=E0611
    30 from hashlib import sha1 # pylint: disable=E0611
    30 from datetime import timedelta
    31 from datetime import timedelta
    31 from os.path import (abspath, join, exists, split, isabs, isdir)
    32 from os.path import (abspath, join, exists, split, isabs, isdir)
    32 from functools import partial
    33 from functools import partial
    33 
    34 
   326         backup_data = self._backup_database(db_id)
   327         backup_data = self._backup_database(db_id)
   327         config_path = self.config_path(db_id)
   328         config_path = self.config_path(db_id)
   328         # XXX we dump a dict of the config
   329         # XXX we dump a dict of the config
   329         # This is an experimental to help config dependant setup (like BFSS) to
   330         # This is an experimental to help config dependant setup (like BFSS) to
   330         # be propertly restored
   331         # be propertly restored
   331         with open(config_path, 'wb') as conf_file:
   332         with tempfile.NamedTemporaryFile(dir=os.path.dirname(config_path), delete=False) as conf_file:
   332             conf_file.write(pickle.dumps(dict(self.config)))
   333             conf_file.write(pickle.dumps(dict(self.config)))
       
   334         os.rename(conf_file.name, config_path)
   333         self.db_cache[self.db_cache_key(db_id)] = (backup_data, config_path)
   335         self.db_cache[self.db_cache_key(db_id)] = (backup_data, config_path)
   334 
   336 
   335     def _backup_database(self, db_id):
   337     def _backup_database(self, db_id):
   336         """Actual backup the current database.
   338         """Actual backup the current database.
   337 
   339