fix.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # THIS FILE IS A PART OF VCStudio
  2. # PYTHON 3
  3. import os
  4. w, h = os.get_terminal_size()
  5. from settings import settings
  6. from settings import talk
  7. def cls():
  8. #cleaning the terminal
  9. os.system("clear")
  10. global w
  11. global h
  12. w, h = os.get_terminal_size()
  13. if (w % 2) == 0:
  14. w = w - 1
  15. def output(form, text=""):
  16. #Basically a fancy print() function
  17. while len(text) < w:
  18. text = text + " "
  19. print(form + text)
  20. def autofix(Modules):
  21. output("\033[1;41m", "Autofix will try to install")
  22. output("\033[1;41m", "all missing modules. Some may")
  23. output("\033[1;41m", "request a sudo password.")
  24. print("\033[1;m")
  25. print("Press ENTER to continue")
  26. input()
  27. print("\033[1;43m")
  28. # Let's install the GI repository. ( Grpahical Interface )
  29. # This is going to be different depending on the system
  30. # for more info look at https://pygobject.readthedocs.io/en/latest/getting_started.html
  31. system = "debian"
  32. import platform
  33. ostype = platform.system()
  34. if ostype == "Linux":
  35. print("Select GNU / Linux fork: debian, arch, fedora, opensuse\033[1;m")
  36. system = input(": ")
  37. command = "sudo apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0"
  38. if system == "arch":
  39. command = "sudo pacman -S python cairo pkgconf gobject-introspection gtk3"
  40. elif system == "fedora":
  41. command = "sudo dnf install gcc gobject-introspection-devel cairo-devel pkg-config python3-devel gtk3"
  42. elif system == "opensuse":
  43. command = "sudo zypper install cairo-devel pkg-config python3-devel gcc gobject-introspection-devel"
  44. elif system == "debian":
  45. pass
  46. else:
  47. # If not any of them
  48. print("You are running an unknown GNU / Linux distro.")
  49. print("Please refer to: https://pygobject.readthedocs.io/en/latest/getting_started.html")
  50. print("Autofix can't help you here.")
  51. print("\033[1;43m")
  52. print("Executing:", command , "\033[1;m")
  53. os.system(command)
  54. print("\033[1;43m")
  55. command = "python3 -m pip install pycairo"
  56. print("Executing:", command , "\033[1;m")
  57. os.system(command)
  58. print("\033[1;43m")
  59. command = "python3 -m pip install PyGObject"
  60. print("Executing:", command , "\033[1;m")
  61. os.system(command)
  62. elif ostype == "Darwin": # MacOS
  63. print("\033[1;43m")
  64. command = "brew install pygobject3 gtk+3"
  65. print("Executing:", command , "\033[1;m")
  66. os.system(command)
  67. else:
  68. # If it's not linux.
  69. print("You are running non a GNU / Linux distro.")
  70. print("Please refer to: https://pygobject.readthedocs.io/en/latest/getting_started.html")
  71. print("Autofix can't help you here.")
  72. # Let's install the PIL module
  73. print("\033[1;43m")
  74. command = "python3 -m pip install Pillow"
  75. print("Executing:", command , "\033[1;m")
  76. os.system(command)
  77. output("\033[1;42m", "Done!")
  78. print("\033[1;m")
  79. print("If any issues are still there. Please report them to:")
  80. print("https://notabug.org/jyamihud/VCStudio/issues")
  81. print("\033[1;m")
  82. print("Press ENTER to continue")
  83. input()
  84. import sys
  85. os.execl(sys.executable, sys.executable, *sys.argv)