... | ... |
@@ -104,7 +104,7 @@ class Config(object): |
104 | 104 |
enable = None |
105 | 105 |
get_continue = False |
106 | 106 |
put_continue = False |
107 |
- upload_id = None |
|
107 |
+ upload_id = u"" |
|
108 | 108 |
skip_existing = False |
109 | 109 |
recursive = False |
110 | 110 |
restore_days = 1 |
... | ... |
@@ -189,8 +189,8 @@ class Config(object): |
189 | 189 |
limitrate = 0 |
190 | 190 |
requester_pays = False |
191 | 191 |
stop_on_error = False |
192 |
- content_disposition = None |
|
193 |
- content_type = None |
|
192 |
+ content_disposition = u"" |
|
193 |
+ content_type = u"" |
|
194 | 194 |
stats = False |
195 | 195 |
# Disabled by default because can create a latency with a CONTINUE status reply |
196 | 196 |
# expected for every send file requests. |
... | ... |
@@ -149,19 +149,19 @@ def sign_url_base_v2(**parms): |
149 | 149 |
debug("Expiry interpreted as epoch time %s", parms['expiry']) |
150 | 150 |
signtext = 'GET\n\n\n%(expiry)d\n/%(bucket)s/%(object)s' % parms |
151 | 151 |
param_separator = '?' |
152 |
- if content_disposition is not None: |
|
152 |
+ if content_disposition: |
|
153 | 153 |
signtext += param_separator + 'response-content-disposition=' + content_disposition |
154 | 154 |
param_separator = '&' |
155 |
- if content_type is not None: |
|
155 |
+ if content_type: |
|
156 | 156 |
signtext += param_separator + 'response-content-type=' + content_type |
157 | 157 |
param_separator = '&' |
158 | 158 |
debug("Signing plaintext: %r", signtext) |
159 | 159 |
parms['sig'] = s3_quote(sign_string_v2(encode_to_s3(signtext)), unicode_output=True) |
160 | 160 |
debug("Urlencoded signature: %s", parms['sig']) |
161 | 161 |
url = "%(proto)s://%(bucket)s.%(host_base)s/%(object)s?AWSAccessKeyId=%(access_key)s&Expires=%(expiry)d&Signature=%(sig)s" % parms |
162 |
- if content_disposition is not None: |
|
162 |
+ if content_disposition: |
|
163 | 163 |
url += "&response-content-disposition=" + s3_quote(content_disposition, unicode_output=True) |
164 |
- if content_type is not None: |
|
164 |
+ if content_type: |
|
165 | 165 |
url += "&response-content-type=" + s3_quote(content_type, unicode_output=True) |
166 | 166 |
return url |
167 | 167 |
|
... | ... |
@@ -40,7 +40,7 @@ class MultiPartUpload(object): |
40 | 40 |
return parts |
41 | 41 |
|
42 | 42 |
def get_unique_upload_id(self, uri): |
43 |
- upload_id = None |
|
43 |
+ upload_id = "" |
|
44 | 44 |
multipart_response = self.s3.get_multipart(uri) |
45 | 45 |
tree = getTreeFromXml(multipart_response['data']) |
46 | 46 |
for mpupload in parseNodes(tree): |
... | ... |
@@ -49,7 +49,7 @@ class MultiPartUpload(object): |
49 | 49 |
mp_path = mpupload['Key'] |
50 | 50 |
info("mp_path: %s, object: %s" % (mp_path, uri.object())) |
51 | 51 |
if mp_path == uri.object(): |
52 |
- if upload_id is not None: |
|
52 |
+ if upload_id: |
|
53 | 53 |
raise ValueError("More than one UploadId for URI %s. Disable multipart upload, or use\n %s multipart %s\nto list the Ids, then pass a unique --upload-id into the put command." % (uri, sys.argv[0], uri)) |
54 | 54 |
upload_id = mp_upload_id |
55 | 55 |
except KeyError: |
... | ... |
@@ -62,14 +62,14 @@ class MultiPartUpload(object): |
62 | 62 |
Begin a multipart upload |
63 | 63 |
http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?mpUploadInitiate.html |
64 | 64 |
""" |
65 |
- if self.s3.config.upload_id is not None: |
|
65 |
+ if self.s3.config.upload_id: |
|
66 | 66 |
self.upload_id = self.s3.config.upload_id |
67 | 67 |
elif self.s3.config.put_continue: |
68 | 68 |
self.upload_id = self.get_unique_upload_id(self.uri) |
69 | 69 |
else: |
70 |
- self.upload_id = None |
|
70 |
+ self.upload_id = "" |
|
71 | 71 |
|
72 |
- if self.upload_id is None: |
|
72 |
+ if not self.upload_id: |
|
73 | 73 |
request = self.s3.create_request("OBJECT_POST", uri = self.uri, |
74 | 74 |
headers = self.headers_baseline, |
75 | 75 |
uri_params = {'uploads': None}) |
... | ... |
@@ -582,7 +582,7 @@ class S3(object): |
582 | 582 |
|
583 | 583 |
def stdin_content_type(self): |
584 | 584 |
content_type = self.config.mime_type |
585 |
- if content_type == '': |
|
585 |
+ if not content_type: |
|
586 | 586 |
content_type = self.config.default_mime_type |
587 | 587 |
|
588 | 588 |
content_type += "; charset=" + self.config.encoding.upper() |
... | ... |
@@ -2875,7 +2875,7 @@ def main(): |
2875 | 2875 |
raise ParameterError("Chunk size %d MB is too large, must be <= %d MB. Please adjust --multipart-chunk-size-mb" % (cfg.multipart_chunk_size_mb, MultiPartUpload.MAX_CHUNK_SIZE_MB)) |
2876 | 2876 |
|
2877 | 2877 |
## If an UploadId was provided, set put_continue True |
2878 |
- if options.upload_id is not None: |
|
2878 |
+ if options.upload_id: |
|
2879 | 2879 |
cfg.upload_id = options.upload_id |
2880 | 2880 |
cfg.put_continue = True |
2881 | 2881 |
|