|
From: <Ar...@us...> - 2009-09-22 14:11:59
|
Revision: 4492
http://phex.svn.sourceforge.net/phex/?rev=4492&view=rev
Author: ArneBab
Date: 2009-09-22 14:11:29 +0000 (Tue, 22 Sep 2009)
Log Message:
-----------
Jython Interpreter: Now the quit command works both in headless and in GUI mode.
Modified Paths:
--------------
phex/trunk/src/main/java/phex/utils/JythonInterpreter.java
Modified: phex/trunk/src/main/java/phex/utils/JythonInterpreter.java
===================================================================
--- phex/trunk/src/main/java/phex/utils/JythonInterpreter.java 2009-09-22 09:57:11 UTC (rev 4491)
+++ phex/trunk/src/main/java/phex/utils/JythonInterpreter.java 2009-09-22 14:11:29 UTC (rev 4492)
@@ -27,16 +27,28 @@
// System.out.println("Hello");
// First add some info as __doc__ string
interp.push("__doc__ = 'The Phex Python interpreter. To get a list of available commands, please call help().'");
+ // Imports
+ interp.push("from phex.servent import Servent");
+ interp.push("from phex.net.server import OIOServer");
+ interp.push("from phex.gui.common import GUIRegistry");
+ interp.push("from java.awt import GraphicsEnvironment");
+ interp.push("from java.lang import System");
// offer a servent and a server object for controlling Phex
- interp.push("from phex.servent import Servent");
interp.push("servent = Servent.getInstance()");
- interp.push("from phex.net.server import OIOServer");
interp.push("server = OIOServer( servent )");
- interp.push("from phex.gui.common import GUIRegistry");
- // A quit action. BUG: Only works in GUI mode. TODO: Create a function which also works in headless mode.
- interp.push("quit = GUIRegistry.getInstance().getGlobalAction( GUIRegistry.EXIT_PHEX_ACTION).shutdown");
+ // A help action
interp.push("help = dir");
+ // A quit action.
+ // interp.push("quit = GUIRegistry.getInstance().getGlobalAction( GUIRegistry.EXIT_PHEX_ACTION).shutdown");
// interp.push("quit = servent.stop");
+ // interp.push("System.exit( True )");
+ interp.push("def quit():");
+ interp.push(" if not GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadless():");
+ interp.push(" GUIRegistry.getInstance().getGlobalAction( GUIRegistry.EXIT_PHEX_ACTION).shutdown()");
+ interp.push(" else:");
+ interp.push(" servent.stop()");
+ interp.push(" System.exit( True )");
+ interp.push("");
// Now start the interactive console
interp.interact("Hello from console. Call help() for available commands.", null);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|