Sikuli interpreter shell within IDE, etc.?

Asked by daluu

I don't think this feature yet exists.:

One can build Sikuli script using the IDE or other IDE or write from scratch. Can also call Sikuli via Python (via Jython) and Java APIs.

I haven't tried it but guess workaround for now is to start an interactive Jython interpreter shell session then import Sikuli library and can then make Sikuli API calls on demand via the shell (no coding a script, etc.)

What would be nice to have as part of Sikuli IDE, or perhaps the Sikuli Jar, is to have an interpreter session option, where it will load an interactive Jython interpreter shell preloaded with Sikuli library and the user can then make calls to the Sikuli API w/o having to write and run a script. And additionally, perhaps the interpreter session can also optionally record the session actions and translate into Sikuli script.

I would think in terms of efficiency, the interpreter should take image arguments as predefined files stored at some specified location rather than the GUI IDE take and crop screenshot on demand. When convert to Sikuli script from interpreter session, it can either keep that image path reference, or display (in IDE) the image that path references.

The interpreter feature would be for power users/scripters and programmers while the regular IDE usage would be for more novice users.

Perhaps an enhancement request for Sikuli IDE, or a third party project (I'd do the R&D when I have time).

Just thought I'd bring that up. Your thoughts?

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

The easiest way, to get this up and running, is using XML-RPC. This is possible with a few lines of code and has the option to run it over the net. The server acts as an always-open interpreter for Sikuli actions. (the basics: see faq 1331)

As with many things around Sikuli, the challenge is: how to handle images. On same machine, it is rather simple. But over the net?

Revision history for this message
daluu (cuuld) said :
#2

Hmm...didn't think of XML-RPC, good suggestion.

But it probably won't feel like an interpreter shell that way, unless you build a front end web UI that mimics an interpreter.

Using the interpreter over XML-RPC will feel more like making a set of individual Sikuli API calls over XML-RPC. Technically, that's not much different from using interpreter locally, except that the UI feels different because there is no XML-RPC client that "feels" like an interpreter shell session.

As for the handle image problem, if you're calling over network, I would think you'd often already have the images already defined and saved to common repository (the XML-RPC server machine, or a common file share), otherwise, you'd build a mechanism to push the images from local machine to the remote XML-RPC server machine.

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

good answer ;-)

Since I like the idea of some how issuing Sikuli "commands", I will check the next weeks with the different XML-RPC solutions, how this may go from command line.

Revision history for this message
daluu (cuuld) said :
#4

Actual on looking further, the solution is kind of available, just not integrated with the IDE.

The closest thing would be this article

https://answers.launchpad.net/sikuli/+question/141302

but rather than run sikuli scripts, we invoke Jython/Python Sikuli API commands via Jython interpreter session (that we manually start up).

So the initial idea of this thread is simply to incorporate within the IDE as separate "plugin" type feature, the launching of said Jython interpreter w/ the classpath and jythonpath all taken cared of along with auto importing the Sikuli library so the user doesn't have to issue the following command in the Jython interpreter shell manually:

from sikuli.Sikuli import *

be nice for that to be called already and user can just begin invoking the Jython/Python Sikuli APIs from the shell that's within the IDE.

Revision history for this message
daluu (cuuld) said :
#5

An example of what I'm thinking of is something like the IDLE Python GUI Windowed version of the interpreter shell but incorporated within the Sikuli IDE as another view/tab.

And example of what one can do with it is like below what I've done for Jython shell manually:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Scripts>cd c:\jython2.5.2

C:\jython2.5.2>cfgSikuli.bat

C:\jython2.5.2>set CLASSPATH=C:\jython2.5.2\sikuli-script.jar

C:\jython2.5.2>set JYTHONPATH=C:\jython2.5.2\Lib;c:\jython2.5.2\sikuli-script.ja
r\Lib

C:\jython2.5.2>bin\jython.bat
Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_27
Type "help", "copyright", "credits" or "license" for more information.
>>> from sikuli.Sikuli import *
[info] Sikuli vision engine loaded.
[info] Windows utilities loaded.
[info] VDictProxy loaded.
>>> exists(r'C:\Scripts\bin\img\aiWelcome.png')
Match[396,542 658x127] score=0.92, target=center
>>> exists(r'C:\Scripts\bin\img\aiWelcome.png')
>>> exists(r'C:\Scripts\bin\img\aiWelcome.png',1)
>>> exists(r'C:\Scripts\bin\img\aiWelcome.png',1)
Match[396,542 658x127] score=0.92, target=center
>>>

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

this is already available for usage on command line:

java -jar path-to-sikuli-script.jar -i

which starts an interactive Jython session with Sikuli already imported (Jython 2.5.2 with rc3).

Revision history for this message
daluu (cuuld) said :
#7

Thanks RaiMan, didn't know that. But that would still be nice to integrate with IDE as well for more advanced users. But the current option will do for now.

Revision history for this message
Brian Parma (bj0) said :
#8

I was just wondering how to do this, I had to add the following to the path:
c:\bin\sikuli-ide\libs;%programfiles%\java\jre6\bin

then
java -jar ...\sikuli-script.jar -i
worked like a charm.

I wrapped it in a .bat file, and the following gives nice tab completion:
(from http://www.jython.org/docs/library/rlcompleter.html)

import readline
import rlcompleter

readline.parse_and_bind(“tab: complete”)

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

--- and the following gives nice tab completion
good finding.

But be careful:
It lists all functions from Sikuli's Python API AND all public functions from the Sikuli's Java API, that cannot all be used on the Python level (you do not see that with rlcompleter).

Can you help with this problem?

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

To post a message you must log in.