This is an automated email from the git hooks/post-receive script. pini pushed a commit to tag upstream/1.1.0_beta1 in repository sikuli.
commit 59e422a2eac1aaf4e0d52078f1754af1cfdc8473 Author: Raimund Hocke <[email protected]> Date: Mon Feb 24 17:53:18 2014 +0100 revised/fixed the stout redirect to IDE message area --- .../java/org/sikuli/ide/EditorConsolePane.java | 42 ++++++++++++---------- .../org/sikuli/scriptrunner/JRubyScriptRunner.java | 13 ++++--- .../sikuli/scriptrunner/JythonScriptRunner.java | 7 ++-- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/IDE/src/main/java/org/sikuli/ide/EditorConsolePane.java b/IDE/src/main/java/org/sikuli/ide/EditorConsolePane.java index 3d53234..a6ea9cc 100755 --- a/IDE/src/main/java/org/sikuli/ide/EditorConsolePane.java +++ b/IDE/src/main/java/org/sikuli/ide/EditorConsolePane.java @@ -26,6 +26,7 @@ import javax.swing.*; import javax.swing.text.*; import javax.swing.text.html.*; import org.sikuli.basics.Debug; +import org.sikuli.basics.IScriptRunner; import org.sikuli.basics.SikuliX; public class EditorConsolePane extends JPanel implements Runnable { @@ -39,11 +40,11 @@ public class EditorConsolePane extends JPanel implements Runnable { ENABLE_IO_REDIRECT = false; } } - final static int NUM_PIPES = 2; + private int NUM_PIPES; private JTextPane textArea; - private Thread[] reader = new Thread[NUM_PIPES]; + private Thread[] reader; private boolean quit; - private final PipedInputStream[] pin = new PipedInputStream[NUM_PIPES]; + private PipedInputStream[] pin; Thread errorThrower; // just for testing (Throws an Exception at this Console public EditorConsolePane() { @@ -59,26 +60,31 @@ public class EditorConsolePane extends JPanel implements Runnable { add(new JScrollPane(textArea), BorderLayout.CENTER); if (ENABLE_IO_REDIRECT) { + int npipes = 2; + NUM_PIPES = npipes * SikuliIDE.scriptRunner.size(); + pin = new PipedInputStream[NUM_PIPES]; + reader = new Thread[NUM_PIPES]; for (int i = 0; i < NUM_PIPES; i++) { pin[i] = new PipedInputStream(); } - if (SikuliX.getScriptRunner("jython", null, null).doSomethingSpecial("redirect", pin)) { - Debug.log(2, "EditorConsolePane: init: stdout/stderr redirected to console"); - quit = false; // signals the Threads that they should exit - - // Starting two seperate threads to read from the PipedInputStreams - for (int i = 0; i < NUM_PIPES; i++) { - reader[i] = new Thread(this); - reader[i].setDaemon(true); - reader[i].start(); - } - } else { - Debug.error("EditorConsolePane: init: Redirect to console not posssible"); - } - + int irunner = 0; + for (IScriptRunner srunner : SikuliIDE.scriptRunner.values()) { + if (srunner.doSomethingSpecial("redirect", pin)) { + Debug.log(2, "EditorConsolePane: stdout/stderr redirected to console" + + " for " + srunner.getName()); + quit = false; // signals the Threads that they should exit + + // Starting two seperate threads to read from the PipedInputStreams + for (int i = irunner * npipes; i < irunner * npipes + npipes; i++) { + reader[i] = new Thread(this); + reader[i].setDaemon(true); + reader[i].start(); + } + irunner++; + } + } } - } private void appendMsg(String msg) { diff --git a/JRuby/src/main/java/org/sikuli/scriptrunner/JRubyScriptRunner.java b/JRuby/src/main/java/org/sikuli/scriptrunner/JRubyScriptRunner.java index e854494..8138554 100755 --- a/JRuby/src/main/java/org/sikuli/scriptrunner/JRubyScriptRunner.java +++ b/JRuby/src/main/java/org/sikuli/scriptrunner/JRubyScriptRunner.java @@ -178,8 +178,7 @@ public class JRubyScriptRunner implements IScriptRunner { @Override public boolean doSomethingSpecial(String action, Object[] args) { if ("redirect".equals(action)) { - doRedirect((PipedInputStream[]) args); - return true; + return doRedirect((PipedInputStream[]) args); } else { return false; } @@ -319,11 +318,11 @@ public class JRubyScriptRunner implements IScriptRunner { errorLine = line.getLineNumber(); errorClass = PY_RUNTIME; this.errorText = thr.getMessage(); - - Pattern sikType = + + Pattern sikType = Pattern.compile( "(?<=org.sikuli.script.)(.*)(?=:)"); - Matcher mSikType = + Matcher mSikType = sikType.matcher(this.errorText); if (mSikType.find()) { @@ -479,7 +478,7 @@ public class JRubyScriptRunner implements IScriptRunner { System.setOut(ps); interpreter.setOutput(ps); } catch (Exception e) { - log(-1, "doRedirect: Couldn't redirect STDOUT\n%s", e.getMessage()); + log(-1, "%s: redirect STDOUT: %s", getName(), e.getMessage()); return false; } try { @@ -488,7 +487,7 @@ public class JRubyScriptRunner implements IScriptRunner { System.setErr(ps); interpreter.setError(ps); } catch (Exception e) { - log(-1, "doRedirect: Couldn't redirect STDERR\n%s", e.getMessage()); + log(-1, "%s: redirect STDERR: %s", getName(), e.getMessage()); return false; } return true; diff --git a/Jython/src/main/java/org/sikuli/scriptrunner/JythonScriptRunner.java b/Jython/src/main/java/org/sikuli/scriptrunner/JythonScriptRunner.java index 978e154..7f8b222 100644 --- a/Jython/src/main/java/org/sikuli/scriptrunner/JythonScriptRunner.java +++ b/Jython/src/main/java/org/sikuli/scriptrunner/JythonScriptRunner.java @@ -499,8 +499,7 @@ public class JythonScriptRunner implements IScriptRunner { @Override public boolean doSomethingSpecial(String action, Object[] args) { if ("redirect".equals(action)) { - doRedirect((PipedInputStream[]) args); - return true; + return doRedirect((PipedInputStream[]) args); } else if ("convertSrcToHtml".equals(action)) { convertSrcToHtml((String) args[0]); return true; @@ -606,7 +605,7 @@ public class JythonScriptRunner implements IScriptRunner { System.setOut(ps); py.setOut(ps); } catch (Exception e) { - log(-1, "doRedirect: Couldn't redirect STDOUT\n%s", e.getMessage()); + log(-1, "%s: redirect STDOUT: %s", getName(), e.getMessage()); return false; } try { @@ -615,7 +614,7 @@ public class JythonScriptRunner implements IScriptRunner { System.setErr(ps); py.setErr(ps); } catch (Exception e) { - log(-1, "doRedirect: Couldn't redirect STDERR\n%s", e.getMessage()); + log(-1, "%s: redirect STDERR: %s", getName(), e.getMessage()); return false; } return true; -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/sikuli.git _______________________________________________ pkg-java-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

