From: Ali Saidi Date: Tue, 10 Jan 2012 16:17:33 +0000 (-0600) Subject: config: Fix json output for Python lt 2.6. X-Git-Tag: stable_2012_06_28~275^2~22^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8f18898e85ade3233502acd0dbc7cf9cd416d880;p=gem5.git config: Fix json output for Python lt 2.6. --- diff --git a/src/python/m5/simulate.py b/src/python/m5/simulate.py index 29d14f75d..38129592c 100644 --- a/src/python/m5/simulate.py +++ b/src/python/m5/simulate.py @@ -31,7 +31,6 @@ import atexit import os import sys -import json # import the SWIG-wrapped main C++ functions import internal @@ -74,10 +73,14 @@ def instantiate(ckpt_dir=None): ini_file.close() if options.json_config: - json_file = file(os.path.join(options.outdir, options.json_config), 'w') - d = root.get_config_as_dict() - json.dump(d, json_file, indent=4) - json_file.close() + try: + import json + json_file = file(os.path.join(options.outdir, options.json_config), 'w') + d = root.get_config_as_dict() + json.dump(d, json_file, indent=4) + json_file.close() + except ImportError: + pass # Initialize the global statistics