|
1 | | -import platform, urllib2, os, sys, zipfile, stat, tempfile |
| 1 | +import platform, os, sys, zipfile, stat, tempfile |
2 | 2 | from browserstack.bserrors import BrowserStackLocalError |
3 | 3 |
|
| 4 | +try: |
| 5 | + from urllib.request import urlopen |
| 6 | +except ImportError: |
| 7 | + from urllib2 import urlopen |
| 8 | + |
4 | 9 | class LocalBinary: |
5 | 10 | def __init__(self): |
6 | 11 | is_64bits = sys.maxsize > 2**32 |
7 | 12 | osname = platform.system() |
8 | 13 | if osname == 'Darwin': |
9 | | - self.http_path = "https://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-darwin-x64" |
| 14 | + self.http_path = "https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-darwin-x64" |
10 | 15 | elif osname == 'Linux': |
11 | 16 | if is_64bits: |
12 | | - self.http_path = "https://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-linux-x64" |
| 17 | + self.http_path = "https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-linux-x64" |
13 | 18 | else: |
14 | | - self.http_path = "https://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-linux-ia32" |
| 19 | + self.http_path = "https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-linux-ia32" |
15 | 20 | else: |
16 | | - self.http_path = "https://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal.exe" |
| 21 | + self.http_path = "https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-win32.exe" |
17 | 22 |
|
18 | 23 | self.ordered_paths = [ |
19 | 24 | os.path.join(os.path.expanduser('~'), '.browserstack'), |
@@ -41,8 +46,11 @@ def __available_dir(self): |
41 | 46 | raise BrowserStackLocalError('Error trying to download BrowserStack Local binary') |
42 | 47 |
|
43 | 48 | def download(self, chunk_size=8192, progress_hook=None): |
44 | | - response = urllib2.urlopen(self.http_path) |
45 | | - total_size = int(response.info().getheader('Content-Length').strip()) |
| 49 | + response = urlopen(self.http_path) |
| 50 | + try: |
| 51 | + total_size = int(response.info().getheader('Content-Length').strip()) |
| 52 | + except: |
| 53 | + total_size = int(response.info().get_all('Content-Length')[0].strip()) |
46 | 54 | bytes_so_far = 0 |
47 | 55 |
|
48 | 56 | dest_parent_dir = self.__available_dir() |
|
0 commit comments