|
3 | 3 | """Implements various Helper functions"""
|
4 | 4 |
|
5 | 5 | from __future__ import absolute_import, division, unicode_literals
|
| 6 | + |
6 | 7 | import os
|
7 | 8 | import re
|
8 |
| -from time import time |
| 9 | +import struct |
| 10 | +from functools import total_ordering |
9 | 11 | from socket import timeout
|
10 | 12 | from ssl import SSLError
|
11 |
| -import struct |
| 13 | +from time import time |
12 | 14 | from typing import NamedTuple
|
13 |
| -from functools import total_ordering |
14 |
| - |
15 |
| -try: # Python 3 |
16 |
| - from urllib.error import HTTPError, URLError |
17 |
| - from urllib.request import Request, urlopen |
18 |
| -except ImportError: # Python 2 |
19 |
| - from urllib2 import HTTPError, Request, URLError, urlopen |
| 15 | +from urllib.error import HTTPError, URLError |
| 16 | +from urllib.request import Request, urlopen |
20 | 17 |
|
21 | 18 | from . import config
|
22 |
| -from .kodiutils import (bg_progress_dialog, copy, delete, exists, get_setting, localize, log, mkdirs, |
23 |
| - progress_dialog, set_setting, stat_file, translate_path, yesno_dialog) |
| 19 | +from .kodiutils import (bg_progress_dialog, copy, delete, exists, get_setting, |
| 20 | + localize, log, mkdirs, progress_dialog, set_setting, |
| 21 | + stat_file, translate_path, yesno_dialog) |
24 | 22 | from .unicodes import compat_path, from_unicode, to_unicode
|
25 | 23 |
|
26 | 24 |
|
@@ -123,7 +121,7 @@ def http_head(url):
|
123 | 121 | def http_download(url, message=None, checksum=None, hash_alg='sha1', dl_size=None, background=False): # pylint: disable=too-many-statements
|
124 | 122 | """Makes HTTP request and displays a progress dialog on download."""
|
125 | 123 | if checksum:
|
126 |
| - from hashlib import sha1, md5 |
| 124 | + from hashlib import md5, sha1 |
127 | 125 | if hash_alg == 'sha1':
|
128 | 126 | calc_checksum = sha1()
|
129 | 127 | elif hash_alg == 'md5':
|
@@ -324,7 +322,6 @@ def arch():
|
324 | 322 | sys_arch = 'x86' # else, sys_arch = AMD64
|
325 | 323 |
|
326 | 324 | elif 'armv' in sys_arch:
|
327 |
| - import re |
328 | 325 | arm_version = re.search(r'\d+', sys_arch.split('v')[1])
|
329 | 326 | if arm_version:
|
330 | 327 | sys_arch = 'armv' + arm_version.group()
|
|
0 commit comments