[1.0.1 ok] ScriptJython: exitcode not returned to commandline when using exit(n)

Bug #1224481 reported by RaiMan on 2013-09-12
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Sikuli
Critical
RaiMan

Bug Description

----- fixed with version 1.0.1 per September 12 at 5 pm gmt+1
repeat setup after this time to get the fixed version
tested on Mac, but should work on Win/Linux too
----------------------------------------------------------
I try to stop the sikuli process with error exit code by call the api sys.exit(2).

But it throws an exception

     [exec] Traceback (most recent call last):
     [exec] File "C:\Users\user\Desktop\scripts_folder\deployment.sikuli\deployment.py", line 100, in <module>
     [exec] sys.exit(2)
     [exec] Sy

RaiMan (raimund-hocke) on 2013-09-12
summary: - [1.0.1] ScriptJython: exitcode not returned to commandline when using
+ [1.0.1 ok] ScriptJython: exitcode not returned to commandline when using
exit(n)
description: updated
Changed in sikuli:
status: New → Fix Committed
importance: Undecided → Critical
assignee: nobody → RaiMan (raimund-hocke)
milestone: none → 1.1.0
markshao (mark-shao) wrote :

I have upgraded to the latest version (2013.9.13), but still could not get the right exit code

[exec] File "C:\Users\user\Desktop\scripts_folder\deployment.sikuli\deployment.py", line 112, in <module>
     [exec] exit(3)
     [exec] File "C:\sikuli\sikuli1.0.1\sikuli_download\sikuli-ide.jar\Lib\sikuli\Sikuli.py", line 232, in exit
     [exec] sys.exit(code)
     [exec] SystemExit: 3
     [exec] [info] Exit code: 1

I don't know why the sikuli throw the exception when I try to call the exit(3) method ?

RaiMan (raimund-hocke) wrote :

I do not know, where you get this strange output.

It should look like this:

running SikuliX-Script: -Xmx512M -Dfile.encoding=UTF-8 -Dsikuli.FromCommandLine
-jar ./sikuli-script.jar -r C:\Users\user\Desktop\scripts_folder\deployment.sikuli
[info] Exit code: 23

when running with
runScript.cmd -r C:\Users\user\Desktop\scripts_folder\deployment.sikuli

with a script, that has an
exit(23)

and echo %errorlevel% reported 23 on command line

When using offline setup, you should repeat the download. I just saw, that the update did not run through last night.

markshao (mark-shao) wrote :

I trigger the sikuli script by the ant task 'exec'.

There are three exit code happened according to the log

     [exec] The problems found when running the application
     [exec] Traceback (most recent call last):
     [exec] File "C:\Users\user\Desktop\scripts_folder\deployment.sikuli\deployment.py", line 112, in <module>
     [exec] exit(3)
     [exec] File "C:\sikuli\sikuli1.0.1\sikuli_download\sikuli-ide.jar\Lib\sikuli\Sikuli.py", line 232, in exit
     [exec] sys.exit(code)
     [exec] SystemExit: 3
     [exec] [info] Exit code: 1
     [echo] [Ant] The deployment process exit code is 0

1. The exit(3) function try to exit the process with the code 3
2. But the [info] Exit code :1 shows that the sikuli process is return with 1 exit code
3. The outside ant get the subprocess exit code 0

I am trying the investigate the ant code to see why the ant get the exit code = 0 , but still strange thing is that why the info shows the exit code is 1

My Environement

1. Ant 1.7.1
2. JDK 1.6.0_32
3. Sikuli is the latest version download from today

RaiMan (raimund-hocke) wrote :

pls check when running this from command line:
./runScript -d 3 -i

near beginning the output should show

[debug] SikuliX Jython Support Build: 1.0.1 12SEP2013160248

If this is not the case, you have to download again.

I will check now with your Ant snippet.

RaiMan (raimund-hocke) wrote :

this what I get with this Ant file:

<?xml version="1.0" encoding="UTF-8"?>
<project name="build-mac-app" default="all">
<target name="all">
  <exec executable="/bin/bash" dir="." resultproperty="isGood">
      <arg line="runScript -r /Users/rhocke/test"/>
  </exec>
  <echo message="[Ant] The deployment process exit code is ${isGood}"/>
</target>
</project>

--- output
all:
     [exec] running SikuliX-Script: -Xmx512M -Dfile.encoding=UTF-8 -Dsikuli.FromCommandLine
     [exec] -jar ./sikuli-script.jar -r /Users/rhocke/test
     [exec] [info] Exit code: 23
     [exec] Result: 23
     [echo] [Ant] The deployment process exit code is 23

I had to leave out the failonerror, since with a returncode >0 the build would fail and not print the message.

markshao (mark-shao) wrote :

There is no runScript cmd in my sikuli installation. So currently I am using the following cmd to execute the script from command line

./runIDE -r C:\Users\user\Desktop\scripts_folder\create_new_app.sikuli

And the start log from the ant is following

import:
     [exec] +++ running this Java
     [exec] java version "1.6.0_32"
     [exec] Java(TM) SE Runtime Environment (build 1.6.0_32-b05)
     [exec] Java HotSpot(TM) Client VM (build 20.7-b02, mixed mode, sharing)
     [exec] +++ trying to start Sikuli IDE
     [exec] +++ using: -Xms64M -Xmx512M -Dfile.encoding=UTF-8 -Dsikuli.FromCommandLine -jar C:\sikuli\sikuli1.0.1\sikuli_download\sikuli-ide.jar -r C:\Users\user\Desktop\scripts_folder\create_new_app.sikuli

Whether there is something wrong in my installation process? I install the latest sikuli from other computer . I choose the option 1 with all things . And copy the entire folder to my current lab machine (a windows 7 based computer ) . I have added the lib folder to the sys path.

I am now investigating the code of ANT exec task to see how does it start the subprocess and get the exit code

RaiMan (raimund-hocke) wrote :

Ok, this is ok (my output was from Mac ;-) and I used the script package.
But you might as well use the IDE package to run scripts from command line.

But to be sure you have the latest version, run from command line:

./runIDE -d 3 -i

and look for the version info as stated in comment #4

Matthias Bartelt (8-mail-b) wrote :

Had the same problem like markshao and the solution is very simple. runIDE on Windows has the following lines at the end of the file:

"%JAVA_HOME%\bin\java.exe" %PARMS% -jar "%SIKULIX_HOME%sikuli-ide.jar" %SIKULI_COMMAND%

GOTO FINALLY
:STOPIT
echo.+++ ended with some errors
:FINALLY
ENDLOCAL

Here the exit value of the Java call is overwritten by subsequent echo call. It can be fixed by adding the line
EXIT /B %ERRORLEVEL%
at the very end of the file.

RaiMan (raimund-hocke) on 2014-01-12
Changed in sikuli:
status: Fix Committed → Fix Released
status: Fix Released → Fix Committed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers