From 56cf287cf395f1cd8f135cabb8531ff37d52e122 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Wed, 30 Jul 2008 22:13:02 -0400 Subject: [PATCH] use yaml.CSafeDumper and yaml.CSafeLoader everywhere also break some long lines to fit in 80 columns svn path=/trunk/packages/sipb-xen-base/; revision=796 --- debian/changelog | 5 +++-- files/usr/sbin/invirt-getconf | 3 ++- .../python-support/sipb-xen-base/invirt/config.py | 11 ++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index d64d1be..d6dfb7a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,11 +4,12 @@ sipb-xen-base (8.12) unstable; urgency=low * add --ls and some convenience features to invirt-getconf: formatting composite nodes as yaml, allowing the root * fix bug in late-import of yaml in invirt.config - + * use yaml.CSafeDumper and yaml.CSafeLoader everywhere + [ Yang Zhang ] * added shared lock around cache-reading transaction - -- Yang Zhang Wed, 30 Jul 2008 21:56:07 -0400 + -- Greg Price Wed, 30 Jul 2008 22:11:15 -0400 sipb-xen-base (8.11) unstable; urgency=low diff --git a/files/usr/sbin/invirt-getconf b/files/usr/sbin/invirt-getconf index 1976dbc..06c0aa7 100755 --- a/files/usr/sbin/invirt-getconf +++ b/files/usr/sbin/invirt-getconf @@ -79,7 +79,8 @@ def main(argv): print conf else: import yaml - yaml.safe_dump(conf, stdout, default_flow_style=False) + yaml.dump(conf, stdout, + Dumper=yaml.CSafeDumper, default_flow_style=False) except invirt_exception, ex: print >> stderr, ex return 1 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 -- 1.7.9.5