mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-01-18 16:40:41 -06:00
Updated requests fix to match with pyinstaller later. #309
This commit is contained in:
parent
a58187e5f7
commit
073ccbf6c7
@ -13,7 +13,7 @@ def setup():
|
||||
if hasattr(sys, "frozen"):
|
||||
fix_libloader.fix()
|
||||
fix_win32com.fix()
|
||||
fix_requests.fix(True)
|
||||
else:
|
||||
fix_requests.fix(False)
|
||||
fix_requests.fix()
|
||||
# else:
|
||||
# fix_requests.fix(False)
|
||||
fix_urllib3_warnings.fix()
|
@ -1,27 +1,12 @@
|
||||
from __future__ import unicode_literals
|
||||
from requests import certs, utils, adapters
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import requests
|
||||
import paths
|
||||
import config
|
||||
import requests.sessions
|
||||
orig_session_init=requests.sessions.Session.__init__
|
||||
import os
|
||||
import logging
|
||||
log = logging.getLogger("fixes.fix_requests")
|
||||
|
||||
def patched_where():
|
||||
return paths.app_path(u"cacert.pem")
|
||||
|
||||
def fix(frozen):
|
||||
if frozen==True:
|
||||
certs.where=patched_where
|
||||
utils.DEFAULT_CA_BUNDLE_PATH=patched_where()
|
||||
adapters.DEFAULT_CA_BUNDLE_PATH=patched_where()
|
||||
requests.sessions.Session.__init__=patched_session_init
|
||||
requests.Session.__init__=patched_session_init
|
||||
requests.session.__init__=patched_session_init
|
||||
|
||||
def patched_session_init(self):
|
||||
orig_session_init(self)
|
||||
if config.app["proxy"]["server"] != "" and config.app["proxy"]["port"] != "" and config.app["proxy"]["type"] in config.proxyTypes:
|
||||
self.proxies={"http":"{0}://{1}:{2}/".format(config.app["proxy"]["type"], config.app["proxy"]["server"], config.app["proxy"]["port"]),
|
||||
"https": "{0}://{1}:{2}/".format(config.app["proxy"]["type"], config.app["proxy"]["server"], config.app["proxy"]["port"])}
|
||||
if config.app["proxy"]["user"] != "" and config.app["proxy"]["password"] != "":
|
||||
self.proxies={"http": "{0}://{1}:{2}@{3}:{4}/".format(config.app["proxy"]["type"], config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"]),
|
||||
"https": "{0}://{1}:{2}@{3}:{4}/".format(config.app["proxy"]["type"], config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"])}
|
||||
def fix():
|
||||
log.debug("Applying fix for requests...")
|
||||
os.environ["REQUESTS_CA_BUNDLE"] = os.path.join(paths.app_path(), "certifi", "cacert.pem")#.encode(paths.fsencoding)
|
||||
# log.debug("Changed CA path to %s" % (os.environ["REQUESTS_CA_BUNDLE"]))#.decode(paths.fsencoding)))
|
Loading…
x
Reference in New Issue
Block a user