diff options
Diffstat (limited to 'scripts/s3upload.py')
| -rw-r--r-- | scripts/s3upload.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/scripts/s3upload.py b/scripts/s3upload.py index 9263a8f..163f3b6 100644 --- a/scripts/s3upload.py +++ b/scripts/s3upload.py @@ -28,7 +28,7 @@ def retry_func(f, count): print 'Error! retrying %s more time(s)' % (count - 1) retry_func(f, count - 1) -def upload_file(path, conn, verbose=True, dryrun=False): +def upload_file(path, verbose=True, dryrun=False): path = os.path.normpath(path) if path == '.' or not os.path.isfile(path): return @@ -41,6 +41,7 @@ def upload_file(path, conn, verbose=True, dryrun=False): path = path.replace('\\', '/') # Windows hack start = time.time() def do_upload(): + conn = get_or_initialize_aws_connection() conn.put(BUCKET_NAME, path, S3.S3Object(filedata), {'x-amz-acl': 'public-read', 'Content-Type': content_type}) @@ -52,26 +53,25 @@ def upload_file(path, conn, verbose=True, dryrun=False): print "uploaded %s (%0.0fms) (%sKB)" % (path, ms_took, size / 1024) return 1 -def upload_directory(path, conn, verbose=True, dryrun=False): +def upload_directory(path, verbose=True, dryrun=False): counter = 0 for f in sorted(os.listdir(path)): subpath = os.path.join(path, f) if os.path.isdir(subpath): - counter += upload_directory(subpath, conn, verbose=verbose, dryrun=dryrun) + counter += upload_directory(subpath, verbose=verbose, dryrun=dryrun) else: - counter += upload_file(subpath, conn, verbose=verbose, dryrun=dryrun) + counter += upload_file(subpath, verbose=verbose, dryrun=dryrun) return counter def do_upload(path, verbose=True, dryrun=False): - conn = get_or_initialize_aws_connection() counter = 0 start = time.time() if os.path.isdir(path): - counter += upload_directory(path, conn, verbose=verbose, dryrun=dryrun) + counter += upload_directory(path, verbose=verbose, dryrun=dryrun) else: - counter += upload_file(path, conn, verbose=verbose, dryrun=dryrun) + counter += upload_file(path, verbose=verbose, dryrun=dryrun) s_took = (time.time() - start) |
