addImagePath working on a Pc and not in another

Asked by matteoa on 2019-04-11

Hi,
on my development Pc:
1.1.4-SNAPSHOT-2019-01-30_21:31/Windows10.0/Java8(64)1.8.0_201-b09
I have a folder at the same level of the .sikuli folder that contains my script that contains a set of images.
To access them I have put this in the script:
addImagePath(r"..\ECUImg")
And it works perfectly.
In the "production" pc :
1.1.4-SNAPSHOT-2019-01-30_21:31/Windows6.1/Java8(64)1.8.0_201-b09
i run the same script in a different location, but always with the Image repository folder at the same level of the script, and I have:
[error] ImagePath: add: not valid: ..\ECUImg

I tested using absolute path instead of absolute and it worked well, so I suppose access right et cetc are ok but I'd like to remain "relocatable"...
TO eliminate some possibilities, in both pc the folder exists, withouth spaces in path and are writable by everybody.

Any idea?
Thanks in advance
P.s. I'm currently not using the last version of Sikulix since I have a problem with newer versions of it.

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2019-06-19
Last query:
2019-06-19
Last reply:
2019-04-11
matteoa (matteoa) said : #1

Hello all,
I solved the problem by using this:
p=getParentPath()+r"\ECUImg"
addImagePath(p)
It works on both pc.
I'm ok now, but I think the problem I had is worth an explanation.
Thanks in advance
Matteo

RaiMan (raimund-hocke) said : #2

LOL, 2Fast4me ;-)

had the same idea, after being sure, that the dotted path notation is not supported by addImagePath().

The problem always is: what is the base folder, when you say ../some/what/ever?

Usually it is the working folder.

But I will check.

matteoa (matteoa) said : #3

Thanks RainMan!
Yes, I was supposing that the base folder was the working folder, I tried on my pc and it was ok, then I went to the production pc and...
Let me know
Thanks again for your prompt support!

P.s. the reason for which I'm not using the last version is described in question here:
https://answers.launchpad.net/sikuli/+question/679017

Best RaiMan (raimund-hocke) said : #4

I think it makes sense, when saying in a script
addImagePath(../some/other/folder)

or any other relative path, that it should be relative to the script folder's location.

The rule might be:
- if there is a bundlepath (which is the case with scripts)
- then relative paths should be relative to the script folder's location

I will let this idea cook over night.

Thanks for reporting

BTW: instead of
p=getParentPath()+r"\ECUImg"

use
os.path.join(getParentPath(), "ECUImg")

matteoa (matteoa) said : #5

Thanks RaiMan, that solved my question.