Skip to content

Commit

Permalink
Merge pull request #84 from socketubs/ssl
Browse files Browse the repository at this point in the history
SSL FUCK YEAH
  • Loading branch information
Geoffrey Lehée committed Nov 2, 2014
2 parents 4641dad + 3fb6e4a commit fede02c
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 14 deletions.
Empty file added .no-sublime-package
Empty file.
35 changes: 34 additions & 1 deletion Sublimall.py
Original file line number Diff line number Diff line change
@@ -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])
Expand Down
Binary file not shown.
Binary file not shown.
Binary file added lib/st3_linux_x32/libssl-10/_ssl.cpython-33m.so
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added lib/st3_linux_x64/libssl-10/_ssl.cpython-33m.so
Binary file not shown.
2 changes: 1 addition & 1 deletion sublimall/__init__.py
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion sublimall/commands/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion sublimall/commands/retrieve_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
17 changes: 10 additions & 7 deletions sublimall/commands/upload_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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))

Expand Down
1 change: 1 addition & 0 deletions sublimall/reloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

mods_load_order = [
'',
'.requests',
'.archiver',
'.blacklist',
'.logger',
Expand Down
2 changes: 0 additions & 2 deletions sublimall/requests/packages/urllib3/connectionpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
class BaseSSLError(BaseException):
pass

ssl = None

try: # Python 3
from http.client import HTTPSConnection
except ImportError:
Expand Down
2 changes: 1 addition & 1 deletion sublimall/requests/packages/urllib3/contrib/pyopenssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fede02c

Please sign in to comment.