main: separate out interact() so it can be used by other functions
authorNathan Binkert <nate@binkert.org>
Wed, 13 Apr 2011 16:32:18 +0000 (09:32 -0700)
committerNathan Binkert <nate@binkert.org>
Wed, 13 Apr 2011 16:32:18 +0000 (09:32 -0700)
src/python/m5/main.py

index dc8aab924c9ebf0a94c64f401d5b00c7d7447c96..f932ec63a88653c5ef7564696315d0e1a7f1dc6d 100644 (file)
@@ -128,6 +128,16 @@ if options_file:
 
 arguments = options.parse_args()
 
+def interact(scope):
+    banner = "M5 Interactive Console"
+    sys.argv = []
+    try:
+        from IPython.Shell import IPShellEmbed
+        ipshell = IPShellEmbed(banner=banner,user_ns=scope)
+        ipshell()
+    except ImportError:
+        code.InteractiveConsole(scope).interact(banner)
+
 def main():
     import core
     import debug
@@ -349,13 +359,7 @@ def main():
 
     # once the script is done
     if options.interactive:
-        banner = "M5 Interactive Console"
-        try:
-            from IPython.Shell import IPShellEmbed
-            ipshell = IPShellEmbed(banner=banner,user_ns=scope)
-            ipshell()
-        except ImportError:
-            code.InteractiveConsole(scope).interact(banner)
+        interact(scope)
 
 if __name__ == '__main__':
     from pprint import pprint