.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/ex1_config_netrc.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_ex1_config_netrc.py: Configure OpenDAP ================= This script is designed to create create a .netrc, .dodsrc, and .urs_cookies if those files do not yet exist. All files will be created in the user's home directory. The .netrc file must contain a valid EarthData login and password. The file will be created as read/write for user only to avoid revealing your password to others. .. GENERATED FROM PYTHON SOURCE LINES 13-15 Get Paths for Files to Create ----------------------------- .. GENERATED FROM PYTHON SOURCE LINES 15-51 .. code-block:: default import os import getpass netrcpath = os.path.expanduser('~/.netrc') cookiespath = os.path.expanduser('~/.urs_cookies') dodsrcpath = os.path.expanduser('~/.dodsrc') # Make ~/.netrc with w/r for user only. # Contents will be if os.path.exists(netrcpath): print(netrcpath + ' exists; delete to remake') else: with open(netrcpath, 'w') as outf: outf.write('') os.chmod(netrcpath, 0x600) with open(netrcpath, 'w') as outf: outf.seek(0, 2) outf.write(f""" machine urs.earthdata.nasa.gov login {getpass.getpass('URS User:')} password {getpass.getpass('URS Password:')} """) if os.path.exists(cookiespath): print(cookiespath + ' exists; delete to remake') else: with open(cookiespath, 'w') as outf: outf.write('') if os.path.exists(dodsrcpath): print(dodsrcpath + ' exists; delete to remake') else: with open(dodsrcpath, 'w') as outf: outf.write(f"""HTTP.NETRC={netrcpath} HTTP.COOKIEJAR={cookiespath} """) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_ex1_config_netrc.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ex1_config_netrc.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ex1_config_netrc.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_