Added logic to find CA certs for SSL connections (for frozen apps) and added some logging

This commit is contained in:
blitzmann
2015-10-24 23:32:15 -04:00
parent c04b7e0552
commit 167eb60fe3
4 changed files with 20 additions and 4 deletions

View File

@@ -94,6 +94,9 @@ def defPaths():
__createDirs(savePath)
if isFrozen():
os.environ["REQUESTS_CA_BUNDLE"] = os.path.join(pyfaPath, "cacert.pem")
format = '%(asctime)s %(name)-24s %(levelname)-8s %(message)s'
logging.basicConfig(format=format, level=logLevel)
handler = logging.handlers.RotatingFileHandler(os.path.join(savePath, "log.txt"), maxBytes=1000000, backupCount=3)

View File

@@ -10,7 +10,9 @@ import service
from service.server import *
import config
from gui.utils.repeatedTimer import RepeatedTimer
import logging
logger = logging.getLogger(__name__)
class Crest():
@@ -29,6 +31,7 @@ class Crest():
def __init__(self):
self.settings = service.settings.CRESTSettings.getInstance()
self.httpd = StoppableHTTPServer(('', 6461), AuthHandler)
logger.debug(self.httpd)
self.scopes = ['characterFittingsRead', 'characterFittingsWrite']
self.state = None
@@ -96,15 +99,15 @@ class Crest():
return self.eve.auth_uri(scopes=self.scopes, state=self.state)
def handleLogin(self, message):
self.httpd.stop()
if not message:
return
if message['state'][0] != self.state:
print "state mismatch"
logger.warn("OAUTH state mismatch")
return
print "handling login by making characters and stuff"
print message
logger.debug("Handling CREST login with: %s"%message)
if 'access_token' in message: # implicit
eve = copy.copy(self.eve)
@@ -117,6 +120,9 @@ class Crest():
eve()
info = eve.whoami()
logger.debug("Got character info: %s" % info)
self.implicitCharacter = CrestUser(info['CharacterID'], info['CharacterName'])
self.implicitCharacter.eve = eve
self.implicitCharacter.fetchImage()
@@ -128,6 +134,8 @@ class Crest():
eve()
info = eve.whoami()
logger.debug("Got character info: %s" % info)
# check if we have character already. If so, simply replace refresh_token
char = self.getCrestCharacter(int(info['CharacterID']))
if char:

View File

@@ -9,6 +9,10 @@ from wx.lib.pubsub import pub
from html import HTML
import logging
logger = logging.getLogger(__name__)
# https://github.com/fuzzysteve/CREST-Market-Downloader/
class AuthHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):

View File

@@ -4,11 +4,12 @@ Distribution builder for pyfa.
Windows executable: python setup.py build
Windows executable + installer: python setup.py bdist_msi
"""
import requests.certs
# The modules that contain the bulk of teh source
packages = ['eos', 'gui', 'service', 'utils']
# Extra files that will be copied into the root directory
include_files = ['eve.db', 'LICENSE', 'README.md']
include_files = ['eve.db', 'LICENSE', 'README.md', (requests.certs.where(),'cacert.pem')]
# this is read by dist.py to package the icons
icon_dirs = ['gui', 'icons', 'renders']