Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from __future__ import absolute_import, division, print_function, unicode_literals
import csv
import subprocess
import sys
FILENAME = 'redirection.csv'
FLAGS = '--profile doismellburning' # FIXME
with open(FILENAME, 'r') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
if len(row) != 2:
print("Found a row in %s that did not have exactly two fields: %s" % (FILENAME, row))
(from_url, to_url) = row
command = "aws {flags} s3 cp --website-redirect {to_url} {empty_file_path} s3://{bucket}{from_url}".format(flags=FLAGS, to_url=to_url, from_url=from_url, bucket=BUCKETNAME, empty_file_path=FILENAME)
# Yes I was gloriously lazy there and just sent a copy of the redirection file...
print("Redirecting from {from_url} to {to_url}".format(from_url=from_url, to_url=to_url))
subprocess.check_output(command, shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.