Skip to content

Instantly share code, notes, and snippets.

@batok
Created October 1, 2010 15:42
Show Gist options
  • Save batok/606366 to your computer and use it in GitHub Desktop.
Save batok/606366 to your computer and use it in GitHub Desktop.
import sys, boto
from hashlib import md5
try:
bucket, key_name, local_name = sys.argv[1:]
except:
sys.exit("wrong arguments")
c = boto.connect_s3()
b = c.get_bucket(bucket, validate = False )
with open(local_name, "r") as f:
local_md5 = md5( f.read() ).hexdigest().upper()
key = b.get_key(key_name)
remote_md5 = key.etag.replace('"','').upper()
if local_md5 == remote_md5:
print "="
else:
print "<>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment