look for certs in bundled location

This commit is contained in:
Damien Elmes 2012-06-03 21:44:04 +09:00
parent bc36aace81
commit c8b2b5ff87

View file

@ -13,7 +13,6 @@ from anki.lang import _
from hooks import runHook from hooks import runHook
# syncing vars # syncing vars
HTTP_CERTS = os.path.join(os.path.dirname(__file__), "ankiweb.certs")
HTTP_TIMEOUT = 30 HTTP_TIMEOUT = 30
HTTP_PROXY = None HTTP_PROXY = None
@ -21,8 +20,20 @@ HTTP_PROXY = None
###################################################################### ######################################################################
def httpCon(): def httpCon():
certs = os.path.join(os.path.dirname(__file__), "ankiweb.certs")
if not os.path.exists(certs):
if isWin:
certs = os.path.join(
os.path.dirname(os.path.abspath(sys.argv[0])),
"ankiweb.certs")
elif isMac:
certs = os.path.join(
os.path.dirname(os.path.abspath(sys.argv[0])),
"../Resources/ankiweb.certs")
else:
assert 0
return httplib2.Http( return httplib2.Http(
timeout=HTTP_TIMEOUT, ca_certs=HTTP_CERTS, timeout=HTTP_TIMEOUT, ca_certs=certs,
proxy_info=HTTP_PROXY) proxy_info=HTTP_PROXY)
# Proxy handling # Proxy handling