Skip to content

Commit

Permalink
add pass and user from env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcYin committed Jan 29, 2019
1 parent 34c6e80 commit 4149083
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install:
- conda config --set always_yes yes --set changeps1 no
- conda config --add channels conda-forge
- conda update -q conda
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION pytest pyyaml scipy numpy psutil six requests scikit-learn scikit-image 'gdal>=2.1,<2.4' pytest-cov coverage pip
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION pytest pyyaml scipy numpy psutil six requests scikit-learn scikit-image 'gdal>=2.1,<2.4' pytest-cov coverage pip conda-build anaconda-client
- source activate test-environment
- conda info -a
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
Expand All @@ -29,14 +29,14 @@ install:
pip install gp_emulator==1.6.1;
fi
- pip install lightgbm >=2.1.0 coveralls codecov
- conda install conda-build anaconda-client
- conda list
script:
# Output something every 10 minutes or Travis kills the job
- while sleep 9m; do echo "=====[ $SECONDS seconds still running ]====="; done &
- py.test -s --cov
#Killing background sleep loop
- kill %1
- cp /dev/null SIAC/data/.earthdata_auth
- coverage xml
- export SIAC_VERSION=$TRAVIS_TAG
deploy:
Expand All @@ -51,6 +51,6 @@ after_success:
- codecov
- coveralls
- rm -rf SIAC/emus/*.pkl S2?_MSIL1C*.SAFE
- rm -rf ~/miniconda.sh
#- rm -rf ~/miniconda.sh
#- bash conda_upload.sh
- if [ -z "$SIAC_VERSION" ]; then echo "No git tag was set skipping anaconda build"; else bash conda_upload.sh ; fi
15 changes: 15 additions & 0 deletions SIAC/get_MCD43.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@
logger = create_logger()
test_url = 'https://e4ftl01.cr.usgs.gov/MOTA/MCD43A1.006/2000.02.24/MCD43A1.A2000055.h32v08.006.2016101152216.hdf.xml'

try:
auth = tuple([os.environ['Earthdata_user'], os.environ['Earthdata_pass']])
with requests.Session() as s:
s.auth = auth
r1 = s.get(test_url)
r = s.get(r1.url, stream=True, headers={'user-agent': 'My app'})
if r.status_code == 401:
logger.error('Wrong username and password are set for Earthdata_user and Earthdata_pass Environment variables.')
else:
with open(file_path + '/data/.earthdata_auth', 'wb') as f:
for i in auth:
f.write((i + '\n').encode())
except:
logger.error('Environment variables Earthdata_user and Earthdata_pass for accessing NASA Earthdata are not set, and trying to read from file or input.')

if os.path.exists(file_path + '/data/.earthdata_auth'):
try:
username, password = np.loadtxt(file_path + '/data/.earthdata_auth', dtype=str)
Expand Down
4 changes: 2 additions & 2 deletions conda_upload.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
conda install conda-build
conda install anaconda-client
#conda install conda-build
#conda install anaconda-client
PKG_NAME=siac && USER=f0xy
mkdir ~/conda-bld
conda config --set anaconda_upload no
Expand Down

0 comments on commit 4149083

Please sign in to comment.