[1.1.4]After run removeImagePath() , the result of getImagePath() is abnormal.

Asked by Linda

If script A.sikuli import B.sikuli.
C.sikuli import A.sikuli.
At script C, run [print getImagePath]
Result is path of[C.sikul,A.sikuli,B.sikuli]

If C.sikuli add commamd [removeImagePath(B.sikuli)]
First runnig result is path of [C.sikul,A.sikuli]
But second runnig result is just the path of [C.sikuli]

I have to reopen sikuli IDE continuously to get correct result.

Question information

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

Have to check.

Revision history for this message
Linda (kkea55534) said :
#2

Hi,RaiMan
I try with setBundlePath.
There is same problem with setBundlePath .

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

I made the following test with latest build of 1.1.4 and did not find any oddities:

#main script cMain.sikuli
import aSub
print "*** from C"
for e in getImagePath(): print e

exit()

removeImagePath(getParentFolder() + "bSub.sikuli")
print "*** from C after remove"
for e in getImagePath(): print e

#sub script aSub.sikuli
from sikuli import *
print "aSub imported"
import bSub

#sub script bSub.sikuli
from sikuli import *
print "bSub imported"

- starting IDE
- opening all scripts
- run cMain

#output:
aSub imported
bSub imported
*** from C
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/cMain.sikuli
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/aSub.sikuli
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/bSub.sikuli

- now I comment out the exit() so the removeImagePath is processed on rerunning cMain

#output:
*** from C
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/cMain.sikuli
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/aSub.sikuli
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/bSub.sikuli
*** from C after remove
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/cMain.sikuli
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/aSub.sikuli

- now I rerun cMain and get:
*** from C
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/cMain.sikuli
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/aSub.sikuli
*** from C after remove
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/cMain.sikuli
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/aSub.sikuli

- same output for every rerun of cMain

If I start the IDE and run cMain without the exit(), I get:
aSub imported
bSub imported
*** from C
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/cMain.sikuli
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/aSub.sikuli
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/bSub.sikuli
*** from C after remove
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/cMain.sikuli
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/aSub.sikuli

and on every rerun:
*** from C
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/cMain.sikuli
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/aSub.sikuli
*** from C after remove
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/cMain.sikuli
/Users/raimundhocke/IdeaProjects/_SUPPORT/Linda/aSub.sikuli

BE AWARE:
if you do any changes in aSub or bSub in the same IDE session, then on rerun of cMain the changed sub(s) are automatically reimported (reload()), but the ImagePath is not touched.

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

the video does not help much, since the file names are truncated and I cannot see, what is imported and what is deleted by removeImagepath.

I guess, what you remove are modules that are imported at level 2 by the module imported in the main script.

... but you are removing the main script from the ImagePath, which removes the bundlePath (ImagePath[0]), which in turn might make problems.

Anyways: I do not understand, why you need this.

Revision history for this message
Linda (kkea55534) said :
#6

I get it.
I change the bundle path as A ,it's normal.
It's abnormal because of no Bundle Path.

P.S. My purpose is that running import script randomly.

Thank RaiMain.