1- import requests , gdown , zipfile , os , ctypes , tempfile , shutil , subprocess , logging
1+ import requests , gdown , zipfile , os , ctypes , tempfile , shutil , subprocess
22from tkinter import messagebox
33
4- logging .basicConfig (filename = 'app.log' , filemode = 'w' , format = '%(name)s - %(levelname)s - %(message)s' )
5-
64install_path = "C:\\ Program Files (x86)\\ Keychron"
75
86def get_installed_version ():
@@ -11,7 +9,6 @@ def get_installed_version():
119 installed_version = f .read ().split ('<software caption="Keychron" version="' )[1 ].split ('"' )[0 ]
1210 return installed_version
1311 except Exception as e :
14- logging .error (f"Failed to get installed version: { e } " )
1512 messagebox .showerror ("Error" , f"Failed to get installed version: { e } " )
1613
1714def get_online_version_and_url ():
@@ -28,16 +25,14 @@ def get_online_version_and_url():
2825
2926 return online_version , download_url
3027 except Exception as e :
31- logging .error (f"Failed to get online version and url: { e } " )
3228 messagebox .showerror ("Error" , f"Failed to get online version and url: { e } " )
3329
3430def download_and_extract_file (download_url , tmp_path ):
3531 try :
36- gdown .download (download_url , tmp_path + '\\ Keychron.zip' , quiet = False )
32+ gdown .download (download_url , tmp_path + '\\ Keychron.zip' , quiet = True )
3733 with zipfile .ZipFile (tmp_path + '\\ Keychron.zip' , 'r' ) as zip_ref :
3834 zip_ref .extractall (tmp_path )
3935 except Exception as e :
40- logging .error (f"Failed to download and extract file: { e } " )
4136 messagebox .showerror ("Error" , f"Failed to download and extract file: { e } " )
4237
4338def run_exe (tmp_path ):
@@ -48,7 +43,6 @@ def run_exe(tmp_path):
4843 process = subprocess .Popen ([os .path .join (root , file )], shell = True )
4944 process .wait ()
5045 except Exception as e :
51- logging .error (f"Failed to run exe: { e } " )
5246 messagebox .showerror ("Error" , f"Failed to run exe: { e } " )
5347
5448def main ():
@@ -65,7 +59,6 @@ def main():
6559 run_exe (tmp_path )
6660 shutil .rmtree (tmp_path )
6761 except Exception as e :
68- logging .error (f"An error occurred: { e } " )
6962 messagebox .showerror ("Error" , f"An error occurred: { e } " )
7063
7164if __name__ == "__main__" :
0 commit comments