Merge pull request #23 from faroukbmiled/refactored

Fixes
This commit is contained in:
Ryuk 2023-10-05 12:45:13 -07:00 committed by GitHub
commit f8f448f7e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 13 deletions

View File

@ -46,4 +46,4 @@ LIBRARY_FILE = "boiiiwd_library.json"
RESOURCES_DIR = os.path.join(os.path.dirname(__file__), '..', 'resources') RESOURCES_DIR = os.path.join(os.path.dirname(__file__), '..', 'resources')
UPDATER_FOLDER = "update" UPDATER_FOLDER = "update"
REGISTRY_KEY_PATH = r"Software\BOIIIWD" REGISTRY_KEY_PATH = r"Software\BOIIIWD"
VERSION = "v0.3.2" VERSION = "v0.3.3"

View File

@ -799,9 +799,13 @@ class BOIIIWD(ctk.CTk):
temp_file_path = log_file_path + '.temp' temp_file_path = log_file_path + '.temp'
if not os.path.exists(log_file_path): if not os.path.exists(log_file_path):
if os.path.isdir(log_file_path): if os.path.isdir(log_file_path):
os.makedirs(log_file_path) try: os.makedirs(log_file_path)
except: return False
else: else:
open(log_file_path, 'w').close() try:
with open(log_file_path, 'w') as file:
file.write('')
except: pass
try: shutil.copy2(log_file_path, temp_file_path) try: shutil.copy2(log_file_path, temp_file_path)
except: return False except: return False
@ -866,13 +870,15 @@ class BOIIIWD(ctk.CTk):
stdout_path = os.path.join(steamcmd_path, "logs", "workshop_log.txt") stdout_path = os.path.join(steamcmd_path, "logs", "workshop_log.txt")
timestamp = datetime.now().strftime("%Y-%m-%d-%H-%M-%S") timestamp = datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
os.makedirs(os.path.dirname(stdout_path), exist_ok=True) try: os.makedirs(os.path.dirname(stdout_path), exist_ok=True)
except: pass
try: try:
with open(stdout_path, 'w') as file: with open(stdout_path, 'w') as file:
file.write('') file.write('')
except: except:
os.rename(stdout_path, os.path.join(map_folder, os.path.join(stdout_path, f"workshop_log_couldntremove_{timestamp}.txt"))) try: os.rename(stdout_path, os.path.join(map_folder, os.path.join(stdout_path, f"workshop_log_couldntremove_{timestamp}.txt")))
except: pass
show_console = subprocess.CREATE_NO_WINDOW show_console = subprocess.CREATE_NO_WINDOW
if self.settings_tab.console: if self.settings_tab.console:
@ -924,10 +930,8 @@ class BOIIIWD(ctk.CTk):
with open(stdout_path, 'w') as file: with open(stdout_path, 'w') as file:
file.write('') file.write('')
except: except:
try: try: os.rename(stdout_path, os.path.join(map_folder, os.path.join(stdout_path, f"workshop_log_couldntremove_{timestamp}.txt")))
os.rename(stdout_path, os.path.join(map_folder, os.path.join(stdout_path, f"workshop_log_couldntremove_{timestamp}.txt"))) except: pass
except:
pass
if not self.settings_tab.stopped: if not self.settings_tab.stopped:
self.settings_tab.steam_fail_counter = self.settings_tab.steam_fail_counter + 1 self.settings_tab.steam_fail_counter = self.settings_tab.steam_fail_counter + 1
@ -958,12 +962,15 @@ class BOIIIWD(ctk.CTk):
creationflags=show_console creationflags=show_console
) )
#wait for process
while True: while True:
if not self.is_downloading:
if self.check_steamcmd_stdout(stdout_path, wsid):
self.is_downloading = True
if process.poll() is not None: if process.poll() is not None:
break break
if not self.is_downloading:
if self.check_steamcmd_stdout(stdout_path, wsid):
start_time = time.time()
self.is_downloading = True
elapsed_time = time.time() - start_time
time.sleep(1) time.sleep(1)
# print("Broken freeeee!") # print("Broken freeeee!")
@ -972,7 +979,8 @@ class BOIIIWD(ctk.CTk):
with open(stdout_path, 'w') as file: with open(stdout_path, 'w') as file:
file.write('') file.write('')
except: except:
os.rename(stdout_path, os.path.join(map_folder, os.path.join(stdout_path, f"workshop_log_couldntremove_{timestamp}.txt"))) try: os.rename(stdout_path, os.path.join(map_folder, os.path.join(stdout_path, f"workshop_log_couldntremove_{timestamp}.txt")))
except: pass
if not os.path.exists(map_folder): if not os.path.exists(map_folder):
show_message("SteamCMD has terminated", "SteamCMD has been terminated\nAnd failed to download the map/mod, try again or enable continuous download in settings") show_message("SteamCMD has terminated", "SteamCMD has been terminated\nAnd failed to download the map/mod, try again or enable continuous download in settings")