Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
username = os.environ.get('EARTHDATA_USERNAME')
if username is None:
username = input('EarthData username: ')
password = os.environ.get('EARTHDATA_PASSWORD')
if password is None:
password = getpass('EarthData password: ')
auth = (username, password)
login = requests.get(url)
downloader = pooch.HTTPDownloader(auth=auth, progressbar=True)
try:
downloader(login.url, output_file, dataset)
except requests.exceptions.HTTPError as error:
if 'Unauthorized' in str(error):
pooch.get_logger().error('Wrong username/password!')
raise error
# icepack is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# The full text of the license can be found in the file LICENSE in the
# icepack source directory or at .
r"""Routines for fetching the glaciological data sets used in the demos"""
import os
from getpass import getpass
import requests
import pooch
pooch.get_logger().setLevel('WARNING')
def _earthdata_downloader(url, output_file, dataset):
username = os.environ.get('EARTHDATA_USERNAME')
if username is None:
username = input('EarthData username: ')
password = os.environ.get('EARTHDATA_PASSWORD')
if password is None:
password = getpass('EarthData password: ')
auth = (username, password)
login = requests.get(url)
downloader = pooch.HTTPDownloader(auth=auth, progressbar=True)
try:
downloader(login.url, output_file, dataset)
except requests.exceptions.HTTPError as error: