how to import other Sikuli scripts

Asked by kishore

Hi,

I created one global functions those global function am calling into the main scripts its working fine through IDE but when am trying to call through command line its showing the following error "unable to import global" function

command line syntax
C:\Program Files\Sikuli X>sikuli-IDE.bat D:\GAAutomation_Sikuli\Scripts\LoginScript.sikuli

tried the following command also

C:\Program Files\Sikuli X>sikuli-IDE-w.bat -r D:\GAAutomation_Sikuli\Scripts\LoginScript.sikuli

still same issue

Please clarify the above issue

Generally how we need to run batch script in sikuli?

Regards,
Kishore

Question information

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

the script running from command line is correct.

--- showing the following error "unable to import global" function
this is not the original error message!
so paste the original error message.

Revision history for this message
kishore (kishore-thotapally) said :
#2

Error : "No Module with named GALogin Found"

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

Still not the original message - what about copy&paste?

Did you prepare the import as stated in the docs?
Paste code here.

where are your .sikuli stored? directory structure?

It is really a hard job to try to help you without any information.

Revision history for this message
kishore (kishore-thotapally) said :
#4

Runtime Error when running D:\Sikuli\Script\Login.sikuli
trackeback (most recent call last): File "D:\Sikuli\Script\Login.sikuli\login.py", line 12,in <module> import GALogin
"Import Error: no module named GALogin"

Folder Structure like

GAAutomation-Sikuli
           |
        Scripts
           |
         Global(Sikuli file name GALogin.sikuli )

Please let me know if any clarifications

Regards,
Kishore

Revision history for this message
j (j-the-k) said :
#5

A wild guess:
try
cd D:\Sikuli\Script
first and then
D:\Sikuli\Script> "C:\Program Files\Sikuli X\sikuli-IDE.bat" -r LoginScript.sikuli

I often experienced that a script did not run on windows if the commandline was not in the directory where the test was.

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

makes it clearer ;-)

-- Your main script (Login.sikuli) is located in
D:\Sikuli\Script\

this is not, as you mentioned above. You are telling, that the working root is GAAutomation-Sikuli.

Below this you have a folder Scripts (not Script ??).

If this all is true though, then you need in Login.sikuli (assuming all is on D: from the root):

dir = r"d:\GAAutomation-Sikuli\Scripts\Global"
if not dir in sys.path: sys.path.append(dir)
import GALogin

assuming, that GALogin.sikuli is in the folder
d:\GAAutomation-Sikuli\Scripts\Global

This is how it is mentioned in the docs.

Revision history for this message
kishore (kishore-thotapally) said :
#7

Thanks J and Raiman, its working fine

Once again Thanks your Support

Regards,
Kishore