install

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

commit c1c2b4f07532d164030338ffe3c85df81574c540
parent 0bc106d69ea29586be2ac89e8004b90abf6fc7b8
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Tue, 15 Nov 2016 18:11:15 +0100

Add(Modules): Add a new module conf_install:

Fix some weird behavior in module switching in main.py

Diffstat:
Mmain.py | 15++++++++-------
Ascreens/conf_install/__init__.py | 0
Ascreens/conf_install/conf_install.py | 81+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mscreens/main_menu/main_menu.py | 2+-
4 files changed, 90 insertions(+), 8 deletions(-)

diff --git a/main.py b/main.py @@ -23,6 +23,7 @@ import locale from pythondialog.dialog import * +import time ## # Global configuration @@ -46,7 +47,6 @@ class Main: # Construct function def __init__(self): self.load_screens() - self.get_screens_infos() locale.setlocale(locale.LC_ALL, '') self.d.set_background_title(title + ", version " + version) self.main() @@ -70,22 +70,23 @@ class Main: # Get infos on screens def get_screens_infos(self): config = {} + m_done = [] for name, klass in self.modules.items(): print("Reading "+ name +" module ... ", end="") klass = klass() config = klass.init(self.d, self.conf_lst) - self.screens.append(klass) + self.screens.insert(config["id"], klass) print("Done !") def main(self): - id = 0 + nm = 0 t_id = 0 while 1: - t_id = self.screens[id].main() - if (t_id == -2 or (t_id == -1 and id == 0)): + t_id = self.screens[nm].main() + if (t_id == -2): return 0 - elif (t_id != id): - id = t_id + elif (t_id != nm): + nm = t_id main = Main() diff --git a/screens/conf_install/__init__.py b/screens/conf_install/__init__.py diff --git a/screens/conf_install/conf_install.py b/screens/conf_install/conf_install.py @@ -0,0 +1,81 @@ +################################### LICENSE #################################### +# Copyright 2016 Morphux # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + +## +# conf_install.py +# Created: 15/11/2016 +# By: Louis Solofrizzo <louis@morphux.org> +## + +class Conf_Install: + +## +# Variables +## + + dlg = 0 + conf_lst = {} + +## +# Functions +## + def init(self, dialog, config_list): + self.dlg = dialog + self.conf_lst = config_list + self.config = { + "id": 1, + "name": "Installation" + } + return self.config + + def main(self): + if (self.hostname()): + return 0 + if (self.root_password()): + return 0 + return 2 + + def hostname(self): + string = "" + while string == "": + code, string = self.dlg.inputbox("Please enter your hostname:") + if (string == "" and code != "cancel"): + self.dlg.msgbox("Cannot be blank") + elif (code == "cancel"): + return 1 + return 0 + + def root_password(self): + string = "" + pass1 = "" + while string == "": + code, string = self.dlg.passwordbox("Please enter you root password:", insecure=True) + if (string == "" and code != "cancel"): + self.dlg.msgbox("Cannot be blank") + elif (code == "cancel"): + return 1 + pass1 = string + string = "" + while string == "": + code, string = self.dlg.passwordbox("Please re-enter you root password:", insecure=True) + if (string == "" and code != "cancel"): + self.dlg.msgbox("Cannot be blank") + elif (code == "cancel"): + return 1 + if (pass1 != string): + self.dlg.msgbox("Passwords do not match.") + return self.root_password() + return 0 diff --git a/screens/main_menu/main_menu.py b/screens/main_menu/main_menu.py @@ -84,7 +84,7 @@ For more information about the menu entries, See <Help> button"; self.dlg.msgbox(self.choices_ref[tag]["help"]) return 0 elif (code == "cancel"): - return -1 + return -2 else: return self.choices_ref[tag]["t_id"]