install

installer
Log | Files | Refs | README | LICENSE | git clone https://git.ne02ptzero.me/git/install

commit 610a78e62a546acb9916cfd018a2e9c3ffd188d1
parent f5e4d6fa1e3ca9c3a19ff4757e74eeb6109de718
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Wed, 16 Nov 2016 10:39:23 +0100

Add(Users edit): Add user edition in the menu:

Basic error handling done (Duplicate usernames)
Some behavior as been changed in the user menu, for simplicity

Diffstat:
Mscreens/conf_install/conf_install.py | 44+++++++++++++++++++++++++++++++++++---------
1 file changed, 35 insertions(+), 9 deletions(-)

diff --git a/screens/conf_install/conf_install.py b/screens/conf_install/conf_install.py @@ -20,6 +20,8 @@ # By: Louis Solofrizzo <louis@morphux.org> ## +import time + class Conf_Install: ## @@ -121,10 +123,16 @@ class Conf_Install: return 1 elif (code == "ok" and tag == "Save"): return 0 + elif (code == "ok"): + self.add_new_user(tag) - def add_new_user(self): + def add_new_user(self, user = ""): list = ["", "", "/bin/false", "/home/$USER"] - while list[0] == "": + if (user != ""): + for o in self.users_l: + if o["username"] == user: + list = [o["username"], o["groups"], o["shell"], o["home"]] + while list[0] == "" or user != "": code, list = self.dlg.form("Please provide the following informations:", [ ("Username", 1, 1, list[0], 1, 20, 30, 30), ("Groups", 2, 1, list[1], 2, 20, 30, 30), @@ -136,16 +144,34 @@ class Conf_Install: if (list[0] == ""): self.dlg.msgbox("Username cannot be blank") return self.add_new_user() + if user == "" or user != list[0]: + for o in self.users_l: + if (o["username"] == list[0]): + self.dlg.msgbox("Username '"+ list[0] +"' already exist.") + return self.add_new_user(user) password = self.add_new_user_password(list[0]) if (type(password) == type(1)): return 1 - self.users_l.append({ - "username": list[0], - "groups": list[1], - "shell": list[2], - "home": list[3], - "passw": password - }) + if user == "": + self.users_l.append({ + "username": list[0], + "groups": list[1], + "shell": list[2], + "home": list[3], + "passw": password + }) + else: + for o in self.users_l: + if o["username"] == user: + self.users_l.remove(o) + self.users_l.append({ + "username": list[0], + "groups": list[1], + "shell": list[2], + "home": list[3], + "passw": password + }) + user = "" return 0 def add_new_user_password(self, username):