stick to python naming conventions

This commit is contained in:
vyvir
2024-09-11 11:27:37 +03:00
parent d7c66a0484
commit 99387e5265
+45 -45
View File
@@ -51,14 +51,14 @@ def resource_path(relative_path):
# Global variables # Global variables
ermcheck = False # Checks if the IPA path has been defined by user ipa_path_exists = False # Checks if the IPA path has been defined by user
savedcheck = False savedcheck = False
InsAltStore = subprocess.Popen( InsAltStore = subprocess.Popen(
"test", stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True "test", stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True
) )
lolcheck = "lol" # Redirects user either to login or to file chooser; If the "Pair" option was selected, it closes the dialog lolcheck = "lol" # Redirects user either to login or to file chooser; If the "Pair" option was selected, it closes the dialog
AppleID = "lol" apple_id = "lol"
Password = "lol" password = "lol"
Warnmsg = "warn" Warnmsg = "warn"
Failmsg = "fail" Failmsg = "fail"
icon_name = "changes-prevent-symbolic" icon_name = "changes-prevent-symbolic"
@@ -218,12 +218,12 @@ def altserverfile(_):
openwindow(PairWindow) openwindow(PairWindow)
else: else:
win2 = FileChooserWindow() win2 = FileChooserWindow()
global ermcheck global ipa_path_exists
if ermcheck == True: if ipa_path_exists == True:
global PATH global PATH
PATH = win2.PATHFILE PATH = win2.PATHFILE
win1() win1()
ermcheck = False ipa_path_exists = False
class SplashScreen(Handy.Window): class SplashScreen(Handy.Window):
@@ -257,7 +257,7 @@ class SplashScreen(Handy.Window):
self.mainBox.pack_start(self.lbl1, False, False, 6) self.mainBox.pack_start(self.lbl1, False, False, 6)
self.loadalthea = Gtk.ProgressBar() self.loadalthea = Gtk.ProgressBar()
self.mainBox.pack_start(self.loadalthea, True, True, 0) self.mainBox.pack_start(self.loadalthea, True, True, 0)
self.t = threading.Thread(target=self.lol321actualfunction) self.t = threading.Thread(target=self.startup_process)
self.t.start() self.t.start()
self.wait_for_t(self.t) self.wait_for_t(self.t)
@@ -270,7 +270,7 @@ class SplashScreen(Handy.Window):
else: else:
GLib.timeout_add(200, self.wait_for_t, self.t) GLib.timeout_add(200, self.wait_for_t, self.t)
def lol321actualfunction(self): def startup_process(self):
self.lbl1.set_text("Checking if anisette-server is already running...") self.lbl1.set_text("Checking if anisette-server is already running...")
self.loadalthea.set_fraction(0.1) self.loadalthea.set_fraction(0.1)
command = 'curl 127.0.0.1:6969 | grep -q "{"' command = 'curl 127.0.0.1:6969 | grep -q "{"'
@@ -323,7 +323,7 @@ class SplashScreen(Handy.Window):
f'unzip -j "{(altheapath)}/am.apk" "lib/x86_64/libCoreADI.so" -d "{(altheapath)}/lib/x86_64"', f'unzip -j "{(altheapath)}/am.apk" "lib/x86_64/libCoreADI.so" -d "{(altheapath)}/lib/x86_64"',
shell=True, shell=True,
) )
silentremove(f"{(altheapath)}/am.apk") silent_remove(f"{(altheapath)}/am.apk")
self.loadalthea.set_fraction(0.4) self.loadalthea.set_fraction(0.4)
self.lbl1.set_text("Starting anisette-server...") self.lbl1.set_text("Starting anisette-server...")
subprocess.run(f"cd {(altheapath)} && ./anisette-server &", shell=True)#-n 127.0.0.1 -p 6969 &", shell=True subprocess.run(f"cd {(altheapath)} && ./anisette-server &", shell=True)#-n 127.0.0.1 -p 6969 &", shell=True
@@ -373,12 +373,12 @@ class SplashScreen(Handy.Window):
self.loadalthea.set_fraction(0.8) self.loadalthea.set_fraction(0.8)
if not os.path.isfile(f"{(altheapath)}/AltStore.ipa"): if not os.path.isfile(f"{(altheapath)}/AltStore.ipa"):
self.lbl1.set_text("Downloading AltStore...") self.lbl1.set_text("Downloading AltStore...")
altstoredownload("Download") altstore_download("Download")
else: else:
self.lbl1.set_text("Checking latest AltStore version...") self.lbl1.set_text("Checking latest AltStore version...")
if not altstoredownload("Check"): if not altstore_download("Check"):
self.lbl1.set_text("Downloading new version of AltStore...") self.lbl1.set_text("Downloading new version of AltStore...")
altstoredownload("Download") altstore_download("Download")
self.lbl1.set_text("Starting AltServer...") self.lbl1.set_text("Starting AltServer...")
self.loadalthea.set_fraction(1.0) self.loadalthea.set_fraction(1.0)
subprocess.run(f"{(altheapath)}/AltServer &", shell=True) subprocess.run(f"{(altheapath)}/AltServer &", shell=True)
@@ -419,15 +419,15 @@ class login(Gtk.Window):#
grid.attach(self.entry, 1, 2, 1, 1) grid.attach(self.entry, 1, 2, 1, 1)
grid.attach_next_to(self.button, self.entry, Gtk.PositionType.RIGHT, 1, 1) grid.attach_next_to(self.button, self.entry, Gtk.PositionType.RIGHT, 1, 1)
silentremove(f"{(altheapath)}/log.txt") silent_remove(f"{(altheapath)}/log.txt")
def on_click_me_clicked1(self): def on_click_me_clicked1(self):
self.realthread1 = threading.Thread(target=self.onclickmethread) self.realthread1 = threading.Thread(target=self.onclickmethread)
self.realthread1.start() self.realthread1.start()
GLib.idle_add(self.ermlol) GLib.idle_add(self.install_process)
def on_click_me_clicked(self, button): def on_click_me_clicked(self, button):
silentremove(f"{(altheapath)}/log.txt") silent_remove(f"{(altheapath)}/log.txt")
if not os.path.isfile(f"{(altheapath)}/saved.txt"): if not os.path.isfile(f"{(altheapath)}/saved.txt"):
self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
dialog = Gtk.MessageDialog( dialog = Gtk.MessageDialog(
@@ -440,12 +440,12 @@ class login(Gtk.Window):#
dialog.format_secondary_text("This will allow you to login automatically.") dialog.format_secondary_text("This will allow you to login automatically.")
response = dialog.run() response = dialog.run()
if response == Gtk.ResponseType.YES: if response == Gtk.ResponseType.YES:
AppleID = self.entry1.get_text().lower() apple_id = self.entry1.get_text().lower()
Password = self.entry.get_text() password = self.entry.get_text()
f = open(f"{(altheapath)}/saved.txt", "x") f = open(f"{(altheapath)}/saved.txt", "x")
f.write(AppleID) f.write(apple_id)
f.write(":") f.write(":")
f.write(Password) f.write(password)
f.close() f.close()
dialog.destroy() dialog.destroy()
self.entry.set_progress_pulse_step(0.2) self.entry.set_progress_pulse_step(0.2)
@@ -456,25 +456,25 @@ class login(Gtk.Window):#
self.button.set_sensitive(False) self.button.set_sensitive(False)
self.realthread1 = threading.Thread(target=self.onclickmethread) self.realthread1 = threading.Thread(target=self.onclickmethread)
self.realthread1.start() self.realthread1.start()
GLib.idle_add(self.ermlol) GLib.idle_add(self.install_process)
def onclickmethread(self): def onclickmethread(self):
if checkiosver() >= "15.0": if ios_version() >= "15.0":
global savedcheck global savedcheck
global AppleID global apple_id
global Password global password
if not savedcheck: if not savedcheck:
AppleID = self.entry1.get_text().lower() apple_id = self.entry1.get_text().lower()
Password = self.entry.get_text() password = self.entry.get_text()
UDID = subprocess.check_output("idevice_id -l", shell=True).decode().strip() UDID = subprocess.check_output("idevice_id -l", shell=True).decode().strip()
global InsAltStore global InsAltStore
print(PATH) print(PATH)
silentremove(f"{(altheapath)}/log.txt") silent_remove(f"{(altheapath)}/log.txt")
#f = open(f"{(altheapath)}/log.txt", "w") #f = open(f"{(altheapath)}/log.txt", "w")
#f.close() #f.close()
if os.path.isdir(f'{ os.environ["HOME"] }/.adi'): if os.path.isdir(f'{ os.environ["HOME"] }/.adi'):
rmtree(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/althea/log.txt")}""" InsAltStoreCMD = f"""export ALTSERVER_ANISETTE_SERVER='http://127.0.0.1:6969' ; {(AltServer)} -u {UDID} -a {apple_id} -p {password} {PATH} > {("$HOME/.local/share/althea/log.txt")}"""
InsAltStore = subprocess.Popen( InsAltStore = subprocess.Popen(
InsAltStoreCMD, InsAltStoreCMD,
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
@@ -489,7 +489,7 @@ class login(Gtk.Window):#
dialog2.destroy() dialog2.destroy()
self.destroy() self.destroy()
def ermlol(self): def install_process(self):
Installing = True Installing = True
WarnTime = 0 WarnTime = 0
TwoFactorTime = 0 TwoFactorTime = 0
@@ -686,11 +686,11 @@ class PairWindow(Handy.Window):
win1() win1()
elif lolcheck == "ipa": elif lolcheck == "ipa":
win2 = FileChooserWindow() win2 = FileChooserWindow()
global ermcheck global ipa_path_exists
if ermcheck == True: if ipa_path_exists == True:
PATH = win2.PATHFILE PATH = win2.PATHFILE
win1() win1()
ermcheck = False ipa_path_exists = False
lolcheck = "lol" lolcheck = "lol"
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
errormsg = e.output.decode("utf-8") errormsg = e.output.decode("utf-8")
@@ -730,8 +730,8 @@ class FileChooserWindow(Gtk.Window):
response = dialog.run() response = dialog.run()
if response == Gtk.ResponseType.OK: if response == Gtk.ResponseType.OK:
self.PATHFILE = dialog.get_filename() self.PATHFILE = dialog.get_filename()
global ermcheck global ipa_path_exists
ermcheck = True ipa_path_exists = True
elif response == Gtk.ResponseType.CANCEL: elif response == Gtk.ResponseType.CANCEL:
self.destroy() self.destroy()
@@ -994,7 +994,7 @@ def restartaltserver(_):
def winerm(): def winerm():
silentremove(f"{(altheapath)}/log.txt") silent_remove(f"{(altheapath)}/log.txt")
dialog = Gtk.MessageDialog( dialog = Gtk.MessageDialog(
# transient_for=self, # transient_for=self,
flags=0, flags=0,
@@ -1005,18 +1005,18 @@ def winerm():
dialog.format_secondary_text("Your login and password have been saved earlier.") dialog.format_secondary_text("Your login and password have been saved earlier.")
response = dialog.run() response = dialog.run()
if response == Gtk.ResponseType.YES: if response == Gtk.ResponseType.YES:
global AppleID global apple_id
global Password global password
f = open(f"{(altheapath)}/saved.txt", "r") f = open(f"{(altheapath)}/saved.txt", "r")
for line in f: for line in f:
AppleID, Password = line.split(":") apple_id, password = line.split(" ")
f.close() f.close()
print(AppleID, Password) print(apple_id, password)
global savedcheck global savedcheck
savedcheck = True savedcheck = True
login().on_click_me_clicked1() login().on_click_me_clicked1()
else: else:
silentremove(f"{(altheapath)}/saved.txt") silent_remove(f"{(altheapath)}/saved.txt")
win3 = login() win3 = login()
win3.show_all() win3.show_all()
dialog.destroy() dialog.destroy()
@@ -1050,18 +1050,18 @@ def launchatlogin1(_):
os.popen(AutoStart).read() os.popen(AutoStart).read()
return True return True
else: else:
silentremove("$HOME/.config/autostart/althea.desktop") silent_remove("$HOME/.config/autostart/althea.desktop")
return False return False
def silentremove(filename): def silent_remove(filename):
try: try:
os.remove(filename) os.remove(filename)
except OSError as e: except OSError as e:
if e.errno != errno.ENOENT: # errno.ENOENT = no such file or directory if e.errno != errno.ENOENT: # errno.ENOENT = no such file or directory
raise # re-raise exception if a different error occurred raise # re-raise exception if a different error occurred
def altstoredownload(value): def altstore_download(value):
# setting the base URL value # setting the base URL value
baseUrl = "https://cdn.altstore.io/file/altstore/apps.json" baseUrl = "https://cdn.altstore.io/file/altstore/apps.json"
@@ -1090,8 +1090,8 @@ def altstoredownload(value):
else: else:
return False return False
def checkiosver(): def ios_version():
silentremove(f"{(altheapath)}/ideviceinfo.txt") silent_remove(f"{(altheapath)}/ideviceinfo.txt")
subprocess.run(f"ideviceinfo > {(altheapath)}/ideviceinfo.txt", shell=True) subprocess.run(f"ideviceinfo > {(altheapath)}/ideviceinfo.txt", shell=True)
result = "result" result = "result"
pathsy = f"{(altheapath)}/ideviceinfo.txt" pathsy = f"{(altheapath)}/ideviceinfo.txt"
@@ -1103,7 +1103,7 @@ def checkiosver():
# If the word is inside the line # If the word is inside the line
if index != -1: if index != -1:
result = line[:-1][16:] result = line[:-1][16:]
silentremove(f"{(altheapath)}/ideviceinfo.txt") silent_remove(f"{(altheapath)}/ideviceinfo.txt")
print(result) print(result)
return(result) return(result)