2
2
import socket
3
3
from threading import Lock , Timer
4
4
from contextlib import contextmanager
5
+ import sys
5
6
6
7
try :
7
8
# Python 3
@@ -210,11 +211,34 @@ def fetch(self, url, error_message, prefer_cached=False):
210
211
211
212
url = update_url (url , self .settings .get ('debug' ))
212
213
214
+ # We don't use sublime.platform() here since this is used for
215
+ # the crawler on packagecontrol.io also
216
+ if sys .platform == 'darwin' :
217
+ platform = 'osx'
218
+ elif sys .platform == 'win32' :
219
+ platform = 'windows'
220
+ else :
221
+ platform = 'linux'
222
+
223
+ downloader_precedence = self .settings .get ('downloader_precedence' , {})
224
+ downloader_list = downloader_precedence .get (platform , [])
225
+
226
+ if not isinstance (downloader_list , list ) or len (downloader_list ) == 0 :
227
+ error_string = text .format (
228
+ u'''
229
+ No list of preferred downloaders specified in the
230
+ "downloader_precedence" setting for the platform "%s"
231
+ ''' ,
232
+ platform
233
+ )
234
+ show_error (error_string )
235
+ raise DownloaderException (error_string )
236
+
213
237
# Make sure we have a downloader, and it supports SSL if we need it
214
238
if not self .downloader or (is_ssl and not self .downloader .supports_ssl ()):
215
- for downloader_class in DOWNLOADERS :
239
+ for downloader_name in downloader_list :
216
240
try :
217
- downloader = downloader_class (self .settings )
241
+ downloader = DOWNLOADERS [ downloader_name ] (self .settings )
218
242
if is_ssl and not downloader .supports_ssl ():
219
243
continue
220
244
self .downloader = downloader
@@ -225,10 +249,14 @@ def fetch(self, url, error_message, prefer_cached=False):
225
249
if not self .downloader :
226
250
error_string = text .format (
227
251
u'''
228
- Unable to download %s due to no ssl module available and no
229
- capable program found.
252
+ None of the preferred downloaders can download %s.
253
+
254
+ This is usually either because the ssl module is unavailable
255
+ and/or the command line curl or wget executables could not be
256
+ found in the PATH.
230
257
231
- Please install curl or wget.
258
+ If you customized the "downloader_precedence" setting, please
259
+ verify your customization.
232
260
''' ,
233
261
url
234
262
)
0 commit comments