devtools/__init__.py
branchstable
changeset 9337 70f6b183085a
parent 9235 3eb8d65824f5
child 9340 b1e933b0e850
child 9564 e2d5b0712974
equal deleted inserted replaced
9336:722635e530a0 9337:70f6b183085a
    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