From 20e0b17e563da17ba46dc32832cf4ed9173a7531 Mon Sep 17 00:00:00 2001 From: Elsa Culler Date: Wed, 24 Apr 2024 12:16:27 -0600 Subject: [PATCH] Add environment auth option --- earthpy/appeears.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/earthpy/appeears.py b/earthpy/appeears.py index 80c3fd0a..b1b4e6cc 100644 --- a/earthpy/appeears.py +++ b/earthpy/appeears.py @@ -12,11 +12,11 @@ import os import pathlib import re -import requests import time from glob import glob import keyring +import requests class AppeearsDownloader(object): """ @@ -174,6 +174,14 @@ def login(self, service='NASA_EARTHDATA', username_id='NED_USERNAME'): except: username = None password = None + + # Get username and password from environment + try: + username = os.environ['EARTHDATA_USERNAME'] + password = os.environ['EARTHDATA_PASSWORD'] + except: + username = None + password = None # Prompt user if no username or password is stored if (username is None) or (password is None): @@ -337,4 +345,4 @@ def download_files(self, cache=True): f.write(data) # Remove task id file when download is complete - os.remove(self.task_id_path) + os.remove(self.task_id_path) \ No newline at end of file