Merge branch 'master' into singularity
This commit is contained in:
@@ -123,6 +123,7 @@ class SkillBackupThread(threading.Thread):
|
||||
|
||||
wx.CallAfter(self.callback)
|
||||
|
||||
|
||||
class Character(object):
|
||||
instance = None
|
||||
skillReqsDict = {}
|
||||
|
||||
@@ -17,7 +17,6 @@ from service.server import StoppableHTTPServer, AuthHandler
|
||||
from service.settings import EsiSettings
|
||||
from service.esiAccess import EsiAccess
|
||||
|
||||
import wx
|
||||
from requests import Session
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
@@ -108,7 +107,8 @@ class Esi(EsiAccess):
|
||||
serverAddr = None
|
||||
# always start the local server if user is using client details. Otherwise, start only if they choose to do so.
|
||||
if self.settings.get('ssoMode') == SsoMode.CUSTOM or self.settings.get('loginMode') == LoginMethod.SERVER:
|
||||
serverAddr = self.startServer(6461 if self.settings.get('ssoMode') == SsoMode.CUSTOM else 0) # random port, or if it's custom application, use a defined port
|
||||
# random port, or if it's custom application, use a defined port
|
||||
serverAddr = self.startServer(6461 if self.settings.get('ssoMode') == SsoMode.CUSTOM else 0)
|
||||
uri = self.getLoginURI(serverAddr)
|
||||
webbrowser.open(uri)
|
||||
wx.PostEvent(self.mainFrame, GE.SsoLoggingIn(sso_mode=self.settings.get('ssoMode'), login_mode=self.settings.get('loginMode')))
|
||||
@@ -181,4 +181,3 @@ class Esi(EsiAccess):
|
||||
pyfalog.debug("Handling SSO login with: {0}", message)
|
||||
|
||||
self.handleLogin(message)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import base64
|
||||
|
||||
import datetime
|
||||
from eos.enum import Enum
|
||||
from service.settings import EsiSettings
|
||||
from service.settings import EsiSettings, NetworkSettings
|
||||
|
||||
from requests import Session
|
||||
from urllib.parse import urlencode, quote
|
||||
@@ -85,6 +85,7 @@ class EsiAccess(object):
|
||||
'pyfa v{}'.format(config.version)
|
||||
)
|
||||
})
|
||||
self._session.proxies = NetworkSettings.getInstance().getProxySettingsInRequestsFormat()
|
||||
|
||||
@property
|
||||
def sso_url(self):
|
||||
@@ -180,7 +181,7 @@ class EsiAccess(object):
|
||||
data = {
|
||||
'grant_type': 'refresh_token',
|
||||
'refresh_token': refreshToken,
|
||||
}
|
||||
}
|
||||
|
||||
if self.settings.get('ssoMode') == SsoMode.AUTO:
|
||||
# data is all we really need, the rest is handled automatically by pyfa.io
|
||||
@@ -281,4 +282,3 @@ class EsiAccess(object):
|
||||
self._before_request(ssoChar)
|
||||
endpoint = endpoint.format(**kwargs)
|
||||
return self._after_request(self._session.delete("{}{}".format(self.esi_url, endpoint)))
|
||||
|
||||
|
||||
@@ -1209,11 +1209,9 @@ class Fit(object):
|
||||
start_time = time()
|
||||
pyfalog.info("=" * 10 + "recalc: {0}" + "=" * 10, fit.name)
|
||||
|
||||
|
||||
fit.factorReload = self.serviceFittingOptions["useGlobalForceReload"]
|
||||
fit.clear()
|
||||
|
||||
fit.calculateModifiedAttributes()
|
||||
|
||||
pyfalog.info("=" * 10 + "recalc time: " + str(time() - start_time) + "=" * 10)
|
||||
|
||||
|
||||
@@ -20,17 +20,18 @@
|
||||
import config
|
||||
import pkg_resources
|
||||
|
||||
|
||||
class Jargon(object):
|
||||
def __init__(self, rawdata: dict):
|
||||
self._rawdata = rawdata
|
||||
|
||||
# copy the data to lowercase keys, ignore blank keys
|
||||
self._data = {str(k).lower():v for k,v in rawdata.items() if k}
|
||||
self._data = {str(k).lower(): v for k, v in rawdata.items() if k}
|
||||
|
||||
def get(self, term: str) -> str:
|
||||
return self._data.get(term.lower())
|
||||
|
||||
def get_rawdata() -> dict:
|
||||
def get_rawdata(self) -> dict:
|
||||
return self._rawdata
|
||||
|
||||
def apply(self, query):
|
||||
|
||||
@@ -26,11 +26,12 @@ from .resources import DEFAULT_DATA, DEFAULT_HEADER
|
||||
|
||||
JARGON_PATH = os.path.join(config.savePath, 'jargon.yaml')
|
||||
|
||||
|
||||
class JargonLoader(object):
|
||||
def __init__(self, jargon_path: str):
|
||||
self.jargon_path = jargon_path
|
||||
self._jargon_mtime = 0 # type: int
|
||||
self._jargon = None # type: Jargon
|
||||
self._jargon_mtime = 0 # type: int
|
||||
self._jargon = None # type: Jargon
|
||||
|
||||
def get_jargon(self) -> Jargon:
|
||||
if self._is_stale():
|
||||
@@ -58,7 +59,7 @@ class JargonLoader(object):
|
||||
def init_user_jargon(jargon_path):
|
||||
values = yaml.load(DEFAULT_DATA)
|
||||
|
||||
## Disabled for issue/1533; do not overwrite existing user config
|
||||
# Disabled for issue/1533; do not overwrite existing user config
|
||||
# if os.path.exists(jargon_path):
|
||||
# with open(jargon_path) as f:
|
||||
# custom_values = yaml.load(f)
|
||||
@@ -72,6 +73,7 @@ class JargonLoader(object):
|
||||
yaml.dump(values, stream=f, default_flow_style=False)
|
||||
|
||||
_instance = None
|
||||
|
||||
@staticmethod
|
||||
def instance(jargon_path=None):
|
||||
if not JargonLoader._instance:
|
||||
@@ -79,4 +81,5 @@ class JargonLoader(object):
|
||||
JargonLoader._instance = JargonLoader(jargon_path)
|
||||
return JargonLoader._instance
|
||||
|
||||
|
||||
JargonLoader.init_user_jargon(JARGON_PATH)
|
||||
|
||||
@@ -41,6 +41,7 @@ pyfalog = Logger(__name__)
|
||||
# Event which tells threads dependent on Market that it's initialized
|
||||
mktRdy = threading.Event()
|
||||
|
||||
|
||||
class ShipBrowserWorkerThread(threading.Thread):
|
||||
def __init__(self):
|
||||
threading.Thread.__init__(self)
|
||||
@@ -113,10 +114,8 @@ class SearchWorkerThread(threading.Thread):
|
||||
else:
|
||||
filter_ = None
|
||||
|
||||
|
||||
jargon_request = self.jargonLoader.get_jargon().apply(request)
|
||||
|
||||
|
||||
results = []
|
||||
if len(request) >= config.minItemSearchLength:
|
||||
results = eos.db.searchItems(request, where=filter_,
|
||||
|
||||
@@ -35,7 +35,7 @@ class EveMarketData(object):
|
||||
def __init__(self, types, system, priceMap):
|
||||
data = {}
|
||||
baseurl = "https://eve-marketdata.com/api/item_prices.xml"
|
||||
data["system_id"] = system # Use Jita for market
|
||||
data["system_id"] = system # Use Jita for market
|
||||
data["type_ids"] = ','.join(str(x) for x in types)
|
||||
|
||||
network = Network.getInstance()
|
||||
|
||||
@@ -93,25 +93,7 @@ class Network(object):
|
||||
# or with HTTP Basic auth support: proxies = {'http': 'http://user:pass@10.10.1.10:3128/'}
|
||||
# then you do: requests.get('http://example.org', proxies=proxies)
|
||||
|
||||
proxies = None
|
||||
proxy_settings = NetworkSettings.getInstance().getProxySettings()
|
||||
# proxy_settings is a tuple of (host, port), like ('192.168.20.1', 3128), or None
|
||||
|
||||
if proxy_settings is not None:
|
||||
# form proxy address in format "http://host:port
|
||||
proxy_host_port = '{}:{}'.format(proxy_settings[0], proxy_settings[1])
|
||||
proxy_auth_details = NetworkSettings.getInstance().getProxyAuthDetails()
|
||||
# proxy_auth_details is a tuple of (login, password), or None
|
||||
user_pass = ''
|
||||
if proxy_auth_details is not None:
|
||||
# construct prefix in form "user:password@"
|
||||
user_pass = '{}:{}@'.format(proxy_auth_details[0], proxy_auth_details[1])
|
||||
proxies = {
|
||||
'http': 'http://' + user_pass + proxy_host_port,
|
||||
'https': 'http://' + user_pass + proxy_host_port
|
||||
}
|
||||
# final form: { 'http': 'http://user:password@host:port', ... }, or
|
||||
# { 'http': 'http://host:port', ... } if no auth info.
|
||||
proxies = NetworkSettings.getInstance().getProxySettingsInRequestsFormat()
|
||||
|
||||
try:
|
||||
resp = requests.get(url, headers=headers, proxies=proxies, **kwargs)
|
||||
|
||||
@@ -58,6 +58,7 @@ from collections import OrderedDict
|
||||
class ESIExportException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
EFT_SLOT_ORDER = [Slot.LOW, Slot.MED, Slot.HIGH, Slot.RIG, Slot.SUBSYSTEM, Slot.SERVICE]
|
||||
@@ -349,7 +350,6 @@ class Port(object):
|
||||
|
||||
nested_dict = lambda: collections.defaultdict(nested_dict)
|
||||
fit = nested_dict()
|
||||
sEsi = Esi.getInstance()
|
||||
sFit = svcFit.getInstance()
|
||||
|
||||
# max length is 50 characters
|
||||
|
||||
@@ -103,11 +103,18 @@ class AuthHandler(http.server.BaseHTTPRequestHandler):
|
||||
def log_message(self, format, *args):
|
||||
return
|
||||
|
||||
import socketserver
|
||||
|
||||
# http://code.activestate.com/recipes/425210-simple-stoppable-server-using-socket-timeout/
|
||||
class StoppableHTTPServer(http.server.HTTPServer):
|
||||
class StoppableHTTPServer(socketserver.TCPServer):
|
||||
def server_bind(self):
|
||||
http.server.HTTPServer.server_bind(self)
|
||||
# Can't use HTTPServer due to reliance on socket.getfqdn() which seems to be bugged.
|
||||
# See https://github.com/pyfa-org/Pyfa/issues/1560#issuecomment-390095101
|
||||
socketserver.TCPServer.server_bind(self)
|
||||
host, port = self.server_address[:2]
|
||||
self.server_name = host
|
||||
self.server_port = port
|
||||
|
||||
# self.settings = CRESTSettings.getInstance()
|
||||
|
||||
# Allow listening for x seconds
|
||||
|
||||
@@ -284,6 +284,23 @@ class NetworkSettings(object):
|
||||
self.serviceNetworkSettings["login"] = login
|
||||
self.serviceNetworkSettings["password"] = password
|
||||
|
||||
def getProxySettingsInRequestsFormat(self) -> dict:
|
||||
proxies = {}
|
||||
proxy_settings = self.getProxySettings()
|
||||
if proxy_settings is not None:
|
||||
# form proxy address in format "http://host:port
|
||||
proxy_host_port = '{}:{}'.format(proxy_settings[0], proxy_settings[1])
|
||||
proxy_auth_details = self.getProxyAuthDetails()
|
||||
user_pass = ''
|
||||
if proxy_auth_details is not None:
|
||||
# construct prefix in form "user:password@"
|
||||
user_pass = '{}:{}@'.format(proxy_auth_details[0], proxy_auth_details[1])
|
||||
proxies = {
|
||||
'http': 'http://' + user_pass + proxy_host_port,
|
||||
'https': 'http://' + user_pass + proxy_host_port
|
||||
}
|
||||
return proxies
|
||||
|
||||
|
||||
class HTMLExportSettings(object):
|
||||
"""
|
||||
|
||||
@@ -49,7 +49,8 @@ class CheckUpdateThread(threading.Thread):
|
||||
|
||||
try:
|
||||
try:
|
||||
response = network.request('https://www.pyfa.io/update_check?pyfa_version={}&client_hash={}'.format(config.version, config.getClientSecret()), network.UPDATE)
|
||||
response = network.request('https://www.pyfa.io/update_check?pyfa_version={}&client_hash={}'.format(
|
||||
config.version, config.getClientSecret()), network.UPDATE)
|
||||
except Exception as e:
|
||||
response = network.request('https://api.github.com/repos/pyfa-org/Pyfa/releases', network.UPDATE)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user