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

find_storage_directories: prevent crash with nonexistent directories #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hans
Copy link

@hans hans commented Dec 19, 2016

I ran zotcli configure on OS X using the pip-distributed package and got the following error:

$ zotcli configure
Do you already have an API key for zotero-cli? [y/N]: n
Opening ...
Enter verification code: ...
[0] Local Zotero storage
[1] Use Zotero file cloud
[2] Use WebDAV storage
How do you want to access files for reading? [1]: 0
Traceback (most recent call last):
  File "/Users/jon/anaconda/bin/zotcli", line 11, in <module>
    load_entry_point('zotero-cli==0.3.0', 'console_scripts', 'zotcli')()
  File "/Users/jon/anaconda/lib/python3.5/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/Users/jon/anaconda/lib/python3.5/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/Users/jon/anaconda/lib/python3.5/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/jon/anaconda/lib/python3.5/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/jon/anaconda/lib/python3.5/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/Users/jon/anaconda/lib/python3.5/site-packages/zotero_cli/cli.py", line 91, in configure
    storage_dirs = tuple(find_storage_directories())
  File "/Users/jon/anaconda/lib/python3.5/site-packages/zotero_cli/cli.py", line 44, in find_storage_directories
    for fpath in candidate_iter:
  File "/Users/jon/anaconda/lib/python3.5/pathlib.py", line 1049, in iterdir
    for name in self._accessor.listdir(self):
  File "/Users/jon/anaconda/lib/python3.5/pathlib.py", line 371, in wrapped
    return strfunc(str(pathobj), *args)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/jon/.mozilla/firefox'

This PR prevents this crash and adds support for the OS X Zotero profile directory.
Thanks for making this package!

@hans
Copy link
Author

hans commented Dec 19, 2016

(I'm not able to test on non-OSX, so let me know if I accidentally broke e.g. the Linux directory setup.)

@jbaiter
Copy link
Owner

jbaiter commented Aug 12, 2017

Sorry for ignoring this issue for so long :/
I just merged a fix from @DancingQuanta (#35) that improves discovery of Zotero storage directories, can you try if that works for you?

@BlueDrink9
Copy link

Sorry to resurrect, but since the original author never responded, I thought I'd mention that I also have this error, so #35 doesn't seem to have fixed it.

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

Successfully merging this pull request may close these issues.

3 participants