How to run a series of scripts to avoid startup splash screen with each script

Asked by Kevin

I'd like to use Sikuli to drive an automated demo. Is it possible to get rid of the splash screen for each script that I launch from the command line? The bright yellow banner detracts from the whole experience.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Sorry, currently no way. But I will change that in 1.1.0-Beta3+

If you run a series of scripts from command line, you might instead use a main script and put all scripts in the same folder.

# main script:
import script1
import script2
...

each script scriptN.sikuli now needs
from sikuli import *
at the beginning of the script.

BE AWARE:
this only works when running from command line and in the first run in the IDE after startup.

The trick:
at Python import, the script content is run once to get the defined names, but never again.
hence an imported script will do what it would do, when run from command line.

caveat: different images in the scripts must all have different names, since images are searched in all imported scripts in the sequence of import - first wins

Revision history for this message
Kevin (kwilson4813) said :
#2

Thanks for the quick turn around. A single main script would not work because I need to be able to run the scripts out of order. Looking forward to seeing the fix in the next update.

Revision history for this message
Shengyuan Gu (gushengyuan2002) said :
#3

Hi all,
My approach to hide the splash screen is using jython to run the sikuli scripts without sikuli ide.

I wrapped a jython startup script name jython.bat on windows7 using the jython in sikulix.jar:
@echo off
chcp 437
java -Xmx512m -Xss1152k -cp D:/SikuliX110b2/sikulix.jar org.python.util.jython %*

Then I can use jython to run the sikuli script without splash screen:
jython login.sikuli/login.py

also, I should insert some workaround jython code in my sikuli script:
# configure execution environment for both SikuliX and Jython
# caution:!!!
# 1, __file__ is not supported in SikuliX script, so use sys.argv[0] instead
# 2, these code cannot be move to a common module
file = sys.argv[0]
file = file.replace('\\', '/')
fullpath = os.path.realpath(file)
fullpath = fullpath.replace('\\', '/')

# jython: xxxx.sikuli/demo.py
if file.endswith(".py") and not "robot" in file:
    # set bundle path
    pathname = os.path.dirname(fullpath)
    setBundlePath(pathname)
    print(getBundlePath())
    resetImagePath()

Hope this will be helpful.

Revision history for this message
RaiMan (raimund-hocke) said :
#4

@ comment #2:
… then use a user parameter, that selects the scripts to be run:

*** very simple solution: each script corresponds to a number
toRun = sys.argv[1] # contains e.g. 137
if "1" in toRun: import scriptxyz # the script that corresponds to #1
if "2" in toRun: import scriptxyz # the script that corresponds to #2
….

*** if the given sequence has to be obeyed:
toRun = sys.argv[1] # contains e.g. 1,3,7 in this case
for actual in toRun.split(","):
    if "1" in actual: import scriptxyz # the script that corresponds to #1
    if "2" actual: import scriptxyz # the script that corresponds to #2

*** or you might give a list of script names:
toRun = sys.argv[1] # contains e.g. script1,script2,script3 in this case
for actual in toRun.split(","):
    exec("import " + actual)

Can you help with this problem?

Provide an answer of your own, or ask Kevin for more information if necessary.

To post a message you must log in.