petermr / pygetpapers

a Python version of getpapers
Apache License 2.0
78 stars 9 forks source link

Filesystem errors need trapping or documenting #10

Closed petermr closed 3 years ago

petermr commented 3 years ago

I was in a stale directory by mistake and issued:

pygetpapers -q "(essential oil) AND morocco AND mint AND leaf" -k 1 -o morocco_mint_leaf -p -x
Traceback (most recent call last):
  File "/opt/anaconda3/bin/pygetpapers", line 8, in <module>
    sys.exit(main())
  File "/opt/anaconda3/lib/python3.8/site-packages/pygetpapers/pygetpapers.py", line 695, in main
    callpygetpapers = pygetpapers()
  File "/opt/anaconda3/lib/python3.8/site-packages/pygetpapers/pygetpapers.py", line 11, in __init__
    self.LOGGING_URL = os.path.join(str(os.getcwd()), '*', 'fulltext.xml')
PermissionError: [Errno 1] Operation not permitted

This will confuse users (it initially confused me. I suggest catching all File/IO errors, PermissionErrors and adding a more user-oriented message, e.g. " Filesystem error. Cannot run operation on/in this directory or file" and then throw the error.