Closed tdiprima closed 7 years ago
I don't know how you compose that path name, but in Python you can (should!) use os.path.join
to do this in a platform-safe way.
Although, looking at the error, I am not sure path separator is the cause. You are trying to access C:/TCGA-3C-AALI-01Z-00-DX1_20170501094619.zip
. It is highly unlikely this is correct, and if it is correct - it should be fixed. You cannot expect to be able to save anything into top level of a system drive on Windows. It's not a good style, and you would need Admin permissions to do it...
Thanks for the tip, @fedorov. I'll have a go at it.
We have 2 issues:
We're adding a slash when building this file path
os.path.join(self.resourcesPath, "Colors/SlicerPathology.csv")
We should probably do a join, and another join.
When we get the output mask file name, we do
os.path.join(self.dataDirButton.directory, labelName + '.tif')
And that comes out to ./TCGA-41-3393-01Z-00-DX1...
So it looks like Windows interprets that as root. So we can't build that one as a relative path.
We should probably do a join, and another join.
join takes arbitrary number of arguments, so it is easier:
In [3]: os.path.join('a','b','c','d','e')
Out[3]: 'a/b/c/d/e'
Right. Or even os.sep
. Coolness! Thank you.
Update:
I figured out what triggers problem 2...
If the user doesn't change the data directory (class ctkDirectoryButton
), when you ask it for it's .directory
, it gives you: .
Current directory in *nix. But in Windows, that's not right.
We're getting a "Permission denied" error on Windows because the slashes are backwards: u'C:/TCGA-3C-AALI-01Z-00-DX1_20170501094619.zip'
On Linux, the slashes go like this: / On Windows, it's like this: \
But if you look at the error output... there ares slashes going both directions.