importing .sikuli files in eclipse

Asked by vidisha aggarwal

i am trying to run .sikuli files in eclipse and followed these steps:
-- in Eclipse make a new PyDev project
- name it
- uncheck 'Project contents' use defaults
- browse for the directory .sikuli, that you want and confirm
- select Jython as Project type
- uncheck 'create default .....'
- press finish.

-- select in menu Run: Run configurations ...
- right click on JythonRun and select new
- in Project select your project and
- in Main Module select the .py file
- at top give it a name (e.g. same as project name)
- press Close
and also gone through "sikuli.org/docx/faq/040-other-ide.html"
but i am litle confused where to add this statement "from sikuli.sikuli.import*"

and please guide me what to do next? how to run this project..

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

--- from sikuli.sikuli.import*
is now
from sikuli import *

(we have to adapt the docs ;-)

and has to be one of the first statements in your .py files (if used and before any Sikuli features are used)

--- how to run this project..
just do it ;-)

Take care for the images (as mentioned in sikuli.org/docx/faq/040-other-ide.html"

Revision history for this message
vidisha aggarwal (vidisha23-aggarwal) said :
#2

Thanks Raiman for your help...
but i hv a confusion regarding .py files...
there are two .py files in my project. one is that which i have created using Sikuli Ide. and dat i hv imported in the project while creating it.
the other one is in src folder.
now i am confused where to add this line "from sikuli import *"
and also i need to write any python script. If yes then just provide me a sample for that.

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

If you use the Jython interpreter to run your stuff (either from command line or from within Eclipse) EVERY .py file, that uses Sikuli features, has to have this import statement.

BTW: this is standard with Python/Jython for any stuff, that is not part of the language, but implemented as modules/classes/methods.

That you do not need it in the main script, when using Sikuli to run your script is only a convenience feature (the import is handled internally).

Revision history for this message
vidisha aggarwal (vidisha23-aggarwal) said :
#4

Thanks Raiman..
I have run my script using Sikuli and getting the following error:

Line 2, in file C:\Users\VIDISH~1.AGG\AppData\Local\Temp\sikuli-tmp3644869208293073873.py

 at org.sikuli.script.Region.handleFindFailed(Region.java:420)
at org.sikuli.script.Region.wait(Region.java:511)
at org.python.proxies.sikuli.Region$Region$0.super__wait(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)

org.sikuli.script.FindFailed: FindFailed: can not find 1347427581710.png on the screen.
 Line 2, in file C:\Users\VIDISH~1.AGG\AppData\Local\Temp\sikuli-tmp3644869208293073873.py

please help me with it..

this was a simple script just to open a google chrome.. but if we have to do complex scripting like to use the loops and all then how to and where to write the script and how to use the scripts in between our wrtten scripts.. please explain me by giving an example that how to perform google search and each time for a different topic.

Revision history for this message
vidisha aggarwal (vidisha23-aggarwal) said :
#5

when i am running the same project through Eclipse. I am getting this error:
-------------------------------------------------------------------------------
pydev debugger: CRITICAL WARNING: This version of python seems to be incorrectly compiled (internal generated filenames are not absolute)
pydev debugger: The debugger may still function, but it will work slower and may miss breakpoints.
pydev debugger: Related bug: http://bugs.python.org/issue1666807
-------------------------------------------------------------------------------
Finding files... done.
Traceback (most recent call last):
  File "D:\eclipse\plugins\org.python.pydev_2.6.0.2012062818\pysrc\pydev_runfiles.py", line 432, in _PydevTestRunner__get_module_from_str
    mod = __import__(modname)
  File "C:\Users\vidisha.aggarwal\Desktop\sample.sikuli\sample.py", line 1
     from sikuli import * ;
    ^
 SyntaxError: mismatched input ' ' expecting EOF
ERROR: Module: sample could not be imported (file: C:\Users\vidisha.aggarwal\Desktop\sample.sikuli\sample.py).
Importing test modules ... done.

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
Please explain why?

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

Sorry, I cannot help you this way, because it would mean, that I had to write your scripts.

-- comment #4: the image cannot be found on the screen, so you have to analyze why

-- comment #5: this is a simple syntax error, so check, what is wrong based on the rules of Python language (indentation ?)

Revision history for this message
vidisha aggarwal (vidisha23-aggarwal) said :
#7

thanks Raiman.

Revision history for this message
vidisha aggarwal (vidisha23-aggarwal) said :
#8

Thanks RaiMan, that solved my question.

Revision history for this message
vishveshwar (vishveshwar-vishu) said :
#9

Hi vidisha& Raiman,
Thank you guys