~jconti/oneconf/closeable-cache

« back to all changes in this revision

Viewing changes to oneconf/packagesethandler.py

  • Committer: Didier Roche
  • Date: 2012-04-05 13:18:48 UTC
  • Revision ID: didier.roche@canonical.com-20120405131848-crymougg7lfridwo
* Move saving facility to an utils module to reuse safe saving accross
  the whole application. Removed a deprecated call as well (LP: #944738)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from oneconf.hosts import Hosts, HostError
28
28
from oneconf.distributor import get_distro
29
29
from oneconf.paths import ONECONF_CACHE_DIR, PACKAGE_LIST_PREFIX
 
30
from oneconf import utils
30
31
 
31
32
class PackageSetHandler(object):
32
33
    """
58
59
                
59
60
        LOG.debug("Package list need refresh")
60
61
        self.package_list[hostid] = {'valid': True, 'package_list': newpkg_list}
61
 
        with open(os.path.join(self.hosts.get_currenthost_dir(), '%s_%s' % (PACKAGE_LIST_PREFIX, hostid)), 'w') as f:
62
 
            json.dump(self.package_list[hostid]['package_list'], f)
 
62
        utils.save_json_file_update(os.path.join(self.hosts.get_currenthost_dir(), '%s_%s' % (PACKAGE_LIST_PREFIX, hostid)),
 
63
                                    self.package_list[hostid]['package_list'])
63
64
        if self.hosts.current_host['packages_checksum'] != checksum:
64
65
            self.hosts.current_host['packages_checksum'] = checksum
65
66
            self.hosts.save_current_host()