Fix upload from STDIN and Python2.5 compatibly
Michal Ludvig authored on 2013/02/21 11:58:34... | ... |
@@ -145,7 +145,6 @@ def fetch_local_list(args, recursive = None): |
145 | 145 |
info(u"Compiling list of local files...") |
146 | 146 |
|
147 | 147 |
if deunicodise(local_uri.basename()) == "-": |
148 |
- loc_list = SortedDict(ignore_case = False) |
|
149 | 148 |
loc_list["-"] = { |
150 | 149 |
'full_name_unicode' : '-', |
151 | 150 |
'full_name' : '-', |
... | ... |
@@ -413,6 +413,7 @@ class S3(object): |
413 | 413 |
|
414 | 414 |
## MIME-type handling |
415 | 415 |
content_type = self.config.mime_type |
416 |
+ content_encoding = None |
|
416 | 417 |
if filename != "-" and not content_type and self.config.guess_mime_type: |
417 | 418 |
(content_type, content_encoding) = mime_magic(filename) |
418 | 419 |
if not content_type: |
... | ... |
@@ -169,7 +169,13 @@ def formatDateTime(s3timestamp): |
169 | 169 |
try: |
170 | 170 |
import pytz |
171 | 171 |
timezone = pytz.timezone(os.environ.get('TZ', 'UTC')) |
172 |
- utc_dt = datetime.datetime(*dateS3toPython(s3timestamp)[0:6], tzinfo=pytz.timezone('UTC')) |
|
172 |
+ tz = pytz.timezone('UTC') |
|
173 |
+ ## Can't unpack args and follow that with kwargs in python 2.5 |
|
174 |
+ ## So we pass them all as kwargs |
|
175 |
+ params = zip(('year', 'month', 'day', 'hour', 'minute', 'second', 'tzinfo'), |
|
176 |
+ dateS3toPython(s3timestamp)[0:6] + (tz)) |
|
177 |
+ params = dict(params) |
|
178 |
+ utc_dt = datetime.datetime(**params) |
|
173 | 179 |
dt_object = utc_dt.astimezone(timezone) |
174 | 180 |
except ImportError: |
175 | 181 |
dt_object = datetime.datetime(*dateS3toPython(s3timestamp)[0:6]) |
... | ... |
@@ -389,7 +395,7 @@ def time_to_epoch(t): |
389 | 389 |
# Try to parse it as a timestamp string |
390 | 390 |
try: |
391 | 391 |
return time.strptime(t) |
392 |
- except ValueError as ex: |
|
392 |
+ except ValueError, ex: |
|
393 | 393 |
# Will fall through |
394 | 394 |
debug("Failed to parse date with strptime: %s", ex) |
395 | 395 |
pass |