[HowTo] use the server feature to run scripts in 2.0.4

Asked by Ben

Hello,

So, I have a python program that : start the sikuli runserver and check if a message has been send to a pub/sub module.

If a message has been send, my python program extract some data from the message and put them into a json file, it then register the json file path into a var named jread_file.

Now I'm trying to send a requests.post to the sikuli runserver to execute a script, with the jread_file var. I can't add the arg to the server run because it start before the jread_file is created. I also tried to send with the "params" arg from requests but I don't know how to receive it inside the sikuli script.

Is it possible to add args into the url that is send to the runserver ? Something like localhost:50001/groups/groupname/script/run&args ?

Question information

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

What version of SikuliX?

Revision history for this message
Ben (benvdg) said :
#2

Version 2.0.4

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

--- localhost:50001/groups/groupname/script/run&args ?

... is not what the current server implementation understands.

How to in 2.0.4:

- in one process start the server using the -s command line parameter

- in another process issue GET requests towards localhost:50001 using e.g. curl or similar features in Python

/start --- start the server
/stop --- stop the server
/startp --- start the Jython environment

/scripts/someFolder --- where the scripts can be found
/images/someFolder --- where the images are stored (optional)

/run/someScript --- run a script (someScript.sikuli in folder someFolder)

add parameters for a script run:
/run/someScript?param1=value1;param2=value2;...

instead of ; you might use &

in the script you get sys.argv as
[ ;"--param1=value1";"--param2=value2";...]

more features are not available in the current implementation.

Revision history for this message
Ben (benvdg) said :
#4

Hey, thanks for the answer !

So I managed to fix my problem.

I'm running sikuli version 2.1.0, not 2.0.4, my bad.

So I did it like this : http://localhost:50001/groups/something/scripts/something/run?args=something and it seems to work !

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

... so at least I have written down, how to use the server feature in 2.0.4 ;-)

Be aware: 2.1.0 is currently paused, might have bugs and is not supported until 2.0.5 is out somewhen the next weeks.

Revision history for this message
Ben (benvdg) said :
#6

Thanks RaiMan, that solved my question.