From: <otm...@us...> - 2009-05-28 14:03:17
|
Revision: 6416 http://jython.svn.sourceforge.net/jython/?rev=6416&view=rev Author: otmarhumbel Date: 2009-05-28 13:37:28 +0000 (Thu, 28 May 2009) Log Message: ----------- provide jython.jar as sys.executable (if not otherwise specified), and let subprocesses run it using java -jar Modified Paths: -------------- trunk/installer/src/java/org/python/util/install/driver/NormalVerifier.java trunk/jython/Lib/subprocess.py trunk/jython/src/org/python/core/PySystemState.java Modified: trunk/installer/src/java/org/python/util/install/driver/NormalVerifier.java =================================================================== --- trunk/installer/src/java/org/python/util/install/driver/NormalVerifier.java 2009-05-28 06:12:41 UTC (rev 6415) +++ trunk/installer/src/java/org/python/util/install/driver/NormalVerifier.java 2009-05-28 13:37:28 UTC (rev 6416) @@ -23,7 +23,8 @@ private static final String BAT_EXTENSION = ".bat"; - private static final String JYTHON_UP = "jython up and running!"; + //TODO:Oti re-add an exclamation mark as soon subprocess/jython.bat can handle it + private static final String JYTHON_UP = "jython up and running"; private static final String JYTHON = "jython"; @@ -269,6 +270,23 @@ b.append("print '"); b.append(JYTHON_UP); b.append("'\n"); + b.append("# test subprocess if present\n"); + b.append("try:\n"); + b.append(" import subprocess\n"); + b.append(" proceed=True\n"); + b.append("except:\n"); + b.append(" proceed=False\n"); + b.append("if proceed:\n"); + b.append(" print '"); + b.append(VERIFYING); + b.append(" subprocess"); + b.append("'\n"); + b.append(" exitCode = subprocess.call([sys.executable, '-c', 'print "); + b.append('"'); + b.append(JYTHON_UP); + b.append('"'); + b.append("'])\n"); + b.append(" assert exitCode==0\n"); return b.toString(); } Modified: trunk/jython/Lib/subprocess.py =================================================================== --- trunk/jython/Lib/subprocess.py 2009-05-28 06:12:41 UTC (rev 6415) +++ trunk/jython/Lib/subprocess.py 2009-05-28 13:37:28 UTC (rev 6416) @@ -1236,6 +1236,9 @@ raise TypeError('args must contain only strings') args = _escape_args(args) + if len(args) > 0 and '.jar' == args[0][-4:] and executable is None: + args = ['java', '-jar'] + args + if shell: args = _shell_command + args Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2009-05-28 06:12:41 UTC (rev 6415) +++ trunk/jython/src/org/python/core/PySystemState.java 2009-05-28 13:37:28 UTC (rev 6416) @@ -856,7 +856,7 @@ // Initialize the path (and add system defaults) defaultPath = initPath(registry, standalone, jarFileName); defaultArgv = initArgv(argv); - defaultExecutable = initExecutable(registry); + defaultExecutable = initExecutable(registry, jarFileName); // Set up the known Java packages initPackages(registry); // Finish up standard Python initialization... @@ -959,16 +959,23 @@ } /** - * Determine the default sys.executable value from the - * registry. Returns Py.None is no executable can be found. - * - * @param props a Properties registry + * Determine the default sys.executable value from the registry. Returns Py.None is no + * executable can be found. + * + * @param props + * a Properties registry + * @param jarFileName + * used as executable if python.executable not otherwise specified * @return a PyObject path string or Py.None */ - private static PyObject initExecutable(Properties props) { + private static PyObject initExecutable(Properties props, String jarFileName) { String executable = props.getProperty("python.executable"); if (executable == null) { - return Py.None; + if (jarFileName != null) { + executable = jarFileName; + } else { + return Py.None; + } } File executableFile = new File(executable); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |