diff --git a/.no-sublime-package b/.no-sublime-package new file mode 100644 index 0000000..e69de29 diff --git a/Sublimall.py b/Sublimall.py index 0150d83..63bc831 100644 --- a/Sublimall.py +++ b/Sublimall.py @@ -1,12 +1,45 @@ # -*- coding: utf-8 -*- +import os import sys +import imp import sublime from imp import reload -if sys.version_info.major == 2: +st_version = 2 +if int(sublime.version()) > 3000: + st_version = 3 + +if st_version == 2: msg = "Sublimall is only available for SublimeText 3.\n Sorry about that." sublime.error_message(msg) +if sublime.platform() == 'linux': + so_name = '_ssl.cpython-33m.so' + arch_lib_path = os.path.join( + os.path.dirname(__file__), + 'lib', + 'st%d_linux_%s' % (st_version, sublime.arch())) + + print('[Sublimall] enabling custom linux ssl module') + for ssl_ver in ['1.0.0', '10', '0.9.8']: + lib_path = os.path.join(arch_lib_path, 'libssl-' + ssl_ver) + sys.path.append(lib_path) + try: + import _ssl + print( + '[Sublimall] successfully loaded _ssl ' + 'module for libssl.so.%s' % ssl_ver) + import http.client + imp.reload(http.client) + break + except (ImportError) as e: + print('[Sublimall] _ssl module import error - ' + str(e)) + if '_ssl' in sys.modules: + try: + import ssl + except (ImportError) as e: + print('[Sublimall] ssl module import error - ' + str(e)) + reloader_name = 'Sublimall.sublimall.reloader' if reloader_name in sys.modules: reload(sys.modules[reloader_name]) diff --git a/lib/st3_linux_x32/libssl-0.9.8/_ssl.cpython-33m.so b/lib/st3_linux_x32/libssl-0.9.8/_ssl.cpython-33m.so new file mode 100644 index 0000000..0d3c9d6 Binary files /dev/null and b/lib/st3_linux_x32/libssl-0.9.8/_ssl.cpython-33m.so differ diff --git a/lib/st3_linux_x32/libssl-1.0.0/_ssl.cpython-33m.so b/lib/st3_linux_x32/libssl-1.0.0/_ssl.cpython-33m.so new file mode 100644 index 0000000..7e97b49 Binary files /dev/null and b/lib/st3_linux_x32/libssl-1.0.0/_ssl.cpython-33m.so differ diff --git a/lib/st3_linux_x32/libssl-10/_ssl.cpython-33m.so b/lib/st3_linux_x32/libssl-10/_ssl.cpython-33m.so new file mode 100644 index 0000000..9eed699 Binary files /dev/null and b/lib/st3_linux_x32/libssl-10/_ssl.cpython-33m.so differ diff --git a/lib/st3_linux_x64/libssl-0.9.8/_ssl.cpython-33m.so b/lib/st3_linux_x64/libssl-0.9.8/_ssl.cpython-33m.so new file mode 100644 index 0000000..42470d2 Binary files /dev/null and b/lib/st3_linux_x64/libssl-0.9.8/_ssl.cpython-33m.so differ diff --git a/lib/st3_linux_x64/libssl-1.0.0/_ssl.cpython-33m.so b/lib/st3_linux_x64/libssl-1.0.0/_ssl.cpython-33m.so new file mode 100644 index 0000000..f5b7274 Binary files /dev/null and b/lib/st3_linux_x64/libssl-1.0.0/_ssl.cpython-33m.so differ diff --git a/lib/st3_linux_x64/libssl-10/_ssl.cpython-33m.so b/lib/st3_linux_x64/libssl-10/_ssl.cpython-33m.so new file mode 100644 index 0000000..acb05eb Binary files /dev/null and b/lib/st3_linux_x64/libssl-10/_ssl.cpython-33m.so differ diff --git a/sublimall/__init__.py b/sublimall/__init__.py index de3e44d..0313beb 100644 --- a/sublimall/__init__.py +++ b/sublimall/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -__version_info__ = (0, 0, 23) +__version_info__ = (0, 0, 24) __version__ = '.'.join(str(x) for x in __version_info__) SETTINGS_USER_FILE = "Sublimall.sublime-settings" diff --git a/sublimall/commands/command.py b/sublimall/commands/command.py index 1a2ae5d..d99e495 100644 --- a/sublimall/commands/command.py +++ b/sublimall/commands/command.py @@ -26,7 +26,7 @@ class CommandWithStatus(object): """ def __init__(self, *args, **kwargs): self._messageStatus = MessageStatus() - sublime.set_timeout(lambda: self.unset_message, 1000) + sublime.set_timeout(lambda: self.unset_message, 3000) super().__init__(*args, **kwargs) def set_timed_message(self, message, time=7, clear=False): diff --git a/sublimall/commands/retrieve_command.py b/sublimall/commands/retrieve_command.py index 2e1b186..5282209 100644 --- a/sublimall/commands/retrieve_command.py +++ b/sublimall/commands/retrieve_command.py @@ -171,7 +171,8 @@ def retrieve_from_server(self): pass show_report( 'Unhandled Http error while ' - 'downloading (%s).\n\n%s' % (r.status_code, r.content)) + 'downloading (%s).\n\n%s' % (r.status_code, r.content), + exception=False) self.set_timed_message(msg, clear=True, time=10) logger.error("HTTP [%s] %s" % (r.status_code, r.content)) diff --git a/sublimall/commands/upload_command.py b/sublimall/commands/upload_command.py index 66f65f3..0b2795c 100644 --- a/sublimall/commands/upload_command.py +++ b/sublimall/commands/upload_command.py @@ -78,23 +78,26 @@ def get_max_package_size(self): if r.json().get('success'): return r.json().get('output') else: - self.set_timed_message("Bad credentials", clear=True) - logger.info('Bad credentials') + self.set_timed_message("Bad credentials.", clear=True) + self.running = False + logger.info('Bad credentials.') except Exception as err: - self.set_timed_message("Error while retrieving max package size") + self.set_timed_message( + "Error while retrieving max package size.", clear=True) + self.running = False logger.error( - 'Server: %s\nHttp code: %s\n' + 'Server: %s\n' '==========[EXCEPTION]==========\n' '%s\n' '===============================' % ( - self.api_max_package_size_url, r.status_code, err)) + self.api_max_package_size_url, err)) def send_to_api(self): """ Send archive file to API """ if not os.path.exists(self.archive_filename): - msg = "Error while sending archive: archive not found" + msg = "Error while sending archive: archive not found." self.set_timed_message(msg) show_report( msg + '\n' + 'Path:%s' % self.archive_filename, @@ -205,7 +208,7 @@ def send_to_api(self): except: pass show_report('Unhandled Http error while uploading (%s).\n\n%s' % ( - r.status_code, r.content)) + r.status_code, r.content), exception=False) self.set_timed_message(msg, clear=True, time=10) logger.error('HTTP [%s] %s' % (r.status_code, r.content)) diff --git a/sublimall/reloader.py b/sublimall/reloader.py index d2ec4ef..62636da 100644 --- a/sublimall/reloader.py +++ b/sublimall/reloader.py @@ -21,6 +21,7 @@ mods_load_order = [ '', + '.requests', '.archiver', '.blacklist', '.logger', diff --git a/sublimall/requests/packages/urllib3/connectionpool.py b/sublimall/requests/packages/urllib3/connectionpool.py index 030eae8..88d4afe 100644 --- a/sublimall/requests/packages/urllib3/connectionpool.py +++ b/sublimall/requests/packages/urllib3/connectionpool.py @@ -30,8 +30,6 @@ class BaseSSLError(BaseException): pass - ssl = None - try: # Python 3 from http.client import HTTPSConnection except ImportError: diff --git a/sublimall/requests/packages/urllib3/contrib/pyopenssl.py b/sublimall/requests/packages/urllib3/contrib/pyopenssl.py index 6d0255f..295b9fc 100644 --- a/sublimall/requests/packages/urllib3/contrib/pyopenssl.py +++ b/sublimall/requests/packages/urllib3/contrib/pyopenssl.py @@ -26,7 +26,7 @@ import OpenSSL.SSL from pyasn1.codec.der import decoder as der_decoder from socket import _fileobject -import ssl +import _ssl as ssl from .. import connectionpool from .. import util