aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Preud'homme <thomasp@graphcore.ai>2019-10-10 10:31:17 +0000
committerThomas Preud'homme <thomasp@graphcore.ai>2019-10-10 10:31:17 +0000
commite348ca759297854f827c07216f01c06a7313e954 (patch)
tree592a8c9c738ad676e8489401264f9e77547ebee9
parent9c06b955e056504f723d8828a956fe6303f8135a (diff)
[LNT] Python 3 support: adapt secret computation
Computation of the secret when it is not supplied on the command line involves passing a string constructed with str to the sha1 function. However that function expects binary data which is a different type in Python3. This commit uses the bytes constructor as an additional step to convert from text to binary data. Reviewers: cmatthews, hubert.reinterpretcast, kristof.beyls Reviewed By: hubert.reinterpretcast Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D68104 git-svn-id: https://llvm.org/svn/llvm-project/lnt/trunk@374303 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lnt/lnttool/create.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/lnt/lnttool/create.py b/lnt/lnttool/create.py
index 3cfafe7..707b810 100644
--- a/lnt/lnttool/create.py
+++ b/lnt/lnttool/create.py
@@ -113,6 +113,7 @@ def action_create(instance_path, name, config, wsgi, tmp_dir, db_dir,
* INSTANCE_PATH should point to a directory that will keep
LNT configuration.
"""
+ from builtins import bytes
from .common import init_logger
import hashlib
import lnt.server.db.migrate
@@ -137,8 +138,12 @@ LNT configuration.
tmp_path = os.path.join(basepath, tmp_dir)
wsgi_path = os.path.join(basepath, wsgi)
schemas_path = os.path.join(basepath, "schemas")
- secret_key = (secret_key or
- hashlib.sha1(str(random.getrandbits(256))).hexdigest())
+ secret_key = (
+ secret_key or
+ hashlib.sha1(
+ bytes(str(random.getrandbits(256)), encoding="ascii")
+ ).hexdigest()
+ )
os.mkdir(instance_path)
os.mkdir(tmp_path)