Skip to content

Instantly share code, notes, and snippets.

@MatthewRalston
Created March 13, 2018 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MatthewRalston/6f3d8ba468694243022a0db17a472b00 to your computer and use it in GitHub Desktop.
Save MatthewRalston/6f3d8ba468694243022a0db17a472b00 to your computer and use it in GitHub Desktop.
s3sync
from awscli.clidriver import create_clidriver
def s3sync(source, destination, *options):
old_env = dict(os.environ)
try:
env = os.environ.copy()
env["LC_CTYPE"] = u"en_US.UTF"
os.environ.update(env)
exit_code = create_clidriver().main(["s3", "sync", source, destination] + list(options))
if exit_code > 0:
raise RuntimeError("AWS S3 cli exited with code {0}".format(exit_code))
finally:
os.environ.clear()
os.environ.update()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment