NDAR / nda-tools

Python package for interacting with NDA web services. Used to validate, submit, and download data to and from NDA.
MIT License
48 stars 22 forks source link

`KeyError : 'content-type' error`, even when package ID was provided through `-dp` #47

Closed dyhan316 closed 8 months ago

dyhan316 commented 2 years ago

I used the command, downloadcmd -dp 12038XX -d '/scratch/08834/tg881334/ABCD_release4' -u 'XXXX' -p 'YYYY'

However, I got the following error, stating that there was a KeyError :

(download_TRY) login4.stampede2(456)$ downloadcmd -dp 12038XX -d '/scratch/08834/tg881334/ABCD_release4' -u 'XXX' -p 'YYYY' 
Running NDATools Version 0.2.18
Warning: Support for the password flag (-p, --password) has been removed from nda-tools due to security concerns and has been replaced with keyring.
The password that was entered for user 'XXXX' is invalid ...
If your username was previously entered incorrectly, you may update it in your settings.cfg located at 
/home1/08834/tg881334/logout/envs/download_TRY/lib/python3.7/site-packages/NDATools/clientscripts/config/settings.cfg
Enter your NIMH Data Archives password:

No value specified for --workerThreads. Using the default option of 27
Important - You can configure the thread count setting using the --workerThreads argument to maximize your download speed.

Getting Package Information...
Traceback (most recent call last):
  File "/home1/08834/tg881334/logout/envs/download_TRY/bin/downloadcmd", line 8, in <module>
    sys.exit(main())
  File "/home1/08834/tg881334/logout/envs/download_TRY/lib/python3.7/site-packages/NDATools/clientscripts/downloadcmd.py", line 200, in main
    s3Download.start()
  File "/home1/08834/tg881334/logout/envs/download_TRY/lib/python3.7/site-packages/NDATools/Download.py", line 191, in start
    package_resource = self.get_package_info()
  File "/home1/08834/tg881334/logout/envs/download_TRY/lib/python3.7/site-packages/NDATools/Download.py", line 952, in get_package_info
    tmp = get_request(url,headers=self.request_header(),auth=self.auth)
  File "/home1/08834/tg881334/logout/envs/download_TRY/lib/python3.7/site-packages/NDATools/Utils.py", line 289, in get_request
    error_handler(tmp)
  File "/home1/08834/tg881334/logout/envs/download_TRY/lib/python3.7/site-packages/NDATools/Utils.py", line 60, in print_and_exit
    if 'json' in r.headers['Content-Type']:
  File "/home1/08834/tg881334/logout/envs/download_TRY/lib/python3.7/site-packages/requests/structures.py", line 52, in __getitem__
    return self._store[key.lower()][1]
KeyError: 'content-type'

I looked at previous GitHub issues, and this one : https://github.com/NDAR/nda-tools/issues/45 states that this occurs when the package ID was not specified via -dp. However, provided the -dp option. Could anyone help me determine where I did wrong?

Thank you in advance :)

gregmagdits commented 1 year ago

I was able to reproduce this error by putting the literal '12038XX' as the value for -dp command line argument. Did you replace the last 2 digits of your package-id with XX for security reasons, or did you actually specify '12038XX' as the value of the -dp argument?

dyhan316 commented 1 year ago

I have been able to resolve this issue~! Thank you for the response :)