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
* hyprcursor ,hypridle, hyprlang, hyprloc, hyprpaper, hyprpicker, hyprutils
* 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
|---ranger
|---etc...
|---data.txt
|---data.config
|---rice-cook.py
```
+11 -7
View File
@@ -1,3 +1,4 @@
[Main]
hyprland
hyprcursor
hypridle
@@ -15,19 +16,22 @@ flatpak
neovim
zsh
pavucontrol
picom
alsa-tools
dunst
feh
alsa-utils
rofi
mozilla-openh
pamixer
pavucontrol
network-manager-applet
[other-programs]
gnome-font-viewer
gnome-software
kitty
ranger
gnome-software
alsa-utils
rofi
mozilla-openh
nemo
pamixer
pavucontrol
network-manager-applet
[Flatpak]
+42 -4
View File
@@ -147,17 +147,48 @@ Type=Application ''')
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():
console.rule("Installing All Programs DNF ", style='checkt')
programs =[]
with open("data.txt", 'r') as file:
for line in file:
others = []
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())
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
# instead of unpacked list *programs
programs.extend(others)
for program in programs:
try:
subprocess.run(f'dnf install -y {program} ', shell=True)
@@ -165,7 +196,14 @@ def install_programs_dnf():
console.print(Exception(),":x:" , style='error')
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