Skip to content
Snippets Groups Projects
Commit bc4adbd2 authored by edupin's avatar edupin
Browse files

Update maap S3 script

parent 0a2026c4
No related branches found
No related tags found
No related merge requests found
#zip -r Project_template.zip Project_template
export VERSION=0.3
export VERSION=0.4
docker build -t kosted/bmap-stack:$VERSION .
docker run --rm kosted/bmap-stack:$VERSION pip freeze
docker push kosted/bmap-stack:$VERSION
......
......@@ -33,6 +33,7 @@ def display_help():
print('list folder/path List data in a subfolder')
print('delete path/in/S3/file.tiff Delete an existing data on S3')
print('refresh Refresh credentials and password')
print('token email password Return a bearer token')
print('resume Resume last interrupted multipart upload')
sys.exit(2)
......@@ -114,6 +115,23 @@ def generate_token(email, password):
sys.exit(2)
################################
# Generate token and return it #
###############################
def get_token(email, password):
#print("[INFO] Start retrieving token for authent")
#Set the bearer
url = "https://iam."+MAAP_ENV_TYPE.lower()+".esa-maap.org/oxauth/restv1/token"
response = requests.post(url, data={'client_id': CLIENT_ID, 'username': email, 'password': password, "grant_type": "password", "scope": "openid+profile"})
#Convert the string to json to fecth access_token
data = json.loads(response.text)
token = data['access_token']
print (token)
return token
#########################
# Check if file is older#
#########################
......@@ -481,7 +499,7 @@ argv = sys.argv[1:]
result=0
try:
if len(argv) == 0:
display_help()
else:
......@@ -501,6 +519,12 @@ try:
display_help()
else:
delete(argv[1])
elif argv[0] == 'token':
# Delete a data
if len(argv) != 3:
display_help()
else:
get_token(argv[1], argv[2])
elif argv[0] == 'download':
# Download a data
if len(argv) != 3:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment