mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Use random.choice instead of random.choices
- Allows compatibility with python3.5
This commit is contained in:
parent
3827806603
commit
7a65144641
@ -7,7 +7,9 @@ import os
|
|||||||
fn = 'secret_key.txt'
|
fn = 'secret_key.txt'
|
||||||
|
|
||||||
def generate_key():
|
def generate_key():
|
||||||
return ''.join(random.choices(string.digits + string.ascii_letters + string.punctuation, k=50))
|
options = string.digits + string.ascii_letters + string.punctuation
|
||||||
|
key = ''.join([random.choice(options) for i in range(50)])
|
||||||
|
return key
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
@ -15,6 +17,6 @@ if __name__ == '__main__':
|
|||||||
path = os.path.dirname(os.path.realpath(__file__))
|
path = os.path.dirname(os.path.realpath(__file__))
|
||||||
key_file = os.path.join(path, fn)
|
key_file = os.path.join(path, fn)
|
||||||
|
|
||||||
with open(key_file, 'w') as key:
|
with open(key_file, 'w') as kf:
|
||||||
key.write(generate_key())
|
kf.write(generate_key())
|
||||||
print('Generated SECRET_KEY to {f}'.format(f=key_file))
|
print('Generated SECRET_KEY to {f}'.format(f=key_file))
|
Loading…
Reference in New Issue
Block a user