Can now login to SSO from pyfa, which completes basic integration. This is very crude, will be refined.

This commit is contained in:
blitzmann
2015-10-19 20:09:39 -04:00
parent 972df6cad3
commit 8151debfe1
4 changed files with 61 additions and 4 deletions

View File

@@ -1,9 +1,16 @@
import json
import thread
import wx
from wx.lib.pubsub import pub
import service
import gui.display as d
from eos.types import Cargo
from eos.db import getItem
import json
from service.server import *
import config
class CrestFittings(wx.Frame):
@@ -129,6 +136,42 @@ class ExportToEve(wx.Frame):
except ValueError:
self.statusbar.SetStatusText("", 1)
class CrestLogin(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, id=wx.ID_ANY, title="Login", pos=wx.DefaultPosition, size=wx.Size( -1,-1 ), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
self.mainFrame = parent
sCrest = service.Crest.getInstance()
mainSizer = wx.BoxSizer( wx.HORIZONTAL )
self.loginBtn = wx.Button( self, wx.ID_ANY, u"Login via SSO", wx.DefaultPosition, wx.DefaultSize, 5 )
mainSizer.Add( self.loginBtn, 0, wx.ALL, 5 )
self.loginBtn.Bind(wx.EVT_BUTTON, self.startServer)
self.SetSizer(mainSizer)
self.Layout()
pub.subscribe(self.sso_login, 'sso_login')
self.Centre(wx.BOTH)
def sso_login(self, message):
self.httpd.stop()
con = config.pycrest_eve.authorize(message)
sCrest = service.Crest.getInstance()
sCrest.newChar(con)
self.Close()
def startServer(self, event):
self.httpd = StoppableHTTPServer(('', 6461), AuthHandler)
thread.start_new_thread(self.httpd.serve, ())
uri = config.pycrest_eve.auth_uri(scopes=['characterFittingsRead', 'characterFittingsWrite'])
wx.LaunchDefaultBrowser(uri)
class FittingsTreeView(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__ (self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, style=wx.TAB_TRAVERSAL)

View File

@@ -44,7 +44,7 @@ from gui.multiSwitch import MultiSwitch
from gui.statsPane import StatsPane
from gui.shipBrowser import ShipBrowser, FitSelected, ImportSelected, Stage3Selected
from gui.characterEditor import CharacterEditor, SaveCharacterAs
from gui.crestFittings import CrestFittings, ExportToEve
from gui.crestFittings import CrestFittings, ExportToEve, CrestLogin
from gui.characterSelection import CharacterSelection
from gui.patternEditor import DmgPatternEditorDlg
from gui.resistsEditor import ResistsEditorDlg
@@ -420,6 +420,8 @@ class MainFrame(wx.Frame):
self.Bind(wx.EVT_MENU, self.eveFittings, id = menuBar.eveFittingsId)
# Export to EVE
self.Bind(wx.EVT_MENU, self.exportToEve, id = menuBar.exportToEveId)
# Login to EVE
self.Bind(wx.EVT_MENU, self.ssoLogin, id = menuBar.ssoLoginId)
#Clipboard exports
self.Bind(wx.EVT_MENU, self.exportToClipboard, id=wx.ID_COPY)
@@ -488,6 +490,10 @@ class MainFrame(wx.Frame):
dlg=CrestFittings(self)
dlg.Show()
def ssoLogin(self, event):
dlg=CrestLogin(self)
dlg.Show()
def exportToEve(self, event):
dlg=ExportToEve(self)
dlg.Show()

View File

@@ -43,6 +43,7 @@ class MainMenuBar(wx.MenuBar):
self.revertCharId = wx.NewId()
self.eveFittingsId = wx.NewId()
self.exportToEveId = wx.NewId()
self.ssoLoginId = wx.NewId()
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
@@ -108,6 +109,7 @@ class MainMenuBar(wx.MenuBar):
# CREST Menu
crestMenu = wx.Menu()
self.Append(crestMenu, "&CREST")
crestMenu.Append(self.ssoLoginId, "Login To EVE")
crestMenu.Append(self.eveFittingsId, "Browse EVE Fittings")
crestMenu.Append(self.exportToEveId, "Export To EVE")

View File

@@ -1,4 +1,5 @@
import eos.db
from eos.types import Crest as CrestUser
import config
class Crest():
@@ -12,7 +13,6 @@ class Crest():
return cls._instance
def __init__(self):
pass
def getCrestCharacters(self):
@@ -29,6 +29,12 @@ class Crest():
def postFitting(self, charID, json):
char = self.getCrestCharacter(charID)
char.auth()
print char.eve.token
res = char.eve._session.post('https://api-sisi.testeveonline.com/characters/%d/fittings/'%char.ID, data=json)
return res
def newChar(self, connection):
connection()
info = connection.whoami()
char = CrestUser(info['CharacterName'], info['CharacterID'], connection.refresh_token)
eos.db.save(char)