py3: fix swift-dispersion-populate
Change-Id: I1f140ae00cbd25b23c9a40ee91dccee8c7c15d81
This commit is contained in:
parent
29d46ca9f6
commit
4c66596e63
@ -15,6 +15,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import io
|
||||||
import traceback
|
import traceback
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from sys import exit, stdout
|
from sys import exit, stdout
|
||||||
@ -22,8 +23,8 @@ from time import time
|
|||||||
|
|
||||||
from eventlet import GreenPool, patcher, sleep
|
from eventlet import GreenPool, patcher, sleep
|
||||||
from eventlet.pools import Pool
|
from eventlet.pools import Pool
|
||||||
|
import six
|
||||||
from six.moves import range
|
from six.moves import range
|
||||||
from six.moves import cStringIO as StringIO
|
|
||||||
from six.moves.configparser import ConfigParser
|
from six.moves.configparser import ConfigParser
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -56,7 +57,8 @@ def put_object(connpool, container, obj, report):
|
|||||||
global retries_done
|
global retries_done
|
||||||
try:
|
try:
|
||||||
with connpool.item() as conn:
|
with connpool.item() as conn:
|
||||||
conn.put_object(container, obj, StringIO(obj),
|
data = io.BytesIO(obj if six.PY2 else obj.encode('utf8'))
|
||||||
|
conn.put_object(container, obj, data,
|
||||||
headers={'x-object-meta-dispersion': obj})
|
headers={'x-object-meta-dispersion': obj})
|
||||||
retries_done += conn.attempts - 1
|
retries_done += conn.attempts - 1
|
||||||
if report:
|
if report:
|
||||||
|
Loading…
Reference in New Issue
Block a user