@@ -19,7 +19,7 @@ def fetch_data(tag) -> dict:
19
19
url = PROTONGE_URL + (f'/tags/{ tag } ' if tag else '/latest' )
20
20
data = requests .get (url ).json ()
21
21
if 'tag_name' not in data :
22
- return None # invalid tag
22
+ return {} # invalid tag
23
23
24
24
values = {'version' : data ['tag_name' ], 'date' : data ['published_at' ].split ('T' )[0 ]}
25
25
for asset in data ['assets' ]:
@@ -86,7 +86,7 @@ def installed_versions() -> list:
86
86
return versions_found
87
87
88
88
89
- def get_proton (version = None , yes = True , dl_only = False , output = None ) -> None :
89
+ def get_proton (version = None , yes = True , dl_only = False , output = None ) -> bool :
90
90
"""Download and (optionally) install Proton"""
91
91
installdir = install_directory ()
92
92
data = fetch_data (tag = version )
@@ -96,7 +96,7 @@ def get_proton(version=None, yes=True, dl_only=False, output=None) -> None:
96
96
print ('[ERROR] invalid tag / binary not found' )
97
97
return False
98
98
99
- protondir = installdir + 'Proton-' + data ['version' ]
99
+ protondir = installdir + data ['version' ]
100
100
checksum_dir = protondir + '/sha512sum'
101
101
source_checksum = requests .get (data ['checksum' ]).text if 'checksum' in data else None
102
102
local_checksum = open (checksum_dir ).read () if os .path .exists (checksum_dir ) else None
@@ -106,23 +106,23 @@ def get_proton(version=None, yes=True, dl_only=False, output=None) -> None:
106
106
if local_checksum and source_checksum :
107
107
if local_checksum in source_checksum :
108
108
if not yes :
109
- print (f"[INFO] Proton- { data ['version' ]} already installed" )
109
+ print (f"[INFO] { data ['version' ]} already installed" )
110
110
print ("[INFO] No hotfix found" )
111
- return
111
+ return False
112
112
elif not yes :
113
113
print ("[INFO] Hotfix available" )
114
114
else :
115
115
if not yes :
116
- print (f"[INFO] Proton- { data ['version' ]} already installed" )
117
- return
116
+ print (f"[INFO] { data ['version' ]} already installed" )
117
+ return False
118
118
119
119
# Confirmation
120
120
if not yes :
121
- print (f"Ready to download Proton- { data ['version' ]} " ,
121
+ print (f"Ready to download { data ['version' ]} " ,
122
122
f"\n Size : { readable_size (data ['size' ])} " ,
123
123
f"\n Published : { data ['date' ]} " )
124
124
if input ("Continue? (Y/n): " ) not in ['y' , 'Y' , '' ]:
125
- return
125
+ return False
126
126
127
127
# Prepare Destination
128
128
destination = output if output else (os .getcwd () if dl_only else TEMP_DIR )
@@ -135,14 +135,14 @@ def get_proton(version=None, yes=True, dl_only=False, output=None) -> None:
135
135
if not download (url = data ['download' ], destination = destination , show_progress = not yes ):
136
136
if not yes :
137
137
print ("[ERROR] Download failed" )
138
- return
138
+ return True
139
139
140
140
download_checksum = sha512sum (destination )
141
141
if source_checksum and (download_checksum not in source_checksum ):
142
142
if not yes :
143
143
print ("[ERROR] Checksum verification failed" )
144
144
shutil .rmtree (TEMP_DIR , ignore_errors = True )
145
- return
145
+ return True
146
146
147
147
# Installation
148
148
if not dl_only :
@@ -158,12 +158,12 @@ def get_proton(version=None, yes=True, dl_only=False, output=None) -> None:
158
158
# Clean up
159
159
shutil .rmtree (TEMP_DIR , ignore_errors = True )
160
160
161
+ return True
162
+
161
163
162
164
def remove_proton (version = None ) -> bool :
163
165
"""Uninstall existing proton installation"""
164
- if not version .startswith ("Proton-" ):
165
- version = "Proton-" + version
166
- target = install_directory () + version
166
+ target = install_directory () + str (version )
167
167
if os .path .exists (target ):
168
168
shutil .rmtree (target )
169
169
return True
0 commit comments