@@ -32,7 +32,7 @@ VERSION = "0.10"
3232
3333def send_error_report (prog , fatal = False ):
3434 try :
35- with open (f"launcher_logs/{ prog } /latest .log" )as log :
35+ with open (f"launcher_logs/error .log" )as log :
3636 tb = log .read ()
3737 tb .replace (getpass .getuser (), "<USER>" )
3838 except FileNotFoundError :
@@ -45,7 +45,7 @@ def send_error_report(prog, fatal=False):
4545 if messagebox .askyesno ("Report issue" , f"Would you like to automatically open an issue?" ):
4646 newline = "\n "
4747 body = f"(insert description of bug here)%0A***%0ALog contents:%0A```%0A{ tb .replace (newline , '%0A' )} %0A```"
48- url = f"https://github.com/SpacePython12/AP-Launcher/issues/new?body= { body } "
48+ url = f"https://github.com/SpacePython12/AP-Launcher/issues/new?"
4949 webbrowser .open (url )
5050
5151class AboutPage (Frame ):
@@ -258,7 +258,7 @@ class App:
258258 def kill_process (self ):
259259 """Kills the running Minecraft process."""
260260 try :
261- os . system (f'cmd /C taskkill /FI "WindowTitle eq Minecraft*" /T /F' )
261+ subprocess . Popen (f'cmd /C taskkill /FI "WindowTitle eq Minecraft*" /T /F' )
262262 except :
263263 messagebox .showerror ("Error" , "Unable to stop the process." )
264264 return
@@ -278,8 +278,8 @@ class App:
278278 json .dump (self .accounts , open (os .path .join (self .minecraftdir , "launcher_profiles.json" ), "w" ), indent = 2 )
279279 json .dump (self .cache , open ("cache.json" , "w" ), indent = 2 )
280280 self .win .withdraw ()
281- os .system (f'cmd /C taskkill /IM APLauncher.exe /T /F' )
282281 self .update_version ()
282+ subprocess .Popen (f'cmd /C taskkill /IM APLauncher.exe /T /F' )
283283 sys .exit ()
284284
285285 def get_versions (self ):
@@ -518,6 +518,9 @@ class App:
518518 zf .extract (file_ , os .path .join (self .minecraftdir , "assets" ))
519519 logger .info ("Extracting required DLL files..." )
520520 for file_ in zf .namelist ():
521+ dllpath = os .path .join (self .minecraftdir , "bin" , "natives" )
522+ if not os .path .isdir (dllpath ):
523+ os .makedirs (dllpath , exist_ok = True )
521524 if file_ .startswith ("natives" ):
522525 zf .extract (file_ , os .path .join (self .minecraftdir , "bin" ))
523526 logger .info ("Extracting libraries..." )
@@ -583,7 +586,10 @@ if __name__ == "__main__":
583586 num = 1
584587 while os .path .isfile (f"launcher_logs/gui/{ time } -{ num } .log" ):
585588 num += 1
586- os .rename ("launcher_logs/gui/latest.log" , f"launcher_logs/gui/{ time } -{ num } .log" )
589+ try :
590+ os .rename ("launcher_logs/gui/latest.log" , f"launcher_logs/gui/{ time } -{ num } .log" )
591+ except :
592+ sys .exit ()
587593 fmt = "[%(asctime)s] (Process %(processName)s thread %(threadName)s func %(funcName)s/%(levelname)s): %(message)s"
588594 logging .basicConfig (filename = "launcher_logs/gui/latest.log" , format = fmt , level = logging .INFO )
589595 logger = logging .getLogger ()
@@ -592,6 +598,9 @@ if __name__ == "__main__":
592598 except BaseException as e :
593599 messagebox .showerror ("Fatal error" , "A fatal error has occurred during startup." )
594600 logger .error (e , exc_info = True )
601+ with open ("launcher_logs/error.log" , "w" ) as err :
602+ err .write (sys .exc_info ())
603+ err .close ()
595604 send_error_report ("gui" , fatal = True )
596605 sys .exit ()
597606 try :
@@ -600,6 +609,9 @@ if __name__ == "__main__":
600609 if not type (e ).__name__ == "SystemExit" :
601610 messagebox .showerror ("Fatal error" , "A fatal error has occurred during runtime." )
602611 logger .error (e , exc_info = True )
612+ with open ("launcher_logs/error.log" , "w" ) as err :
613+ err .write (sys .exc_info ())
614+ err .close ()
603615 send_error_report ("gui" , fatal = True )
604616 main .win .destroy ()
605617 sys .exit ()
0 commit comments