Skip to content
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

Use a URI library for parsing filenames and paths #3

Open
bburan opened this issue Mar 15, 2018 · 6 comments
Open

Use a URI library for parsing filenames and paths #3

bburan opened this issue Mar 15, 2018 · 6 comments

Comments

@bburan
Copy link
Contributor

bburan commented Mar 15, 2018

I tried to load a recording using my relative path (e.g., ~/downloads/TAR010c-18-1.targz) but this didn't work since we aren't properly handling URIs. There are already URI libraries out there that can validate URI strings (both local filesystem and protocol-based such as http). See https://pypi.python.org/pypi/uri/2.0.0 for example. We should probably switch to one of these.

@bburan
Copy link
Contributor Author

bburan commented Mar 16, 2018

@jacobpennington How familiar are you with the URI system Ivar set up? I'm having difficulty saving/loading files to my local filesystem because the URI is a bit brittle. Any chance we can integrate a real URI handling library that's a bit smarter about local paths?

@svdavid
Copy link
Contributor

svdavid commented Mar 17, 2018 via email

@jacobpennington
Copy link
Contributor

@bburan Not very familiar - it was all set up pretty quickly in his last week as far as I know. I've used save_resource and load_resource a bit and hooked them up to nems_web, and fixed a couple bugs, but that's about it. Happy to add the URI lib stuff to my todo list though.

@jacobpennington
Copy link
Contributor

jacobpennington commented Mar 23, 2018

@bburan Used the 'uri' library some today and i'm not really sure how to get it to handle '~/...' style paths - it seems to just ignore the ~ altogether. Same with the various os.path and urllib.parse methods. So I'll go ahead and start incorporating it since it helps fix issues like having too many slashes in the wrong place, but I'll probably need some input from you to get ~/ paths supported. Could have the relevant methods replace any leading ~ with os.environ['HOME'] in the meantime, but i'm not sure if that's the right approach.

@neheller
Copy link
Contributor

The OS doesn't know how to handle ~, it's expanded by bash. If you have path-strings like this you should run them through os.path.expanduser(str). Or a better solution might be to convert your path-strings to Path objects from Python 3's pathlib library, which makes path operations a lot less verbose.

@svdavid
Copy link
Contributor

svdavid commented Feb 20, 2020

WEB_API option is now implemented, so that data can now be read in and saved via an http server running on nems_baphy. Crummy name, but basically it substitutes NEMS_RESULTS_DIR and NEMS_RECORDINGS_DIR with http://NEMS_BAPHY_API_HOST:/NEMS_BAPHY_API_PORT
Doesn't fix the original problem, but expands the range of URIs we want to be able to handle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants