rewrite of data.config parser to add headers and flatpak

This commit is contained in:
acidburnmonkey
2024-11-23 12:57:22 -05:00
parent 304ce15bdb
commit a67b4055cd
3 changed files with 58 additions and 16 deletions
+2 -2
View File
@@ -19,7 +19,7 @@ This is a python script made to rice a blank fedora install into my custom hyprl
* Hyrland * Hyrland
* hyprcursor ,hypridle, hyprlang, hyprloc, hyprpaper, hyprpicker, hyprutils * hyprcursor ,hypridle, hyprlang, hyprloc, hyprpaper, hyprpicker, hyprutils
* Waybar * Waybar
* Finally installs all programs given in data.txt * Finally installs all programs given in data.config
________________________________________________________________________________ ________________________________________________________________________________
@@ -54,7 +54,7 @@ Should look like this .
|---nvim |---nvim
|---ranger |---ranger
|---etc... |---etc...
|---data.txt |---data.config
|---rice-cook.py |---rice-cook.py
``` ```
+11 -7
View File
@@ -1,3 +1,4 @@
[Main]
hyprland hyprland
hyprcursor hyprcursor
hypridle hypridle
@@ -15,19 +16,22 @@ flatpak
neovim neovim
zsh zsh
pavucontrol pavucontrol
picom
alsa-tools alsa-tools
dunst dunst
feh feh
alsa-utils
rofi
mozilla-openh
pamixer
pavucontrol
network-manager-applet
[other-programs]
gnome-font-viewer gnome-font-viewer
gnome-software gnome-software
kitty kitty
ranger ranger
gnome-software gnome-software
alsa-utils
rofi
mozilla-openh
nemo nemo
pamixer
pavucontrol [Flatpak]
network-manager-applet
+42 -4
View File
@@ -147,17 +147,48 @@ Type=Application ''')
console.print('Created hyprland .desktop and wrappedhl :heavy_check_mark:', style='ok') console.print('Created hyprland .desktop and wrappedhl :heavy_check_mark:', style='ok')
# install programs dnfmax list i can pass to dnf of programs to install # install programs dnf
def install_programs_dnf(): def install_programs_dnf():
console.rule("Installing All Programs DNF ", style='checkt') console.rule("Installing All Programs DNF ", style='checkt')
programs =[] programs =[]
with open("data.txt", 'r') as file: others = []
for line in file: flatpaks= []
with open("data.config", 'r') as file:
lines = file.readlines()
# Variables to store line numbers of headers
main_index = 0
others_index = 0
flatpak_index = 0
# Find the line numbers of headers
for index, line in enumerate(lines):
if '[Main]' in line:
main_index = index
elif '[other-programs]' in line:
others_index = index
elif '[Flatpak]' in line:
flatpak_index = index
file.seek(0)
for index,line in enumerate(file):
#empty strings
if not line.strip():
continue
elif index < others_index and ('[' not in line):
programs.append(line.strip()) programs.append(line.strip())
elif index > others_index and index < flatpak_index:
others.append(line.strip())
elif index > flatpak_index:
flatpaks.append(line.strip())
elif '[' in line.strip():
continue
#for some reason they have to be passed to dnf individually #for some reason they have to be passed to dnf individually
# instead of unpacked list *programs # instead of unpacked list *programs
programs.extend(others)
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)
@@ -165,7 +196,14 @@ def install_programs_dnf():
console.print(Exception(),":x:" , style='error') console.print(Exception(),":x:" , style='error')
logging.critical(f"Error at Installing programs: {str(e)}") logging.critical(f"Error at Installing programs: {str(e)}")
logger.info('Installed programs in data.txt') for fp in flatpaks:
try:
subprocess.run(f'flatpak install flathub -y {fp}', shell=True)
except Exception as e:
console.print(Exception(),":x:" , style='error')
logging.critical(f"Error at Installing flatpaks: {str(e)}")
logger.info('Installed programs in data.config')
## checks for sudo ## checks for sudo