Addes more logging

Adjusted the logging messages

Signed-off-by: debianpepper <pdpdebdevuan@protonmail.com>
This commit is contained in:
debianpepper 2023-09-06 22:24:42 +09:00
parent 7d23b76d47
commit 922ce07e6e
2 changed files with 55 additions and 40 deletions

View File

@ -102,7 +102,7 @@ XFCE_LIST = ('xfce4\n'
'plank\n'
'mugshot\n'
'menulibre\n'
'marwaita-for-xfwm'
#'marwaita-for-xfwm'
)

View File

@ -11,6 +11,7 @@ import os
import collections
from pathlib import Path
import shutil
import logging
@ -23,6 +24,18 @@ BOOTSTRAP = "/fusato/config/includes.bootstrap"
FUSATOCONFIG = "/fusato/config"
term_size = os.get_terminal_size()
# Set up the logging format
logger = logging.getLogger()
handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)
MSG_COPY = "Copying - "
MSG_FIN = "Finished - "
class ChrootFolders:
"""
Copy all the needed folders to CHROOT Depending on
@ -30,7 +43,7 @@ class ChrootFolders:
"""
def __init__(self,sbase,sarch):
print('=' * term_size.columns)
print("Copy Chroot")
logger.info("Copy Chroot")
print('=' * term_size.columns)
self.sbase = sbase
self.sarch = sarch
@ -54,12 +67,12 @@ class ChrootFolders:
for size_length in range(chroot_size_q):
source = chroot_src_q.popleft()
des = chroot_des_q.popleft()
print("INFO: Copying - " + HOME_FOLDER + source)
logger.info(MSG_COPY + HOME_FOLDER + source)
shutil.copytree(HOME_FOLDER + source,
HOME_FOLDER + WPCHROOT + des,
dirs_exist_ok = True
)
print("INFO: Finished - " + HOME_FOLDER + WPCHROOT + des)
logger.info(MSG_FIN + HOME_FOLDER + WPCHROOT + des)
@ -70,7 +83,7 @@ class BinaryFolders:
"""
def __init__(self, sbase, sarch):
print('=' * term_size.columns)
print("Copy Binary")
logger.info("Copy Binary")
print('=' * term_size.columns)
self.sbase = sbase
self.sarch = sarch
@ -93,12 +106,12 @@ class BinaryFolders:
for size_length in range(binary_size_q):
source = binary_src_q.popleft()
des = binary_des_q.popleft()
print("INFO: Copying - " + HOME_FOLDER + source)
logger.info(MSG_COPY+ HOME_FOLDER + source)
shutil.copytree(HOME_FOLDER + source,
HOME_FOLDER + BINARYPTH + des,
dirs_exist_ok = True
)
print("INFO: Finished - " + HOME_FOLDER + BINARYPTH + des)
logger.info(MSG_FIN + HOME_FOLDER + BINARYPTH + des)
class ArchitectureFiles:
@ -108,7 +121,7 @@ class ArchitectureFiles:
"""
def __init__(self, sbase, sarch):
print('=' * term_size.columns)
print("Copy Architecture")
logger.info("Copy Architecture")
print('=' * term_size.columns)
self.sbase = sbase
self.sarch = sarch
@ -143,11 +156,11 @@ class ArchitectureFiles:
for size_length in range(size_q):
source = src_q.popleft()
des = des_q.popleft()
print("INFO: Copying - " + HOME_FOLDER + source)
logger.info(MSG_COPY+ HOME_FOLDER + source)
shutil.copy(HOME_FOLDER + source,
HOME_FOLDER + WPCHROOT + des
)
print("INFO: Finished - " + HOME_FOLDER + WPCHROOT + des)
logger.info(MSG_FIN + HOME_FOLDER + WPCHROOT + des)
def set_symlinks():
@ -155,20 +168,20 @@ def set_symlinks():
Set the symliknks that are used for all builds.
"""
print('=' * term_size.columns)
print("Copy symlinks")
logger.info("Copy Symlinks")
print('=' * term_size.columns)
pep_info = '/usr/share/python-apt/templates/Peppermint.info'
pep_mirror = '/usr/share/python-apt/templates/Peppermint.mirrors'
pep_csv = '/usr/share/distro-info/peppermint.csv'
print("INFO: Making - " + HOME_FOLDER + WPCHROOT + pep_info)
logger.info("Making - " + HOME_FOLDER + WPCHROOT + pep_info)
os.symlink('Debian.info', HOME_FOLDER + WPCHROOT + pep_info)
print("INFO: Finished - " + HOME_FOLDER + WPCHROOT + pep_info)
print("INFO: Making - " + HOME_FOLDER + WPCHROOT + pep_mirror)
logger.info(MSG_FIN + HOME_FOLDER + WPCHROOT + pep_info)
logger.info("Making - " + HOME_FOLDER + WPCHROOT + pep_mirror)
os.symlink('Debian.mirrors', HOME_FOLDER + WPCHROOT + pep_mirror)
print("INFO: Finished - " + HOME_FOLDER + WPCHROOT + pep_mirror)
print("INFO: Making - " + HOME_FOLDER + WPCHROOT + pep_csv)
logger.info(MSG_FIN + HOME_FOLDER + WPCHROOT + pep_mirror)
logger.info("Making - " + HOME_FOLDER + WPCHROOT + pep_csv)
os.symlink('debian.csv', HOME_FOLDER + WPCHROOT + pep_csv)
print("INFO: Finished - " + HOME_FOLDER + WPCHROOT + pep_csv)
logger.info(MSG_FIN + HOME_FOLDER + WPCHROOT + pep_csv)
def shared_folders():
@ -177,7 +190,7 @@ def shared_folders():
all the builds,
"""
print('=' * term_size.columns)
print("Copy Shared folders")
logger.info("Copy Shared folders")
print('=' * term_size.columns)
src_paths = ('/plymouth/lines',
'/application',
@ -223,12 +236,12 @@ def shared_folders():
for size_length in range(size_q):
source = src_q.popleft()
des = des_q.popleft()
print("INFO: Copying - " + HOME_FOLDER + source)
logger.info(MSG_COPY+ HOME_FOLDER + source)
shutil.copytree(HOME_FOLDER + source,
HOME_FOLDER + WPCHROOT + des,
dirs_exist_ok = True
)
print("INFO: Finished - " + HOME_FOLDER + WPCHROOT + des)
logger.info(MSG_FIN + HOME_FOLDER + WPCHROOT + des)
def icons_themes():
@ -237,7 +250,7 @@ def icons_themes():
for all the builds
"""
print('=' * term_size.columns)
print("Copy icons and themes")
logger.info("Copy icons and themes")
print('=' * term_size.columns)
src_paths =('/theme/Marwaita Dark Debian/',
'/theme/Marwaita Dark Manjaro/',
@ -275,12 +288,12 @@ def icons_themes():
for size_length in range(size_q):
source = src_q.popleft()
des = des_q.popleft()
print("INFO: Copying - " + HOME_FOLDER + source)
logger.info(MSG_COPY+ HOME_FOLDER + source)
shutil.copytree(HOME_FOLDER + source,
HOME_FOLDER + WPCHROOT + des,
dirs_exist_ok = True
)
print("INFO: Finished - " + HOME_FOLDER + WPCHROOT + des)
logger.info(MSG_FIN + HOME_FOLDER + WPCHROOT + des)
@ -291,7 +304,7 @@ def shared_files():
builds.
"""
print('=' * term_size.columns)
print("Copy Shared Files")
logger.info("Copy Shared Files")
print('=' * term_size.columns)
src_paths = ('/aliases/bash_aliases',
'/sources/peppermint.list',
@ -321,11 +334,11 @@ def shared_files():
for size_length in range(size_q):
source = src_q.popleft()
des = des_q.popleft()
print("INFO: Copying - " + HOME_FOLDER + source)
logger.info(MSG_COPY+ HOME_FOLDER + source)
shutil.copy(HOME_FOLDER + source,
HOME_FOLDER + WPCHROOT + des
)
print("INFO: Finished - " + HOME_FOLDER + WPCHROOT + des)
logger.info(MSG_FIN + HOME_FOLDER + WPCHROOT + des)
def fusato_configs():
@ -333,7 +346,7 @@ def fusato_configs():
Copy specific folders in the root of fusato configs
"""
print('=' * term_size.columns)
print("Copy Fusato Configs")
logger.info("Copy Fusato Configs")
print('=' * term_size.columns)
src_paths = ('/hooks/normal',)
des_paths = ('/hooks/normal',)
@ -343,12 +356,12 @@ def fusato_configs():
for size_length in range(size_q):
source = src_q.popleft()
des = des_q.popleft()
print("INFO: Copying - " + HOME_FOLDER + source)
logger.info(MSG_COPY+ HOME_FOLDER + source)
shutil.copytree(HOME_FOLDER + source,
HOME_FOLDER + FUSATOCONFIG + des,
dirs_exist_ok = True
)
print("INFO: Finished - " + HOME_FOLDER + WPCHROOT + des)
logger.info(MSG_FIN + HOME_FOLDER + WPCHROOT + des)
def boostrap_shared():
@ -356,7 +369,7 @@ def boostrap_shared():
Copy specific folders in the boostrap location
"""
print('=' * term_size.columns)
print("Copy Shared BootStrap")
logger.info("Copy Shared BootStrap")
print('=' * term_size.columns)
src_paths = ('/issue',)
des_paths = ('/etc',)
@ -366,12 +379,12 @@ def boostrap_shared():
for size_length in range(size_q):
source = src_q.popleft()
des = des_q.popleft()
print("INFO: Copying - " + HOME_FOLDER + source)
logger.info(MSG_COPY+ HOME_FOLDER + source)
shutil.copytree(HOME_FOLDER + source,
HOME_FOLDER + BOOTSTRAP + des,
dirs_exist_ok = True
)
print("INFO: Finished - " + HOME_FOLDER + WPCHROOT + des)
logger.info(MSG_FIN + HOME_FOLDER + WPCHROOT + des)
def xfce_configs():
@ -379,24 +392,24 @@ def xfce_configs():
Copy the xfce files.
"""
print('=' * term_size.columns)
print("Copy xfce4 configs")
logger.info("Copy xfce4 configs")
print('=' * term_size.columns)
src_xfce = '/xfce/xfce4'
des_xfce = '/etc/skel/.config/xfce4'
print("INFO: Copying - " + HOME_FOLDER + src_xfce)
logger.info(MSG_COPY + HOME_FOLDER + src_xfce)
shutil.copytree(HOME_FOLDER + src_xfce,
HOME_FOLDER + WPCHROOT + des_xfce,
dirs_exist_ok = True
)
print("INFO: Finished - " + HOME_FOLDER + WPCHROOT + des_xfce)
logger.info(MSG_FIN + HOME_FOLDER + WPCHROOT + des_xfce)
src_thunar = '/xfce/Thunar'
des_thunar = '/etc/skel/.config/Thunar'
print("INFO: Copying - " + HOME_FOLDER + src_thunar)
logger.info(MSG_COPY+ HOME_FOLDER + src_thunar)
shutil.copytree(HOME_FOLDER + src_thunar,
HOME_FOLDER + WPCHROOT + des_thunar,
dirs_exist_ok = True
)
print("INFO: Finished - " + HOME_FOLDER + WPCHROOT + des_thunar)
logger.info(MSG_FIN + HOME_FOLDER + WPCHROOT + des_thunar)
def gnome_flahsbak_configs():
@ -404,12 +417,14 @@ def gnome_flahsbak_configs():
Copy the gnome flashback files
"""
print('=' * term_size.columns)
print("Copy Gnome Flashback configs")
logger.info("Copy Gnome Flashback configs")
src_gnomef = '/gnome-flashback'
des_gnomef = '/etc/skel/.config'
print("INFO: Copying - " + HOME_FOLDER + src_gnomef)
logger.info("INFO: Copying - " + HOME_FOLDER + src_gnomef)
shutil.copytree(HOME_FOLDER + src_gnomef,
HOME_FOLDER + WPCHROOT + des_gnomef,
dirs_exist_ok = True
)
print("INFO: Finished - " + HOME_FOLDER + WPCHROOT + des_gnomef)
logger.info(MSG_FIN + HOME_FOLDER + WPCHROOT + des_gnomef, e)
logger.info(CFG_TREE_READY)