base64.encodestring needs a bytearray in python3
authorDiane Trout <diane@ghic.org>
Mon, 2 Feb 2015 22:42:32 +0000 (14:42 -0800)
committerDiane Trout <diane@ghic.org>
Mon, 2 Feb 2015 22:42:32 +0000 (14:42 -0800)
I needed to use int2byte to safely replace the char()
I was using in python2.

htsworkflow/util/api.py

index cd7939a29a8839d099cc1ba40aa6dcc5e8001486..e631fa9c5051aeabe2fd39e67bcb7822dd9113b2 100644 (file)
@@ -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