From 08c2058f6113652b3149e11b4f08ed0a7f60a9d5 Mon Sep 17 00:00:00 2001 From: Vyvir <135277623+vyvir@users.noreply.github.com> Date: Fri, 23 Aug 2024 19:03:49 +0300 Subject: [PATCH] Update main.py --- main.py | 166 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/main.py b/main.py index 655916a..52e2302 100644 --- a/main.py +++ b/main.py @@ -40,11 +40,11 @@ computer_cpu_platform = platform.machine() def resource_path(relative_path): global installedcheck CheckRun10 = subprocess.run( - f"find /usr/lib/altlinux/altlinux > /dev/null 2>&1", shell=True + f"find /usr/lib/althea/althea > /dev/null 2>&1", shell=True ) if CheckRun10.returncode == 0: installedcheck = True - base_path = "/usr/lib/altlinux" + base_path = "/usr/lib/althea" else: base_path = os.path.abspath(".") return os.path.join(base_path, relative_path) @@ -63,14 +63,14 @@ Warnmsg = "warn" Failmsg = "fail" icon_name = "changes-prevent-symbolic" command_six = Gtk.CheckMenuItem(label="Launch at Login") -AltServer = "$HOME/.local/share/altlinux/AltServer" -AnisetteServer = "$HOME/.local/share/altlinux/anisette-server" -AltStore = "$HOME/.local/share/altlinux/AltStore.ipa" +AltServer = "$HOME/.local/share/althea/AltServer" +AnisetteServer = "$HOME/.local/share/althea/anisette-server" +AltStore = "$HOME/.local/share/althea/AltStore.ipa" PATH = AltStore AutoStart = resource_path("resources/AutoStart.sh") -altlinuxpath = os.path.join( +altheapath = os.path.join( os.environ.get("XDG_DATA_HOME") or f'{ os.environ["HOME"] }/.local/share', - "altlinux", + "althea", ) @@ -87,16 +87,16 @@ with open(resource_path("resources/version"), "r", encoding="utf-8") as f: LocalVersion = f.readline().strip() def main(): - GLib.set_prgname("AltLinux") # Sets the global program name - global altlinuxpath + GLib.set_prgname("althea") # Sets the global program name + global altheapath #global file_name - if not os.path.exists(altlinuxpath): # Creates $HOME/.local/share/altlinux - os.mkdir(altlinuxpath) + if not os.path.exists(altheapath): # Creates $HOME/.local/share/althea + os.mkdir(altheapath) if Gtk.StatusIcon.is_embedded: if connectioncheck(): global indicator indicator = appindicator.Indicator.new( - "altlinux-tray-icon", + "althea-tray-icon", resource_path("resources/1.png"), appindicator.IndicatorCategory.APPLICATION_STATUS, ) @@ -122,7 +122,7 @@ def menu(): menu.append(Gtk.SeparatorMenuItem()) - command_one = Gtk.MenuItem(label="About AltLinux") + command_one = Gtk.MenuItem(label="About althea") command_one.connect("activate", on_abtdlg) menu.append(command_one) @@ -146,18 +146,18 @@ def menu(): menu.append(Gtk.SeparatorMenuItem()) - CheckRun11 = subprocess.run(f"test -e /usr/lib/altlinux/altlinux", shell=True) + CheckRun11 = subprocess.run(f"test -e /usr/lib/althea/althea", shell=True) if CheckRun11.returncode == 0: global command_six CheckRun12 = subprocess.run( - f"test -e $HOME/.config/autostart/AltLinux.desktop", shell=True + f"test -e $HOME/.config/autostart/althea.desktop", shell=True ) if CheckRun12.returncode == 0: command_six.set_active(command_six) command_six.connect("activate", launchatlogin1) menu.append(command_six) - exittray = Gtk.MenuItem(label="Quit AltLinux") + exittray = Gtk.MenuItem(label="Quit althea") exittray.connect("activate", lambda x: quitit()) menu.append(exittray) @@ -173,7 +173,7 @@ def on_abtdlg(self): resource_path("resources/3.png"), width, height ) about.set_logo(pixbuf) - about.set_program_name("AltLinux") + about.set_program_name("althea") about.set_version("0.5.0") about.set_authors( [ @@ -186,7 +186,7 @@ def on_abtdlg(self): ) # , 'Provision made by', 'Dadoum']) about.set_artists(["nebula"]) about.set_comments("A GUI for AltServer-Linux written in Python.") - about.set_website("https://github.com/vyvir/AltLinux") + about.set_website("https://github.com/vyvir/althea") about.set_website_label("Github") about.set_copyright("GUI by vyvir") about.set_position(Gtk.WindowPosition.CENTER_ALWAYS) @@ -253,10 +253,10 @@ class SplashScreen(Handy.Window): image.show() self.mainBox.pack_start(image, False, True, 0) - self.lbl1 = Gtk.Label(label="Starting AltLinux...") + self.lbl1 = Gtk.Label(label="Starting althea...") self.mainBox.pack_start(self.lbl1, False, False, 6) - self.loadaltlinux = Gtk.ProgressBar() - self.mainBox.pack_start(self.loadaltlinux, True, True, 0) + self.loadalthea = Gtk.ProgressBar() + self.mainBox.pack_start(self.loadalthea, True, True, 0) self.t = threading.Thread(target=self.lol321actualfunction) self.t.start() self.wait_for_t(self.t) @@ -272,62 +272,62 @@ class SplashScreen(Handy.Window): def lol321actualfunction(self): self.lbl1.set_text("Checking if anisette-server is already running...") - self.loadaltlinux.set_fraction(0.1) + self.loadalthea.set_fraction(0.1) command = 'curl 127.0.0.1:6969 | grep -q "{"' CheckRun = subprocess.run(command, shell=True) - if not os.path.isfile(f"{(altlinuxpath)}/anisette-server"): + if not os.path.isfile(f"{(altheapath)}/anisette-server"): self.lbl1.set_text("Downloading anisette-server...") if computer_cpu_platform == 'x86_64': r = requests.get( - "https://github.com/vyvir/AltLinux/releases/download/v0.5.0/anisette-server-x86_64", + "https://github.com/vyvir/althea/releases/download/v0.5.0/anisette-server-x86_64", allow_redirects=True, ) elif computer_cpu_platform == "aarch64": #Thanks, Dadoum for the anisette server! #or vyvir, do not forget to upload ur version of server. r = requests.get( - "https://github.com/vyvir/AltLinux/releases/download/v0.5.0/anisette-server-aarch64", + "https://github.com/vyvir/althea/releases/download/v0.5.0/anisette-server-aarch64", allow_redirects=True ) #sorry i dont know what will arm32 output elif computer_cpu_platform.find('v7') != -1 or computer_cpu_platform.find('ARM') != -1 or computer_cpu_platform.find('hf') != -1: r = requests.get( - "https://github.com/vyvir/AltLinux/releases/download/v0.5.0/anisette-server-armv7", + "https://github.com/vyvir/althea/releases/download/v0.5.0/anisette-server-armv7", allow_redirects=True ) else: print('WARNING: YOUR CPU IS NOT SUPPORTED, THE PROGRAM MAY NOT WORK!') #ooops, just download x86-64 ver r = requests.get( - "https://github.com/vyvir/AltLinux/releases/download/v0.5.0/anisette-server-x86_64", + "https://github.com/vyvir/althea/releases/download/v0.5.0/anisette-server-x86_64", allow_redirects=True, ) - open(f"{(altlinuxpath)}/anisette-server", "wb").write(r.content) - subprocess.run(f"chmod +x {(altlinuxpath)}/anisette-server", shell=True) - subprocess.run(f"chmod 755 {(altlinuxpath)}/anisette-server", shell=True) - self.loadaltlinux.set_fraction(0.2) + open(f"{(altheapath)}/anisette-server", "wb").write(r.content) + subprocess.run(f"chmod +x {(altheapath)}/anisette-server", shell=True) + subprocess.run(f"chmod 755 {(altheapath)}/anisette-server", shell=True) + self.loadalthea.set_fraction(0.2) self.lbl1.set_text("Downloading Apple Music APK...") r = requests.get( "https://apps.mzstatic.com/content/android-apple-music-apk/applemusic.apk", allow_redirects=True, ) - open(f"{(altlinuxpath)}/am.apk", "wb").write(r.content) - os.makedirs(f"{(altlinuxpath)}/lib/x86_64") - self.loadaltlinux.set_fraction(0.3) + open(f"{(altheapath)}/am.apk", "wb").write(r.content) + os.makedirs(f"{(altheapath)}/lib/x86_64") + self.loadalthea.set_fraction(0.3) self.lbl1.set_text("Extracting necessary libraries...") CheckRunB = subprocess.run( - f'unzip -j "{(altlinuxpath)}/am.apk" "lib/x86_64/libstoreservicescore.so" -d "{(altlinuxpath)}/lib/x86_64"', + f'unzip -j "{(altheapath)}/am.apk" "lib/x86_64/libstoreservicescore.so" -d "{(altheapath)}/lib/x86_64"', shell=True, ) CheckRunC = subprocess.run( - f'unzip -j "{(altlinuxpath)}/am.apk" "lib/x86_64/libCoreADI.so" -d "{(altlinuxpath)}/lib/x86_64"', + f'unzip -j "{(altheapath)}/am.apk" "lib/x86_64/libCoreADI.so" -d "{(altheapath)}/lib/x86_64"', shell=True, ) - silentremove(f"{(altlinuxpath)}/am.apk") - self.loadaltlinux.set_fraction(0.4) + silentremove(f"{(altheapath)}/am.apk") + self.loadalthea.set_fraction(0.4) self.lbl1.set_text("Starting anisette-server...") - subprocess.run(f"cd {(altlinuxpath)} && ./anisette-server &", shell=True)#-n 127.0.0.1 -p 6969 &", shell=True - self.loadaltlinux.set_fraction(0.5) + subprocess.run(f"cd {(altheapath)} && ./anisette-server &", shell=True)#-n 127.0.0.1 -p 6969 &", shell=True + self.loadalthea.set_fraction(0.5) finished = False while not finished: CheckRun5 = subprocess.run(command, shell=True) @@ -335,9 +335,9 @@ class SplashScreen(Handy.Window): finished = True else: sleep(1) - if not os.path.isfile(f"{(altlinuxpath)}/AltServer"): + if not os.path.isfile(f"{(altheapath)}/AltServer"): self.lbl1.set_text("Downloading AltServer...") - self.loadaltlinux.set_fraction(0.6) + self.loadalthea.set_fraction(0.6) """ r = requests.get( @@ -367,11 +367,11 @@ class SplashScreen(Handy.Window): "https://github.com/NyaMisty/AltServer-Linux/releases/download/v0.0.5/AltServer-x86_64", allow_redirects=True, ) - open(f"{(altlinuxpath)}/AltServer", "wb").write(r.content) - subprocess.run(f"chmod +x {(altlinuxpath)}/AltServer", shell=True) - subprocess.run(f"chmod 755 {(altlinuxpath)}/AltServer", shell=True) - self.loadaltlinux.set_fraction(0.8) - if not os.path.isfile(f"{(altlinuxpath)}/AltStore.ipa"): + open(f"{(altheapath)}/AltServer", "wb").write(r.content) + subprocess.run(f"chmod +x {(altheapath)}/AltServer", shell=True) + subprocess.run(f"chmod 755 {(altheapath)}/AltServer", shell=True) + self.loadalthea.set_fraction(0.8) + if not os.path.isfile(f"{(altheapath)}/AltStore.ipa"): self.lbl1.set_text("Downloading AltStore...") altstoredownload("Download") else: @@ -380,8 +380,8 @@ class SplashScreen(Handy.Window): self.lbl1.set_text("Downloading new version of AltStore...") altstoredownload("Download") self.lbl1.set_text("Starting AltServer...") - self.loadaltlinux.set_fraction(1.0) - subprocess.run(f"{(altlinuxpath)}/AltServer &", shell=True) + self.loadalthea.set_fraction(1.0) + subprocess.run(f"{(altheapath)}/AltServer &", shell=True) return 0 @@ -419,7 +419,7 @@ class login(Gtk.Window):# grid.attach(self.entry, 1, 2, 1, 1) grid.attach_next_to(self.button, self.entry, Gtk.PositionType.RIGHT, 1, 1) - silentremove(f"{(altlinuxpath)}/log.txt") + silentremove(f"{(altheapath)}/log.txt") def on_click_me_clicked1(self): self.realthread1 = threading.Thread(target=self.onclickmethread) @@ -427,8 +427,8 @@ class login(Gtk.Window):# GLib.idle_add(self.ermlol) def on_click_me_clicked(self, button): - silentremove(f"{(altlinuxpath)}/log.txt") - if not os.path.isfile(f"{(altlinuxpath)}/saved.txt"): + silentremove(f"{(altheapath)}/log.txt") + if not os.path.isfile(f"{(altheapath)}/saved.txt"): self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) dialog = Gtk.MessageDialog( transient_for=self, @@ -442,7 +442,7 @@ class login(Gtk.Window):# if response == Gtk.ResponseType.YES: AppleID = self.entry1.get_text().lower() Password = self.entry.get_text() - f = open(f"{(altlinuxpath)}/saved.txt", "x") + f = open(f"{(altheapath)}/saved.txt", "x") f.write(AppleID) f.write(":") f.write(Password) @@ -469,12 +469,12 @@ class login(Gtk.Window):# UDID = subprocess.check_output("idevice_id -l", shell=True).decode().strip() global InsAltStore print(PATH) - silentremove(f"{(altlinuxpath)}/log.txt") - #f = open(f"{(altlinuxpath)}/log.txt", "w") + silentremove(f"{(altheapath)}/log.txt") + #f = open(f"{(altheapath)}/log.txt", "w") #f.close() if os.path.isdir(f'{ os.environ["HOME"] }/.adi'): rmtree(f'{ os.environ["HOME"] }/.adi') - InsAltStoreCMD = f"""export ALTSERVER_ANISETTE_SERVER='http://127.0.0.1:6969' ; {(AltServer)} -u {UDID} -a {AppleID} -p {Password} {PATH} > {("$HOME/.local/share/altlinux/log.txt")}""" + InsAltStoreCMD = f"""export ALTSERVER_ANISETTE_SERVER='http://127.0.0.1:6969' ; {(AltServer)} -u {UDID} -a {AppleID} -p {Password} {PATH} > {("$HOME/.local/share/althea/log.txt")}""" InsAltStore = subprocess.Popen( InsAltStoreCMD, stdin=subprocess.PIPE, @@ -496,25 +496,25 @@ class login(Gtk.Window):# global InsAltStore while Installing: CheckIns = subprocess.run( - f'grep -F "Could not" {(altlinuxpath)}/log.txt', shell=True + f'grep -F "Could not" {(altheapath)}/log.txt', shell=True ) CheckWarn = subprocess.run( - f'grep -F "Are you sure you want to continue?" {(altlinuxpath)}/log.txt', + f'grep -F "Are you sure you want to continue?" {(altheapath)}/log.txt', shell=True, ) CheckSuccess = subprocess.run( - f'grep -F "Notify: Installation Succeeded" {(altlinuxpath)}/log.txt', + f'grep -F "Notify: Installation Succeeded" {(altheapath)}/log.txt', shell=True, ) Check2fa = subprocess.run( - f'grep -F "Enter two factor code" {(altlinuxpath)}/log.txt', shell=True + f'grep -F "Enter two factor code" {(altheapath)}/log.txt', shell=True ) if CheckIns.returncode == 0: InsAltStore.terminate() Installing = False global Failmsg Failmsg = subprocess.check_output( - f"tail -6 {(altlinuxpath)}/log.txt", shell=True + f"tail -6 {(altheapath)}/log.txt", shell=True ).decode() dialog2 = DialogExample3(self) dialog2.run() @@ -524,14 +524,14 @@ class login(Gtk.Window):# Installing = False word = "Are you sure you want to continue?" # This fixes an issue where the warn window appears when it shouldn't - with open(f"{(altlinuxpath)}/log.txt", "r") as file: + with open(f"{(altheapath)}/log.txt", "r") as file: # Read all content of the file content = file.read() # Check if a string present in the file if word in content: global Warnmsg Warnmsg = subprocess.check_output( - f"tail -8 {('$HOME/.local/share/altlinux/log.txt')}", + f"tail -8 {('$HOME/.local/share/althea/log.txt')}", shell=True, ).decode() dialog1 = DialogExample2(self) @@ -682,7 +682,7 @@ class PairWindow(Handy.Window): global lolcheck global PATH if lolcheck == "altstr": - PATH = f"{(altlinuxpath)}/AltStore.ipa" + PATH = f"{(altheapath)}/AltStore.ipa" win1() elif lolcheck == "ipa": win2 = FileChooserWindow() @@ -914,7 +914,7 @@ class OopsInternet(Handy.Window): vb.pack_start(image, True, True, 0) lbl1 = Gtk.Label( - label="AltLinux is unable to connect to the Internet.\nPlease connect to the Internet and restart AltLinux." + label="althea is unable to connect to the Internet.\nPlease connect to the Internet and restart althea." ) lbl1.set_property("margin_left", 15) lbl1.set_property("margin_right", 15) @@ -941,7 +941,7 @@ def notify(): if (connectioncheck()) == True: LatestVersion = ( urllib.request.urlopen( - "https://raw.githubusercontent.com/vyvir/AltLinux/main/resources/version" + "https://raw.githubusercontent.com/vyvir/althea/main/resources/version" ) .readline() .rstrip() @@ -966,7 +966,7 @@ def notify(): def showurl(_): Gtk.show_uri_on_window( - None, "https://github.com/vyvir/AltLinux/releases", Gdk.CURRENT_TIME + None, "https://github.com/vyvir/althea/releases", Gdk.CURRENT_TIME ) quitit() @@ -988,13 +988,13 @@ def restartaltserver(_): subprocess.run(f"killall {AnisetteServer}", shell=True) subprocess.run("idevicepair pair", shell=True) subprocess.run( - f"""export ALTSERVER_ANISETTE_SERVER='http://127.0.0.1:6969' ; {(altlinuxpath)}/AltServer &""", + f"""export ALTSERVER_ANISETTE_SERVER='http://127.0.0.1:6969' ; {(altheapath)}/AltServer &""", shell=True, ) def winerm(): - silentremove(f"{(altlinuxpath)}/log.txt") + silentremove(f"{(altheapath)}/log.txt") dialog = Gtk.MessageDialog( # transient_for=self, flags=0, @@ -1007,7 +1007,7 @@ def winerm(): if response == Gtk.ResponseType.YES: global AppleID global Password - f = open(f"{(altlinuxpath)}/saved.txt", "r") + f = open(f"{(altheapath)}/saved.txt", "r") for line in f: AppleID, Password = line.split(":") f.close() @@ -1016,21 +1016,21 @@ def winerm(): savedcheck = True login().on_click_me_clicked1() else: - silentremove(f"{(altlinuxpath)}/saved.txt") + silentremove(f"{(altheapath)}/saved.txt") win3 = login() win3.show_all() dialog.destroy() def win1(): - if os.path.isfile(f"{(altlinuxpath)}/saved.txt"): + if os.path.isfile(f"{(altheapath)}/saved.txt"): winerm() else: openwindow(login) def win2(_): - if os.path.isfile(f"{(altlinuxpath)}/saved.txt"): + if os.path.isfile(f"{(altheapath)}/saved.txt"): winerm() else: openwindow(login) @@ -1038,7 +1038,7 @@ def win2(_): def actionCallback(notification, action, user_data=None): Gtk.show_uri_on_window( - None, "https://github.com/vyvir/AltLinux/releases", Gdk.CURRENT_TIME + None, "https://github.com/vyvir/althea/releases", Gdk.CURRENT_TIME ) quitit() @@ -1050,7 +1050,7 @@ def launchatlogin1(_): os.popen(AutoStart).read() return True else: - silentremove("$HOME/.config/autostart/AltLinux.desktop") + silentremove("$HOME/.config/autostart/althea.desktop") return False @@ -1073,7 +1073,7 @@ def altstoredownload(value): if app['name'] == "AltStore": if value == "Check": size = app['versions'][0]['size'] - return size == os.path.getsize(f'{(altlinuxpath)}/AltStore.ipa') + return size == os.path.getsize(f'{(altheapath)}/AltStore.ipa') break if value == "Download": latest = app['versions'][0]['downloadURL'] @@ -1082,19 +1082,19 @@ def altstoredownload(value): allow_redirects=True, ) latest_filename = latest.split('/')[-1] - open(f"{(altlinuxpath)}/{(latest_filename)}", "wb").write(r.content) - os.rename(f"{(altlinuxpath)}/{(latest_filename)}", f"{(altlinuxpath)}/AltStore.ipa") - subprocess.run(f"chmod 755 {(altlinuxpath)}/AltStore.ipa", shell=True) + open(f"{(altheapath)}/{(latest_filename)}", "wb").write(r.content) + os.rename(f"{(altheapath)}/{(latest_filename)}", f"{(altheapath)}/AltStore.ipa") + subprocess.run(f"chmod 755 {(altheapath)}/AltStore.ipa", shell=True) break return True else: return False def checkiosver(): - silentremove(f"{(altlinuxpath)}/ideviceinfo.txt") - subprocess.run(f"ideviceinfo > {(altlinuxpath)}/ideviceinfo.txt", shell=True) + silentremove(f"{(altheapath)}/ideviceinfo.txt") + subprocess.run(f"ideviceinfo > {(altheapath)}/ideviceinfo.txt", shell=True) result = "result" - pathsy = f"{(altlinuxpath)}/ideviceinfo.txt" + pathsy = f"{(altheapath)}/ideviceinfo.txt" with open(pathsy) as file: # Iterate through lines for line in file.readlines(): @@ -1103,7 +1103,7 @@ def checkiosver(): # If the word is inside the line if index != -1: result = line[:-1][16:] - silentremove(f"{(altlinuxpath)}/ideviceinfo.txt") + silentremove(f"{(altheapath)}/ideviceinfo.txt") print(result) return(result)