def create_admin_user(self):
        loop = pyuv.Loop.default_loop()
        key_mgr = KeyManager(loop, self.cfg)
        auth_mgr = AuthManager(loop, self.cfg)


        # open the auth db
        try:
            auth_mgr.open()
        except:
            logging.error("error while creating an admin",
                    exc_info=True)
            sys.exit(1)

        try:
            username = self.args['--username']
            password = self.args['--password']
            confirm_password = None

            if username and username is not None:
                if auth_mgr.has_user(username):
                    print("username %r already exists. " % username
                            + "Please choose another")
                    sys.exit(1)
            elif username == "":
                print("Error: username is empty")
                sys.exit(1)

            if password == "":
                print("Error: password is empty")

            if not username:
                while True:
                    username = input("username: ").lower()
                    if username and username is not None:
                        if auth_mgr.has_user(username):
                            print("username %r already exists. " % username
                                    % "Please enter another")
                            continue
                        break

                    print("username is empty. Please enter a username.")

            if not password:
                while True:
                    password = getpass("password: ")
                    if password and password is not None:
                        break

                    print("password is empty. Please enter a password.")

                # confirm password

                while True:
                    confirm_password = getpass("confirm password: ")
                    if confirm_password == password:
                        break

                    print("Passwords are different.")
            else:
                confirm_password = password

        except KeyboardInterrupt:
            print("")

        if not username or not password or (confirm_password != password):
            print("admin not created.")
            sys.exit(0)

        # create an admin key
        permissions = {"admin": True}
        try:
            key_mgr.open()
            api_key = key_mgr.create_key(permissions, label="admin key")
        except:
            logging.error("error while creating an admin key",
                    exc_info=True)
            sys.exit(0)
        finally:
            try:
                key_mgr.close()
            except:
                pass

        # create a user
        try:
            auth_mgr.create_user(username, password, user_type=0,
                    key=api_key)
        except:
            logging.error("error while creating an admin",
                    exc_info=True)
            sys.exit(0)
        finally:
            try:
                auth_mgr.close()
            except:
                pass


        print("User %r created.\nAPI Key: %s" % (username, api_key))
dataset/ETHPy150Open benoitc/gaffer/gaffer/gafferd/main.py/Server.create_admin_user/operator `+` -> `%`