Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Side by Side Diff: third_party/boto/bin/s3put

Issue 698893003: Update checked in version of gsutil to version 4.6 (Closed) Base URL: http://dart.googlecode.com/svn/third_party/gsutil/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/boto/bin/route53 ('k') | third_party/boto/bin/sdbadmin » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2006,2007,2008 Mitch Garnaat http://garnaat.org/ 2 # Copyright (c) 2006,2007,2008 Mitch Garnaat http://garnaat.org/
3 # 3 #
4 # Permission is hereby granted, free of charge, to any person obtaining a 4 # Permission is hereby granted, free of charge, to any person obtaining a
5 # copy of this software and associated documentation files (the 5 # copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including 6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish, dis- 7 # without limitation the rights to use, copy, modify, merge, publish, dis-
8 # tribute, sublicense, and/or sell copies of the Software, and to permit 8 # tribute, sublicense, and/or sell copies of the Software, and to permit
9 # persons to whom the Software is furnished to do so, subject to the fol- 9 # persons to whom the Software is furnished to do so, subject to the fol-
10 # lowing conditions: 10 # lowing conditions:
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 _upload(retries_left=retries_left - 1) 166 _upload(retries_left=retries_left - 1)
167 else: 167 else:
168 print 'Failed uploading part #%d' % part_num 168 print 'Failed uploading part #%d' % part_num
169 raise exc 169 raise exc
170 else: 170 else:
171 if debug == 1: 171 if debug == 1:
172 print '... Uploaded part #%d' % part_num 172 print '... Uploaded part #%d' % part_num
173 173
174 _upload() 174 _upload()
175 175
176 def check_valid_region(conn, region):
177 if conn is None:
178 print 'Invalid region (%s)' % region
179 sys.exit(1)
176 180
177 def multipart_upload(bucketname, aws_key, aws_secret, source_path, keyname, 181 def multipart_upload(bucketname, aws_key, aws_secret, source_path, keyname,
178 reduced, debug, cb, num_cb, acl='private', headers={}, 182 reduced, debug, cb, num_cb, acl='private', headers={},
179 guess_mimetype=True, parallel_processes=4, 183 guess_mimetype=True, parallel_processes=4,
180 region=DEFAULT_REGION): 184 region=DEFAULT_REGION):
181 """ 185 """
182 Parallel multipart upload. 186 Parallel multipart upload.
183 """ 187 """
184 conn = boto.s3.connect_to_region(region, aws_access_key_id=aws_key, 188 conn = boto.s3.connect_to_region(region, aws_access_key_id=aws_key,
185 aws_secret_access_key=aws_secret) 189 aws_secret_access_key=aws_secret)
190 check_valid_region(conn, region)
186 conn.debug = debug 191 conn.debug = debug
187 bucket = conn.get_bucket(bucketname) 192 bucket = conn.get_bucket(bucketname)
188 193
189 if guess_mimetype: 194 if guess_mimetype:
190 mtype = mimetypes.guess_type(keyname)[0] or 'application/octet-stream' 195 mtype = mimetypes.guess_type(keyname)[0] or 'application/octet-stream'
191 headers.update({'Content-Type': mtype}) 196 headers.update({'Content-Type': mtype})
192 197
193 mp = bucket.initiate_multipart_upload(keyname, headers=headers, 198 mp = bucket.initiate_multipart_upload(keyname, headers=headers,
194 reduced_redundancy=reduced) 199 reduced_redundancy=reduced)
195 200
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 332
328 connect_args = { 333 connect_args = {
329 'aws_access_key_id': aws_access_key_id, 334 'aws_access_key_id': aws_access_key_id,
330 'aws_secret_access_key': aws_secret_access_key 335 'aws_secret_access_key': aws_secret_access_key
331 } 336 }
332 337
333 if host: 338 if host:
334 connect_args['host'] = host 339 connect_args['host'] = host
335 340
336 c = boto.s3.connect_to_region(region or DEFAULT_REGION, **connect_args) 341 c = boto.s3.connect_to_region(region or DEFAULT_REGION, **connect_args)
342 check_valid_region(c, region or DEFAULT_REGION)
337 c.debug = debug 343 c.debug = debug
338 b = c.get_bucket(bucket_name, validate=False) 344 b = c.get_bucket(bucket_name, validate=False)
339 345
340 # Attempt to determine location and warn if no --host or --region 346 # Attempt to determine location and warn if no --host or --region
341 # arguments were passed. Then try to automagically figure out 347 # arguments were passed. Then try to automagically figure out
342 # what should have been passed and fix it. 348 # what should have been passed and fix it.
343 if host is None and region is None: 349 if host is None and region is None:
344 try: 350 try:
345 location = b.get_location() 351 location = b.get_location()
346 352
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 reduced, debug, cb, num_cb, 423 reduced, debug, cb, num_cb,
418 grant or 'private', headers, 424 grant or 'private', headers,
419 region=region or DEFAULT_REGION) 425 region=region or DEFAULT_REGION)
420 else: 426 else:
421 singlepart_upload(b, key_name, fullpath, cb=cb, num_cb=num_cb, 427 singlepart_upload(b, key_name, fullpath, cb=cb, num_cb=num_cb,
422 policy=grant, reduced_redundancy=reduced, 428 policy=grant, reduced_redundancy=reduced,
423 headers=headers) 429 headers=headers)
424 430
425 if __name__ == "__main__": 431 if __name__ == "__main__":
426 main() 432 main()
OLDNEW
« no previous file with comments | « third_party/boto/bin/route53 ('k') | third_party/boto/bin/sdbadmin » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698