From 20ad513fae3197b7ddd4831ca9606b921d187429 Mon Sep 17 00:00:00 2001 From: "Jeison Yehuda Amihud (Blender Dumbass)" Date: Mon, 17 May 2021 13:43:23 +0000 Subject: [PATCH] Implementing BASIC AUTOFIX --- troubleshooter/fix.py | 80 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/troubleshooter/fix.py b/troubleshooter/fix.py index f581d0d..f748af3 100644 --- a/troubleshooter/fix.py +++ b/troubleshooter/fix.py @@ -31,7 +31,81 @@ def output(form, text=""): def autofix(Modules): - print("Autofix not yet implemented") - print("We need testing to implement it") - print("Please contact us. https://github.com/JYamihud/VCStudio/issues") + output("\033[1;41m", "Autofix will try to install") + output("\033[1;41m", "all missing modules. Some may") + output("\033[1;41m", "request a sudo password.") + print("\033[1;m") + print("Press ENTER to continue") input() + + print("\033[1;43m") + + # Let's install the GI repository. ( Grpahical Interface ) + # This is going to be different depending on the system + # for more info look at https://pygobject.readthedocs.io/en/latest/getting_started.html + + system = "debian" + + import platform + ostype = platform.system() + if ostype == "Linux": + + print("Select GNU / Linux fork: debian, arch, fedora, opensuse\033[1;m") + system = input(": ") + + + command = "sudo apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0" + if system == "arch": + command = "sudo pacman -S python cairo pkgconf gobject-introspection gtk3" + elif system == "fedora": + command = "sudo dnf install gcc gobject-introspection-devel cairo-devel pkg-config python3-devel gtk3" + elif system == "opensuse": + command = "sudo zypper install cairo-devel pkg-config python3-devel gcc gobject-introspection-devel" + elif system == "debian": + pass + + else: + # If not any of them + print("You are running an unknown GNU / Linux distro.") + print("Please refer to: https://pygobject.readthedocs.io/en/latest/getting_started.html") + print("Autofix can't help you here.") + + print("\033[1;43m") + print("Executing:", command , "\033[1;m") + os.system(command) + + print("\033[1;43m") + command = "python3 -m pip install pycairo" + print("Executing:", command , "\033[1;m") + os.system(command) + + print("\033[1;43m") + command = "python3 -m pip install PyGObject" + print("Executing:", command , "\033[1;m") + os.system(command) + + + + else: + # If it's not linux. + print("You are running non a GNU / Linux distro.") + print("Please refer to: https://pygobject.readthedocs.io/en/latest/getting_started.html") + print("Autofix can't help you here.") + + # Let's install the PIL module + + print("\033[1;43m") + command = "python3 -m pip install Pillow" + print("Executing:", command , "\033[1;m") + os.system(command) + + output("\033[1;42m", "Done!") + print("\033[1;m") + print("If any issues are still there. Please report them to:") + print("https://notabug.org/jyamihud/VCStudio/issues") + print("\033[1;m") + print("Press ENTER to continue") + input() + + import sys + os.execl(sys.executable, sys.executable, *sys.argv)