added loggin ( untested )

This commit is contained in:
acidburn
2023-04-25 22:59:05 -04:00
parent 837f302dd8
commit 9abd2d6cac
+26 -10
View File
@@ -5,11 +5,17 @@ import re
import subprocess import subprocess
import importlib import importlib
import requests import requests
import logging
from rich.console import Console from rich.console import Console
from rich.progress import Progress from rich.progress import Progress
from rich.theme import Theme from rich.theme import Theme
logging.basicConfig(
format="%(asctime)s | %(levelno)s | %(funcName)s| %(message)s ",
filename='installer.log'
)
ap_theme = Theme({'ok':'green', 'error':'red', 'checkt':'bold cyan','promp':'orange1'}) ap_theme = Theme({'ok':'green', 'error':'red', 'checkt':'bold cyan','promp':'orange1'})
console = Console(theme=ap_theme) console = Console(theme=ap_theme)
@@ -20,12 +26,12 @@ def main():
#set temporary resolution for sesion #set temporary resolution for sesion
user_answer = input("Set resolution 1920x1080? y/n: ").lower() user_answer = input("Set resolution 1920x1080? y/n: ").lower()
console.print("run aranddr to proper set up", style='ok') console.print("Run aranddr to proper set up", style='ok')
try: try:
if user_answer == 'y': if user_answer == 'y':
os.system('xrandr -s 1920x1080') os.system('xrandr -s 1920x1080')
except Exception(): except Exception as e:
print(Exception()) logging.critical(f"Error at xrandr: {str(e)}")
console.print('optimizing dnf.conf', style='ok') console.print('optimizing dnf.conf', style='ok')
dnf_config() dnf_config()
@@ -44,11 +50,16 @@ def main():
copy_dotfiles(setup) copy_dotfiles(setup)
break break
executable_scripts()
msic_configs()
################
#END OF MAIN # END OF MAIN #
################
def dnf_config(): def dnf_config():
console.rule("Configuring dnf", style='checkt')
# dnf conf # dnf conf
with open('/etc/dnf/dnf.conf' , 'r+') as f: with open('/etc/dnf/dnf.conf' , 'r+') as f:
text = 'max_parallel_downloads=10 \nfastestmirror=true' text = 'max_parallel_downloads=10 \nfastestmirror=true'
@@ -79,8 +90,9 @@ def install_programs_dnf():
for program in programs: for program in programs:
try: try:
subprocess.run(f'dnf install -y {program} ', shell=True) subprocess.run(f'dnf install -y {program} ', shell=True)
except: except Exception as e:
console.print(Exception(),":x:" , style='error') console.print(Exception(),":x:" , style='error')
logging.critical(f"Error at Installing programs: {str(e)}")
@@ -189,15 +201,19 @@ def copy_dotfiles(setup):
def executable_scripts(): def executable_scripts():
console.rule('Making scripts executable', style=checkt)
home = os.path.expanduser("~") home = os.path.expanduser("~")
for root ,b,files in os.walk(os.path.join(home,'.config')): for root ,_,files in os.walk(os.path.join(home,'.config')):
for element in files: for element in files:
if '.sh' in element or '.py' in element: if '.sh' in element or '.py' in element:
try: try:
subprocess.run(f"chmod +x {os.path.join(root,element)}", shell=True) subprocess.run(f"chmod +x {os.path.join(root,element)}", shell=True)
except Exception(): except Exception as e:
print(Exception()) logging.critical(f"Error at executable_scripts: {str(e)}")
def msic_configs():
pass
if __name__ == '__main__': if __name__ == '__main__':