track will always try to be downloaded

This commit is contained in:
raphael60650 2021-06-17 16:25:42 +02:00
parent df6e0e8808
commit 524104b400

View file

@ -44,27 +44,26 @@ def patch_track(self, tracks, total_track="?"):
if len(process_list) < max_process: if len(process_list) < max_process:
process_list[track_szs_file] = None process_list[track_szs_file] = None
self.Progress(statut=self.translate("Conversion des courses") + f"\n({i + 1}/{total_track})\n" + self.Progress(statut=self.translate("Conversion des courses") + f"\n({i + 1}/{total_track})\n" +
"\n".join([get_nodir(file) for file in process_list.keys()]), add=1) "\n".join([get_nodir(file) for file in process_list.keys()]), add=1)
for track_file in [track_szs_file, track_wu8_file]: for track_file in [track_szs_file, track_wu8_file]:
if os.path.exists(track_file): if os.path.exists(track_file):
if os.path.getsize(track_file) < 1000: # File under this size are corrupted if os.path.getsize(track_file) < 1000: # File under this size are corrupted
os.remove(track_file) os.remove(track_file)
if not (os.path.exists(track_wu8_file)): dl_code = self.get_github_file(track_wu8_file)
dl_code = self.get_github_file(track_wu8_file) if dl_code == -1:
if dl_code == -1: error_count += 1
error_count += 1 if error_count > error_max: # Too much track wasn't correctly converted
if error_count > error_max: # Too much track wasn't correctly converted messagebox.showerror(
messagebox.showerror( self.translate("Erreur"),
self.translate("Erreur"), self.translate("Trop de course ont eu une erreur du téléchargement."))
self.translate("Trop de course ont eu une erreur du téléchargement.")) return
return else:
else: messagebox.showwarning(self.translate("Attention"),
messagebox.showwarning(self.translate("Attention"), self.translate(
self.translate( "Impossible de télécharger cette course ! (") +
"Impossible de télécharger cette course ! (") + str(error_count) + "/" + str(error_max) + ")")
str(error_count) + "/" + str(error_max) + ")")
if not (os.path.exists(track_szs_file)): if not (os.path.exists(track_szs_file)):
process_list[track_szs_file] = subprocess.Popen([ process_list[track_szs_file] = subprocess.Popen([
@ -82,7 +81,6 @@ def patch_track(self, tracks, total_track="?"):
stderr = process_list[process].stderr.read() stderr = process_list[process].stderr.read()
if b"wszst: ERROR" in stderr: # Error occured if b"wszst: ERROR" in stderr: # Error occured
process_list.pop(process) process_list.pop(process)
print(process, stderr)
os.remove(process) os.remove(process)
error_count += 1 error_count += 1
if error_count > error_max: # Too much track wasn't correctly converted if error_count > error_max: # Too much track wasn't correctly converted