parse password from env if available

This commit is contained in:
Jakob Ketterl 2021-02-18 01:32:27 +01:00
parent 2eec29db05
commit 0714ce5703
1 changed files with 11 additions and 6 deletions

View File

@ -4,6 +4,7 @@ from owrx.users import UserList, User, DefaultPasswordClass
import sys
import random
import string
import os
class Command(ABC):
@ -15,6 +16,10 @@ class Command(ABC):
class UserCommand(Command, metaclass=ABCMeta):
def getPassword(self, args, username):
if args.noninteractive:
if "OWRX_PASSWORD" in os.environ:
password = os.environ["OWRX_PASSWORD"]
generated = False
else:
print("Generating password for user {username}...".format(username=username))
password = self.getRandomPassword()
generated = True