-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uri starting with file:// were not interpreted correctly #1874
Conversation
@@ -283,9 +283,10 @@ def openDataset(uri,mode='r',template=None,dods=1,dpath=None, hostObj=None): | |||
uri = string.strip(uri) | |||
(scheme,netloc,path,parameters,query,fragment)=urlparse.urlparse(uri) | |||
if scheme in ('','file'): | |||
if uri[:7].lower() == "file://": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python does not have method load from file:// directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aashish24 Nope, Python doesn't support arbitrary open
on URLs like PHP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chaosphere2112 I thouught that urllib would have something .. but this code is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aashish24 first off it's cdms open not python open.
Second we are using:
(scheme,netloc,path,parameters,query,fragment)=urlparse.urlparse(uri)
but if it starts with file://
then path
and root
are both empty strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chaosphere2112 I'm not 100% sure how the file://
got appended to the uri in the first place... I have a vague recollection of you asking me to do this forthe GUI so I'll take the blame. But it might be worth tracing down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but if it starts with file:// then path and root are both empty strings.
@doutriaux1 path should not be empty if you parse it via urlparse. I just did a local test to confirm this.
LGTM but will wait for travis to finish. |
@doutriaux1 @aashish24 Just pushed a commit that should help solidify this a bit. I tested with all kinds of gnarly paths ("file://../../blah/test.nc", for example), which works. I also made it so we convert paths to absolute paths in the CdmsFile constructor before converting them to file URIs. |
@chaosphere2112 can you add a test as well? |
Thanks @chaosphere2112 |
@chaosphere2112 @aashish24 ready to go |
@doutriaux1 i pushed again to resolve the conflict. |
I am running it manually as well. |
LGTM 👍 and worked on my machine as well. merging. |
uri starting with file:// were not interpreted correctly
fix #1867
@aashish24 @danlipsa @chaosphere2112 quick review