install

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

commit cf6c31eee12bd55f226af053bddf055193442b95
parent eaa3dd06aac38b075e84ae77a7eea25a2b962f94
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Fri, 25 Nov 2016 19:22:35 +0100

New(Pkgs install): First draft on package installation:

Test working, list working, init working
Need to work on the installation process.

Diffstat:
Mmain.py | 3+--
Apkgs/__init__.py | 0
Apkgs/test/__init__.py | 0
Apkgs/test/test.py | 45+++++++++++++++++++++++++++++++++++++++++++++
Mscreens/install/install.py | 40++++++++++++++++++++++++++++++++++++++--
5 files changed, 84 insertions(+), 4 deletions(-)

diff --git a/main.py b/main.py @@ -73,7 +73,6 @@ class Main: # Get infos on screens, Initialize the instances def get_screens_infos(self): config = {} - m_done = [] for name, klass in self.modules.items(): print("Reading "+ name +" module ... ", end="") klass = klass() @@ -81,7 +80,7 @@ class Main: config = klass.init(self.d, self.conf_lst) # Stocking the return of init() in an object self.screens[config["id"]] = [klass, config] - print("Done !") + print("\tDone !") # Main loop function def main(self): diff --git a/pkgs/__init__.py b/pkgs/__init__.py diff --git a/pkgs/test/__init__.py b/pkgs/test/__init__.py diff --git a/pkgs/test/test.py b/pkgs/test/test.py @@ -0,0 +1,45 @@ +################################### 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. # +################################################################################ + +## +# test.py +# Created: 25/11/2016 +# By: Louis Solofrizzo <louis@morphux.org> +## + +# This a temporary file, here in order to test the install process. + +class Test: + + conf_lst = {} + + def init(self, c_lst): + self.conf_lst = c_lst + self.config = { + "name": "test", # Name of the package + "version": "1.0", # Version of the package + "size": 100, # Size of the installed package + "archive": "test-1.0.tar.gz", # Archive name + "cheksum": "", # Checksum of the archive + "SBU": 1, # SBU (Compilation time) + "tmp_install": False, # Is this package part of the temporary install + "next": "test2", # Next package to install + "urls": [ # Url to download the package. The first one must be morphux servers + "http://url1.com/", + "http://url2.com/", + ] + } + return self.config diff --git a/screens/install/install.py b/screens/install/install.py @@ -21,6 +21,7 @@ ## import json +import os class Install: @@ -30,6 +31,8 @@ class Install: dlg = 0 # Dialog object conf_lst = {} # List object for configuration + modules = {} # Module object + pkgs = {} # Packages instances ## # Functions @@ -46,12 +49,45 @@ class Install: return self.config # main function, called by Main instance - def main(self, Main): + 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": + # Open the file, then dump json in it. with open("morphux_install.conf", "w") as fd: json.dump(self.conf_lst, fd) - print(self.conf_lst) + + # Load packages files + self.load_pkgs() + + # Load all the packages configuration files + # path: Default to ./pkgs + def load_pkgs(self, path = "pkgs"): + res = {} + lst = os.listdir(path) + dir = [] + # List the entries in screens/ and check if the file __init__.py is here + for d in lst: + s = os.path.abspath(path) + os.sep + d + if os.path.isdir(s) and os.path.exists(s + os.sep + "__init__.py"): + dir.append(d) + # Import the good files, in order to load them + for d in dir: + res[d] = __import__(path + "." + d + "." + d, fromlist = ["*"]) + res[d] = getattr(res[d], d.title()) + self.modules = res + self.get_pkg_info() + + # Get information about each package, and instanciate them + def get_pkg_info(self): + config = {} + for name, klass in self.modules.items(): + print("Reading info on "+ name +" ...", end="") + klass = klass() + # Calling the init function of each package + config = klass.init(self.conf_lst) + # Saving the configuration of the object + self.pkgs[config["name"]] = [klass, config] + print("\tDone !")