X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-base.git/blobdiff_plain/06a2334e33b03e38bd880411b4ef82183462d6f1..refs/tags/sipb-xen-base/8.12:/files/usr/share/python-support/sipb-xen-base/invirt/config.py diff --git a/files/usr/share/python-support/sipb-xen-base/invirt/config.py b/files/usr/share/python-support/sipb-xen-base/invirt/config.py index 29f7ce5..4a27cea 100644 --- a/files/usr/share/python-support/sipb-xen-base/invirt/config.py +++ b/files/usr/share/python-support/sipb-xen-base/invirt/config.py @@ -34,7 +34,8 @@ def load(src_path = default_src_path, # lock with other concurrent reads). @with_lock_file(lock_file, False) def read_cache(): - try: ns.cfg = with_closing(file(cache_path))(lambda f: json.read(f.read())) + try: ns.cfg = with_closing(file(cache_path)) ( + lambda f: json.read(f.read())) except: ns.do_refresh = True if ns.do_refresh: @@ -44,10 +45,10 @@ def load(src_path = default_src_path, @with_lock_file(lock_file) def refresh_cache(): import yaml - try: default_loader = yaml.CSafeLoader - except: default_loader = yaml.SafeLoader - ns.cfg = with_closing(file(src_path))(lambda f: yaml.load(f, default_loader)) - try: with_closing(file(cache_path, 'w'))(lambda f: f.write(json.write(ns.cfg))) + ns.cfg = with_closing(file(src_path)) ( + lambda f: yaml.load(f, yaml.CSafeLoader)) + try: with_closing(file(cache_path, 'w')) ( + lambda f: f.write(json.write(ns.cfg))) except: pass # silent failure return ns.cfg