mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
Merge branch '4324_s3_python3'
* 4324_s3_python3: Ticket 4324: EXTFS: s3+: port to Python3.
This commit is contained in:
commit
ea6bd1866e
@ -153,16 +153,16 @@ def threadmap(fun, iterable, maxthreads=16):
|
|||||||
Propagates exception safely.
|
Propagates exception safely.
|
||||||
"""
|
"""
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
import Queue
|
import queue
|
||||||
|
|
||||||
items = list(iterable)
|
items = list(iterable)
|
||||||
nitems = len(items)
|
nitems = len(items)
|
||||||
if nitems < 2:
|
if nitems < 2:
|
||||||
return map(fun, items)
|
return list(map(fun, items))
|
||||||
|
|
||||||
# Create and fill input queue
|
# Create and fill input queue
|
||||||
input = Queue.Queue()
|
input = queue.Queue()
|
||||||
output = Queue.Queue()
|
output = queue.Queue()
|
||||||
|
|
||||||
for i,item in enumerate(items):
|
for i,item in enumerate(items):
|
||||||
input.put( (i,item) )
|
input.put( (i,item) )
|
||||||
@ -181,7 +181,7 @@ def threadmap(fun, iterable, maxthreads=16):
|
|||||||
output.put( (i,result) )
|
output.put( (i,result) )
|
||||||
except:
|
except:
|
||||||
output.put( (None,sys.exc_info()) )
|
output.put( (None,sys.exc_info()) )
|
||||||
except Queue.Empty:
|
except queue.Empty:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Start threads
|
# Start threads
|
||||||
@ -196,8 +196,8 @@ def threadmap(fun, iterable, maxthreads=16):
|
|||||||
try:
|
try:
|
||||||
i,res = output.get()
|
i,res = output.get()
|
||||||
if i == None:
|
if i == None:
|
||||||
raise res[0],res[1],res[2]
|
raise res[0](res[1]).with_traceback(res[2])
|
||||||
except Queue.Empty:
|
except queue.Empty:
|
||||||
break
|
break
|
||||||
ret.append(res)
|
ret.append(res)
|
||||||
|
|
||||||
@ -241,7 +241,7 @@ def get_bucket(name):
|
|||||||
b = s3.get_bucket(name, validate=False)
|
b = s3.get_bucket(name, validate=False)
|
||||||
b.get_location() # just to raise an exception on error
|
b.get_location() # just to raise an exception on error
|
||||||
return b
|
return b
|
||||||
except boto.exception.S3ResponseError, e:
|
except boto.exception.S3ResponseError as e:
|
||||||
# Seems this is the only proper way to switch to the bucket's region.
|
# Seems this is the only proper way to switch to the bucket's region.
|
||||||
# Requesting of the default region for "?location" does not work unfortunately.
|
# Requesting of the default region for "?location" does not work unfortunately.
|
||||||
m = re.search(r'<Region>(.*?)</Region>', e.body)
|
m = re.search(r'<Region>(.*?)</Region>', e.body)
|
||||||
@ -340,7 +340,7 @@ if cmd == 'list':
|
|||||||
expr = re.compile(r'^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.\d{3}Z$')
|
expr = re.compile(r'^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.\d{3}Z$')
|
||||||
def convDate(awsdatetime):
|
def convDate(awsdatetime):
|
||||||
m = expr.match(awsdatetime)
|
m = expr.match(awsdatetime)
|
||||||
ye,mo,da,ho,mi,se = map(int,m.groups())
|
ye,mo,da,ho,mi,se = list(map(int,m.groups()))
|
||||||
|
|
||||||
dt = datetime.datetime(ye,mo,da,ho,mi,se, tzinfo=pytz.utc)
|
dt = datetime.datetime(ye,mo,da,ho,mi,se, tzinfo=pytz.utc)
|
||||||
return dt.astimezone(tz).strftime('%m-%d-%Y %H:%M')
|
return dt.astimezone(tz).strftime('%m-%d-%Y %H:%M')
|
||||||
|
Loading…
Reference in New Issue
Block a user