Commit b7b75d69 authored by Daniel Klaffenbach's avatar Daniel Klaffenbach 🐍

ldap_createsuperuser: Use input() for asking username

This should improve Python3 compatibility
parent 23a7cb65
Pipeline #13056 failed with stage
in 11 seconds
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import getpass
import sys
from django.core.management.base import BaseCommand
from django.contrib.auth import get_user_model
......@@ -23,8 +22,7 @@ class Command(BaseCommand):
username = options.get('username')
if not username:
current_user = getpass.getuser()
sys.stdout.write('Username [%s]: ' %current_user)
input_user = sys.stdin.readline().strip()
input_user = input('Username [{}]: '.format(current_user))
if not input_user:
username = current_user
else:
......@@ -46,3 +44,4 @@ class Command(BaseCommand):
else:
obj.save()
self.stdout.write("Granted %s privileges to user %s." % (privilege, username))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment