py3: fix swift-dispersion-populate

Change-Id: I1f140ae00cbd25b23c9a40ee91dccee8c7c15d81
This commit is contained in:
Tim Burke 2019-10-14 11:34:31 -07:00
parent 29d46ca9f6
commit 4c66596e63

View File

@ -15,6 +15,7 @@
# limitations under the License.
from __future__ import print_function
import io
import traceback
from optparse import OptionParser
from sys import exit, stdout
@ -22,8 +23,8 @@ from time import time
from eventlet import GreenPool, patcher, sleep
from eventlet.pools import Pool
import six
from six.moves import range
from six.moves import cStringIO as StringIO
from six.moves.configparser import ConfigParser
try:
@ -56,7 +57,8 @@ def put_object(connpool, container, obj, report):
global retries_done
try:
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})
retries_done += conn.attempts - 1
if report: