install

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

commit 797b19da4a911a07bb2ec81a14475759655ad2a4
parent 17e2cf7311f14f0a3e6645c2071b80cb38cc685d
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Fri, 25 Nov 2016 18:37:53 +0100

Add(Configuration Saving & Loading):

Now saving configuration
Now proposing to load configuration if found at Install

Diffstat:
Mmain.py | 6+++---
Mscreens/conf_install/conf_install.py | 24+++++++++++++++++++++++-
Mscreens/install/install.py | 12++++++++++--
Mscreens/load_conf/load_conf.py | 2+-
Mscreens/main_menu/main_menu.py | 2+-
Mscreens/options/options.py | 2+-
Mscreens/shell/shell.py | 2+-
7 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/main.py b/main.py @@ -88,9 +88,9 @@ class Main: nm = 0 t_id = 0 while 1: - print(self.conf_lst) - print(self.screens) - t_id = self.screens[nm][0].main() + #print(self.screens) + self.screens[nm][0].conf_lst = self.conf_lst + t_id = self.screens[nm][0].main(self) # If the function return -2, a really bad things happened if (t_id == -2): return 0 diff --git a/screens/conf_install/conf_install.py b/screens/conf_install/conf_install.py @@ -22,6 +22,7 @@ import subprocess import os +import json class Conf_Install: @@ -100,7 +101,28 @@ class Conf_Install: return self.config # main function, called by Main instance - def main(self): + def main(self, Main): + + # Check if we got a configuration file + if os.path.isfile("morphux_install.conf"): + code = self.dlg.yesno("We found a configuration file.\nUse it ?") + if code == "ok": + # Load the json into an object + with open("morphux_install.conf") as fd: + self.conf_lst = json.load(fd) + # Check the configuration integrity + if self.check_conf(): + # Save this in order not to ask the configuration + # saving in the installation process + self.conf_lst["load_conf"] = True + Main.conf_lst = self.conf_lst + return 6 + # If the configuration is wrong, we return the user + # to the step_by_step menu + else: + return self.step_by_step() + + # Since hostname is the first configuration to do, if the user # hit 'cancel' we return him to the Main Menu, not the step-by-step if (self.hostname()): diff --git a/screens/install/install.py b/screens/install/install.py @@ -20,6 +20,8 @@ # By: Louis Solofrizzo <louis@morphux.org> ## +import json + class Install: ## @@ -44,5 +46,11 @@ class Install: return self.config # main function, called by Main instance - def main(self): - self.dlg.msgbox("Hey there !") + def main(self, Main): + # The current configuration is already loaded from a file, no + # reason to re-save it. + if "load_conf" not in self.conf_lst: + code = self.dlg.yesno("Do you want to save your current configuration ?") + if code == "ok": + with open("morphux_install.conf", "w") as fd: + json.dump(self.conf_lst, fd) diff --git a/screens/load_conf/load_conf.py b/screens/load_conf/load_conf.py @@ -45,7 +45,7 @@ class Load_Conf: # main function, called by Main instance # The second parameter, d_path is the default starting path - def main(self, d_path = "/"): + def main(self, Main, d_path = "/"): # Call to the file selection dialog box code, path = self.dlg.fselect(d_path, height=20, width=60, title="Select the configuration file") diff --git a/screens/main_menu/main_menu.py b/screens/main_menu/main_menu.py @@ -91,7 +91,7 @@ For more information about the menu entries, See <Help> button"; return self.config # main function, called by Main instance - def main(self): + def main(self, Main): # Display the menu code, tag = self.dlg.menu(self.a_title, title="Main Menu", choices = self.choices, help_button=True) if (code == "ok" and tag == "Exit"): diff --git a/screens/options/options.py b/screens/options/options.py @@ -68,7 +68,7 @@ class Options: return self.config # main function, called by Main instance - def main(self): + def main(self, Main): res_opt = {} # Call the dialog checklist code, tag = self.dlg.checklist("Use Space to select options", choices = self.options, title="Options Menu") diff --git a/screens/shell/shell.py b/screens/shell/shell.py @@ -48,7 +48,7 @@ class Shell: return self.config # main function, called by Main instance - def main(self): + def main(self, Main): # Execute the binary /bin/sh # Note there is no error handling, nor output redirection. sh = Popen(['/bin/sh'])