config: Fix json output for Python lt 2.6.
authorAli Saidi <Ali.Saidi@ARM.com>
Tue, 10 Jan 2012 16:17:33 +0000 (10:17 -0600)
committerAli Saidi <Ali.Saidi@ARM.com>
Tue, 10 Jan 2012 16:17:33 +0000 (10:17 -0600)
src/python/m5/simulate.py

index 29d14f75deecfd8b68d4cda8fbb6d66996de0852..38129592c0c05f5dad37f7d21edae41499ae3ec4 100644 (file)
@@ -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