From: Diane Trout Date: Mon, 2 Feb 2015 22:42:32 +0000 (-0800) Subject: base64.encodestring needs a bytearray in python3 X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=21b87d2ee5cd1c14c327b0fbaafba7f244dfc8c5 base64.encodestring needs a bytearray in python3 I needed to use int2byte to safely replace the char() I was using in python2. --- diff --git a/htsworkflow/util/api.py b/htsworkflow/util/api.py index cd7939a..e631fa9 100644 --- a/htsworkflow/util/api.py +++ b/htsworkflow/util/api.py @@ -1,7 +1,10 @@ """Common functions for accessing the HTS Workflow REST API """ +from __future__ import unicode_literals + import base64 from six.moves import configparser +from six import int2byte import random import logging @@ -172,9 +175,9 @@ def make_django_secret_key(size=216): chars = [] while bits > 0: byte = bits & 0xff - chars.append(chr(byte)) + chars.append(int2byte(byte)) bits >>= 8 - return base64.encodestring("".join(chars)).strip() + return base64.encodestring(b"".join(chars)).strip() if __name__ == "__main__": from optparse import OptionParser