config: Fix json output for Python lt 2.6.

This commit is contained in:
Ali Saidi 2012-01-10 10:17:33 -06:00
parent e826d23a2e
commit 8f18898e85

View file

@ -31,7 +31,6 @@
import atexit import atexit
import os import os
import sys import sys
import json
# import the SWIG-wrapped main C++ functions # import the SWIG-wrapped main C++ functions
import internal import internal
@ -74,10 +73,14 @@ def instantiate(ckpt_dir=None):
ini_file.close() ini_file.close()
if options.json_config: if options.json_config:
json_file = file(os.path.join(options.outdir, options.json_config), 'w') try:
d = root.get_config_as_dict() import json
json.dump(d, json_file, indent=4) json_file = file(os.path.join(options.outdir, options.json_config), 'w')
json_file.close() d = root.get_config_as_dict()
json.dump(d, json_file, indent=4)
json_file.close()
except ImportError:
pass
# Initialize the global statistics # Initialize the global statistics