import boto, os, time

def print_result(subject, action, success):
  modifier = ' not '
  if success == True:
    modifier = ' '
  print subject + modifier + action + '.'

# We want to commit all modified files to the s3 bucket for the site
def commit_to_s3(bucket_name, src_folder):
  success = False

  try:
    # Requires S3 creds, which I set as environment variables
    connection = boto.connect_s3();
    bucket = connection.lookup(bucket_name)

    if bucket == None:
      # Create the bucket if we don't have it
      print 'Bucket ' + bucket_name + ' not found. Creating...'
      bucket = connection.create_bucket(bucket_name)
      print 'Bucket ' + bucket_name + ' created.'
    else:
      # Iterating over all files in the web-content folder
      for directory, subdirectories, files in os.walk(src_folder):
        for filename in files:
          # We want the path to get each file
          local_file_path = os.path.join(directory, filename)
          # For s3, we don't want the 'public' part of file path
          s3_file_path = local_file_path[len(src_folder)+1:]

          remote_file = bucket.get_key(s3_file_path)

          print filename + ' is uploading...'
          key_file = boto.s3.key.Key(bucket)
          key_file.key = s3_file_path
          key_file.set_contents_from_filename(local_file_path)
          key_file.make_public()

          # Will print after update or if no update was required
          print filename + ' is up to date.'

    # If we got here with no exceptions, changes have been committed
    success = True

  # Boto provides little in the way of exception handling, need a blanket
  except Exception, e:
    print e

  return print_result('Changes', 'committed', success)

@@ -686,24 +686,13 @@
 d.'%0A
-    else:%0A 
+%0A
     
- 
 # It
@@ -740,18 +740,16 @@
  folder%0A
-  
     for 
@@ -805,18 +805,16 @@
 older):%0A
-  
       fo
@@ -842,18 +842,16 @@
         
-  
 # We wan
@@ -878,18 +878,16 @@
 ch file%0A
-  
         
@@ -946,18 +946,16 @@
         
- 
- 
 # For s3
@@ -1009,18 +1009,16 @@
         
-  
 s3_file_
@@ -1061,18 +1061,16 @@
 r)+1:%5D%0A%0A
-  
         
@@ -1113,34 +1113,32 @@
 _path)%0A%0A        
-  
 print filename +
@@ -1157,34 +1157,32 @@
 ing...'%0A        
-  
 key_file = boto.
@@ -1200,34 +1200,32 @@
 bucket)%0A        
- 
- 
 key_file.key = s
@@ -1232,26 +1232,24 @@
 3_file_path%0A
-  
         key_
@@ -1297,18 +1297,16 @@
 e_path)%0A
-  
         
@@ -1337,18 +1337,16 @@
         
-  
 # Will p
@@ -1392,18 +1392,16 @@
 equired%0A
-  
         

Fix upload on new bucket to upload