[1.0.1] getBundlePath() adds extra slash at end --- fixed in 1.1.0

Bug #1269650 reported by Zed
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SikuliX
Fix Committed
Critical
RaiMan

Bug Description

Using getBundlePath() yields "/path/to/bundle.sikuli/ " as opposed to "/path/to/bundle.sikuli", which was the behavior in previous versions.

Because of this change, os.path.dirname(getBundlePath()) stops giving you "/path/to" and instead gives you '/path/to/bundle.sikuli", which a rather annoying inconvenience.

Revision history for this message
RaiMan (raimund-hocke) wrote :

Uuups, I was not aware of that -- interesting, that you are the first complaining about that.

I will fix it with version 1.1.0

Until then a workaround is to put in scripts using it at the top:
def getBundlePath(): return Sikuli.getBundlePath()[:-1]

this would (temporarily) override the function (drawback: has to be deleted again with 1.1.0)

If you are familiar with unzipping jar's and zipping them back with Java's jar utility:
all Sikuli jars contain a folder /Lib/sikuli containing the Sikuli.py

change (at line 140)
def getBundlePath():
    return ImageLocator.getBundlePath()

to
def getBundlePath():
    return ImageLocator.getBundlePath()[:-1]

Changed in sikuli:
status: New → Fix Committed
importance: Undecided → High
assignee: nobody → RaiMan (raimund-hocke)
milestone: none → 1.1.0
summary: - getBundlePath() adds extra slash at end in version 1.0.1
+ [1.0.1] getBundlePath() adds extra slash at end
RaiMan (raimund-hocke)
Changed in sikuli:
importance: High → Critical
summary: - [1.0.1] getBundlePath() adds extra slash at end
+ [1.0.1] getBundlePath() adds extra slash at end --- fixed in 1.1.0
Revision history for this message
Jay (jay-abbott) wrote :

Everywhere I look suggests that the correct way to get the bundle path for opening other files you want to keep in your bundle is like this:

os.path.dirname(getBundlePath())

However, without the trailing slash, this returns the parent directory of the Sikuli bundle, not the sikuli bundle itself. Since the bundle is a directory, then os.path.dirname(getBundlePath()) should return that directory.

I think this 'fix' actually breaks the desired behaviour. getBundlePath() should return the path OF the bundle, not the path TO the bundle.

Revision history for this message
RaiMan (raimund-hocke) wrote :

@Jay
I do not know where you get that.

if you have something like that
someFolder/someBundle.sikuli

then exactly someBundle.sikuli is the folder containing the "bundle-stuff"

... and this is returned by getBundlePath()

so if you want to access something inside the bundle:
myStuff = os.path.join(getBundlePath(), "myStuff.xxx")

supposing:
someFolder/someBundle.sikuli/myStuff.xxx

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.