in scripts/download_media.py [0:0]
def download_s3(s3path,odir):
new_env=os.environ.copy()
for key,value in six.iteritems(new_env):
new_env[key]=value.strip()
if not os.path.exists(odir):
os.makedirs(odir)
s3bucket = s3path.split('s3://')[1].split('/')[0]
cmd = aws_cmd + ' s3api get-bucket-location --bucket ' + s3bucket + " | grep -Po '(?" + '<="LocationConstraint": ")[^"]*'+ "'"
s3bucketregion = subprocess.Popen([cmd], env=new_env, stdout=subprocess.PIPE, shell=True)
s3bucketregion = s3bucketregion.stdout.read().rstrip()
s3bucketregion = s3bucketregion.decode()
print('Will download HANA media from ' + s3path + ' To ' + odir)
cmd = aws_cmd
cmd = cmd + ' s3 sync ' + s3path
if s3bucketregion == "null" or s3bucketregion == "":
cmd = cmd + ' ' + odir
else:
cmd = cmd + ' ' + odir + ' --region ' + s3bucketregion
if not os.path.exists(odir):
os.makedirs(odir)
print('Executing ' + cmd)
output = subprocess.Popen([cmd], env=new_env, stdout=subprocess.PIPE, shell=True)
(out, err) = output.communicate()
cmd = 'chmod 755 ' + odir + '/*.exe'
output = exe_cmd(cmd)