Skip to content

Commit 9cb98dc

Browse files
authored
Update proton_manager.py
1 parent e68849d commit 9cb98dc

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

proton_manager.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# proton_manager.py
21
import requests
32
import json
43
import tarfile
@@ -42,19 +41,12 @@ def get_installed_protons(self):
4241

4342
def get_proton_path(self, version):
4443
base = os.path.join(self.protons_dir, version)
45-
possible_paths = [
46-
os.path.join(base, 'proton'),
47-
os.path.join(base, 'dist', 'bin', 'proton'),
48-
os.path.join(base, 'bin', 'proton'),
49-
os.path.join(base, 'proton-run')
50-
]
51-
for path in possible_paths:
52-
if os.path.exists(path):
53-
return path
44+
for root, dirs, files in os.walk(base):
45+
if 'proton' in files:
46+
return os.path.join(root, 'proton')
5447
raise Exception(f"Proton binary not found in {version}")
5548

5649
def _version_key(self, version):
57-
# Improved version sorting: handle numbers and non-numbers, including decimals
5850
version = version.replace('GE-Proton', '').replace('Proton-', '')
5951
parts = []
6052
current = ''
@@ -71,7 +63,6 @@ def _version_key(self, version):
7163
current += char
7264
if current:
7365
parts.append(current)
74-
# Convert parts: numbers to float (for decimals like 10.0), others as strings
7566
def convert_part(part):
7667
try:
7768
return float(part) if '.' in part else int(part)
@@ -85,7 +76,7 @@ def get_available_ge(self):
8576
for attempt in range(3):
8677
try:
8778
url = 'https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases'
88-
response = requests.get(url, timeout=15) # Increased timeout
79+
response = requests.get(url, timeout=15)
8980
response.raise_for_status()
9081
releases = json.loads(response.text)
9182
tags = [r['tag_name'] for r in releases if 'tag_name' in r and r['tag_name'].startswith('GE-Proton')]
@@ -94,8 +85,10 @@ def get_available_ge(self):
9485
return tags
9586
except Exception as e:
9687
logging.error(f"Error fetching GE protons (attempt {attempt+1}/3): {e}")
97-
time.sleep(3) # Slightly longer delay
88+
print(f"Error fetching GE protons (attempt {attempt+1}/3): {e}")
89+
time.sleep(3)
9890
logging.warning("Failed to fetch GE protons after retries, returning empty list")
91+
print("Failed to fetch GE protons after retries, returning empty list")
9992
self.available_ge_cache = []
10093
return []
10194

@@ -107,7 +100,7 @@ def get_available_official(self, stable=True):
107100
for attempt in range(3):
108101
try:
109102
url = 'https://api.github.com/repos/ValveSoftware/Proton/releases'
110-
response = requests.get(url, timeout=15) # Increased timeout
103+
response = requests.get(url, timeout=15)
111104
response.raise_for_status()
112105
releases = json.loads(response.text)
113106
filtered = [r['tag_name'] for r in releases if 'tag_name' in r]
@@ -123,8 +116,10 @@ def get_available_official(self, stable=True):
123116
return filtered
124117
except Exception as e:
125118
logging.error(f"Error fetching official protons (attempt {attempt+1}/3): {e}")
119+
print(f"Error fetching official protons (attempt {attempt+1}/3): {e}")
126120
time.sleep(3)
127121
logging.warning(f"Failed to fetch {'stable' if stable else 'experimental'} official protons after retries, returning empty list")
122+
print(f"Failed to fetch {'stable' if stable else 'experimental'} official protons after retries, returning empty list")
128123
if stable:
129124
self.available_official_stable_cache = []
130125
else:
@@ -141,11 +136,13 @@ def install_proton(self, version, proton_type, progress_callback=None):
141136
selected_release = next((r for r in releases if r['tag_name'] == version), None)
142137
if not selected_release:
143138
logging.error(f"No release found for {version}")
139+
print(f"No release found for {version}")
144140
return False, f"No release found for {version}"
145141
assets = selected_release['assets']
146142
tar_asset = next((a for a in assets if a['name'].endswith('.tar.gz')), None)
147143
if not tar_asset:
148144
logging.error(f"No tar.gz asset found for {version}")
145+
print(f"No tar.gz asset found for {version}")
149146
return False, f"No tar.gz asset found for {version}"
150147
dl_url = tar_asset['browser_download_url']
151148
progress_callback("Downloading", 0, 100)
@@ -193,6 +190,7 @@ def install_proton(self, version, proton_type, progress_callback=None):
193190
return True, "Success"
194191
except Exception as e:
195192
logging.error(f"Error installing {proton_type} proton {version}: {e}")
193+
print(f"Error installing {proton_type} proton {version}: {e}")
196194
return False, str(e)
197195

198196
def install_custom_tar(self, tar_path, version, progress_callback=None):
@@ -226,6 +224,7 @@ def install_custom_tar(self, tar_path, version, progress_callback=None):
226224
return True, "Success"
227225
except Exception as e:
228226
logging.error(f"Error installing custom tar: {e}")
227+
print(f"Error installing custom tar: {e}")
229228
return False, str(e)
230229

231230
def install_custom_folder(self, src_folder, version):
@@ -239,6 +238,7 @@ def install_custom_folder(self, src_folder, version):
239238
return True, "Success"
240239
except Exception as e:
241240
logging.error(f"Error installing custom folder: {e}")
241+
print(f"Error installing custom folder: {e}")
242242
return False, str(e)
243243

244244
def remove_proton(self, version):
@@ -251,6 +251,7 @@ def remove_proton(self, version):
251251
return True
252252
except Exception as e:
253253
logging.error(f"Error removing proton: {e}")
254+
print(f"Error removing proton: {e}")
254255
return False
255256

256257
def check_update(self, version, proton_type):

0 commit comments

Comments
 (0)