Skip to content

Commit 9897f62

Browse files
committed
1.02 update
Fixed an Unzip error when Improvement Mod Launcher.exe is in the update file Added more log info Updated from upx-5.0.1-win64 to upx-5.0.2-win64 Updated python
1 parent 0dd595d commit 9897f62

2 files changed

Lines changed: 27 additions & 18 deletions

File tree

Improvement Mod Launcher.pyw

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def is_admin() -> bool: # Checks if the Launcher is running as admin
4848
return bool(windll.shell32.IsUserAnAdmin()) # Checks if app is running as admin
4949
except Exception as e:
5050
debug("is_admin","Checking failed" + str(e))
51+
add_log("Cannot check if running as Admin" + str(e))
5152
return False
5253

5354
def find_label_by_name(widget) -> bool: # Finds a widget in gInterface_canvas
@@ -136,6 +137,7 @@ def read_write_config(fileAction:str) -> None: # r or w values only
136137
debug("read_write_config", f"Successfully read from {gConfigPath}")
137138
except (FileNotFoundError, PermissionError, IOError,Exception) as e: # Handle file access errors and give error logs
138139
debug("read_write_config", f"Cannot access {gConfigPath}: {e}")
140+
add_log("Error accessing config " + str(e))
139141

140142
def is_process_running(process_name:str) -> bool: # Check if a process with the given name is running
141143
for proc in process_iter(['name']):
@@ -232,12 +234,17 @@ def download_update_thread(): # Download the new update as a separate thread
232234
with ZipFile(zip_path, "r") as zip_ref: # Open the downloaded ZIP file
233235
members = zip_ref.infolist()
234236
total_files = len(members) # Get the total number of files to extract
237+
current_exe = os.path.basename(sys.argv[0]).lower()
235238
for index, member in enumerate(members, start=1):
236239
if gCancelDownload: # Check if user Cancelled extraction
237240
debug("Extraction cancelled:", "")
238241
gApp.after(0, lambda: gUpdate_label.configure(text="Extraction cancelled"))
239242
enable_all_widgets()
240243
return
244+
245+
if os.path.basename(member.filename).lower() == current_exe:
246+
continue
247+
241248
target_path = os.path.join(gGamePath, member.filename) # Define extraction path
242249
if member.filename.endswith("/"): # Create directories if needed
243250
os.makedirs(target_path, exist_ok=True)
@@ -268,7 +275,7 @@ def download_update_thread(): # Download the new update as a separate thread
268275
except Exception as e: # Handle extraction errors
269276
gApp.after(0, lambda: gUpdate_label.configure(text="Extraction error"))
270277
debug("download_update_thread", "Unzip error Extraction error:" + str(e))
271-
add_log("Cannot unzip update, update failed")
278+
add_log("Cannot unzip update, update failed " + str(e))
272279
gThreadStop_event.set()
273280

274281
try: # Delete the ZIP file after extraction
@@ -286,7 +293,7 @@ def download_update_thread(): # Download the new update as a separate thread
286293
install_check()
287294
except Exception as e: # Handle errors while deleting ZIP file
288295
debug("download_update_thread", "Error deleting zip file:" + str(e))
289-
add_log("Error deleting temporary update zip file")
296+
add_log("Error deleting temporary update zip file " + str(e))
290297
gThreadStop_event.set()
291298
enable_all_widgets()
292299

@@ -330,7 +337,7 @@ def check_updates(url: str) -> str: # Function to check for mod updates by compa
330337

331338
except requests.RequestException as e: # Catch network-related errors during the HTTP request
332339
debug("check_updates Error retrieving last modified date:", str(e)) # Log the error message
333-
add_log("Cannot check for updates") # Add the error message to the log
340+
add_log("Cannot check for updates " + str(e)) # Add the error message to the log
334341
gUpdateButton_label.configure(text="Reinstall Mod")
335342
return "" # Return an empty string to indicate an error has occurred
336343

@@ -362,6 +369,7 @@ def get_zip_top_level_folder_names(zip_file_path) -> set:
362369
folder_names.add(folder_name)
363370
except Exception as e:
364371
debug("get_zip_top_level_folder_names Error reading " + str(zip_file_path) , str(e))
372+
add_log("Error during upzip phase" + str(e))
365373
return sorted(folder_names)
366374

367375
def update_file(file_text:str,file_path:str) -> None:
@@ -374,10 +382,10 @@ def update_file(file_text:str,file_path:str) -> None:
374382
add_log("Cannot update ImpMod_AISetting")
375383
except OSError as e: # OSError
376384
debug(f"update_file OS error has occurred: {e}", "OSError when writing to ImpMod_AISetting")
377-
add_log("Cannot update ImpMod_AISetting")
385+
add_log("Cannot update ImpMod_AISetting " + str(e))
378386
except Exception as e: # Exception
379387
debug(f"update_file An unexpected error has occurred: {e}", "Exception when writing to ImpMod_AISetting")
380-
add_log("Cannot update ImpMod_AISetting")
388+
add_log("Cannot update ImpMod_AISetting " + str(e))
381389

382390
def extract_ai_from_zip(folder_name: str) -> None:
383391
"""
@@ -404,13 +412,13 @@ def extract_ai_from_zip(folder_name: str) -> None:
404412
debug("extract_ai_from_zip", f"Extraction complete. Files extracted to {output_dir}")
405413
except PermissionError as e: # Handle permission error.
406414
debug("extract_ai_from_zip", f"Permission denied while extracting ImpMod_AIs: {e}")
407-
add_log("Cannot change AI")
415+
add_log("Cannot change AI " + str(e))
408416
except OSError as e: # Handle OS-related errors.
409417
debug("extract_ai_from_zip", f"OS error has occurred during extraction of ImpMod_AIs: {e}")
410-
add_log("Cannot change AI")
418+
add_log("Cannot change AI " + str(e))
411419
except Exception as e: # Catch any other unexpected errors.
412420
debug("extract_ai_from_zip", f"An unexpected error has occurred of ImpMod_AIs: {e}")
413-
add_log("Cannot change AI")
421+
add_log("Cannot change AI " + str(e))
414422

415423
def option_changed(choice) -> None:
416424
global gAi_label
@@ -448,7 +456,8 @@ def read_ai_zip() -> None:
448456
button_image_path = gButtonImageUrl
449457
try:
450458
button_image = Image.open(button_image_path)
451-
except FileNotFoundError:
459+
except FileNotFoundError as e:
460+
add_log("Cannot read AI file " + str(e))
452461
sys.exit(1)
453462
dropButton = ctk.CTkLabel(gApp, image=ctk.CTkImage(light_image=button_image, size=(250, 40)), text="", font=gMain_font) # Create the CTkLabel with the background image
454463
gInterface_canvas.create_window(20, 180, window=dropButton, anchor="w") # Add the label to the canvas
@@ -501,10 +510,10 @@ def read_ai_zip() -> None:
501510
add_log("Cannot load AI list")
502511
except OSError as e: # OSError
503512
debug(f"read_ai_zip OS error has occurred: {e}", "OSError when reading ImpMod_AIs")
504-
add_log("Cannot load AI list")
513+
add_log("Cannot load AI list " + str(e))
505514
except Exception as e: # Exception
506515
debug(f"read_ai_zip An unexpected error has occurred: {e}", "Exception when reading ImpMod_AIs")
507-
add_log("Cannot load AI list")
516+
add_log("Cannot load AI list " + str(e))
508517

509518
def checkbox_D3D9_state() -> None:
510519
if gD3D9Var_intVar.get() == 0:
@@ -829,7 +838,7 @@ def interface():
829838
gD3D9Var_intVar = ctk.IntVar(value=1)
830839
gD3D9_checkbox = ctk.CTkCheckBox(gApp, text="Enable DirectX12 Wrapper", variable=gD3D9Var_intVar, command=checkbox_D3D9_state,hover_color="#800000",fg_color="#600000",font= gMain_font,bg_color="#2f1308")
831840
gInterface_canvas.create_window(20, 320, window=gD3D9_checkbox,anchor="w")
832-
CreateToolTip(gD3D9_checkbox, "Enable the DirectX12 wrapper; when disabled the game will use DirectX9")
841+
CreateToolTip(gD3D9_checkbox, "When disabled the game will use DirectX9 ; Do not enable the DX12 Wrapper if you are on a laptop or with integrated graphics; only enable if you have a mid to high range GPU")
833842

834843
elif os.path.exists("D3D9.dll_Disabled"):
835844
gD3D9Var_intVar = ctk.IntVar(value=0)
@@ -1059,8 +1068,8 @@ if __name__ == '__main__':
10591068
else: # Running as a script
10601069
gApp.iconbitmap(r"icon\icon.ico") # Set the path to the icon file for script
10611070

1062-
gVersion:str = "1.01" # App version
1063-
gGitHubVersion:str = "version1.01"
1071+
gVersion:str = "1.02" # App version
1072+
gGitHubVersion:str = "version1.02"
10641073

10651074
gModDownloadUrl:str = "" # Hold the URL for the mirror download
10661075
gLast_updated:str = "" # Stores the last date the file was installed

version/version_info.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ VSVersionInfo(
66
ffi=FixedFileInfo(
77
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
88
# Set not needed items to zero 0.
9-
filevers=(1, 0, 1, 0),
10-
prodvers=(1, 0, 1, 0),
9+
filevers=(1, 0, 2, 0),
10+
prodvers=(1, 0, 2, 0),
1111
# Contains a bitmask that specifies the valid bits 'flags'r
1212
mask=0x3f,
1313
# Contains a bitmask that specifies the Boolean attributes of the file.
@@ -31,12 +31,12 @@ VSVersionInfo(
3131
u'040904B0',
3232
[StringStruct(u'CompanyName', u'ageekhere'),
3333
StringStruct(u'FileDescription', u'Improvement Mod Launcher'),
34-
StringStruct(u'FileVersion', u'1.010'),
34+
StringStruct(u'FileVersion', u'1.020'),
3535
StringStruct(u'InternalName', u'Improvement Mod Launcher'),
3636
StringStruct(u'LegalCopyright', u'ageekhere'),
3737
StringStruct(u'OriginalFilename', u'Improvement Mod Launcher'),
3838
StringStruct(u'ProductName', u'Improvement Mod Launcher'),
39-
StringStruct(u'ProductVersion', u'1.0.1.0')])
39+
StringStruct(u'ProductVersion', u'1.0.2.0')])
4040
]),
4141
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
4242
]

0 commit comments

Comments
 (0)