Exemplo n.º 1
0
 def delChar(self, event):
     item = self.lcCharacters.GetFirstSelected()
     if item > -1:
         charID = self.lcCharacters.GetItemData(item)
         sEsi = Esi.getInstance()
         sEsi.delSsoCharacter(charID)
         self.popCharList()
Exemplo n.º 2
0
    def populateSkillTree(self, data):
        if data is None:
            return
        root = self.root
        tree = self.fittingsTreeCtrl
        tree.DeleteChildren(root)

        sEsi = Esi.getInstance()

        dict = {}
        fits = data
        for fit in fits:
            if fit['fitting_id'] in sEsi.fittings_deleted:
                continue
            ship = getItem(fit['ship_type_id'])
            if ship is None:
                pyfalog.debug('Cannot find ship type id: {}'.format(fit['ship_type_id']))
                continue
            if ship.name not in dict:
                dict[ship.name] = []
            dict[ship.name].append(fit)

        for name, fits in dict.items():
            shipID = tree.AppendItem(root, name)
            for fit in fits:
                fitId = tree.AppendItem(shipID, fit['name'])
                tree.SetItemData(fitId, json.dumps(fit))

        tree.SortChildren(root)
Exemplo n.º 3
0
    def __init__(self):
        mainFrame = gui.mainFrame.MainFrame.getInstance()

        wx.Dialog.__init__(self, mainFrame, id=wx.ID_ANY, title="SSO Login", size=wx.Size(400, 240))

        bSizer1 = wx.BoxSizer(wx.VERTICAL)

        text = wx.StaticText(self, wx.ID_ANY, "Copy and paste the block of text provided by pyfa.io, then click OK")
        bSizer1.Add(text, 0, wx.ALL | wx.EXPAND, 10)

        self.ssoInfoCtrl = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, (-1, -1), style=wx.TE_MULTILINE)
        self.ssoInfoCtrl.SetFont(wx.Font(8, wx.FONTFAMILY_TELETYPE, wx.NORMAL, wx.NORMAL))
        self.ssoInfoCtrl.Layout()

        bSizer1.Add(self.ssoInfoCtrl, 1, wx.LEFT | wx.RIGHT | wx.EXPAND, 10)

        bSizer3 = wx.BoxSizer(wx.VERTICAL)
        bSizer3.Add(wx.StaticLine(self, wx.ID_ANY), 0, wx.BOTTOM | wx.EXPAND, 10)

        bSizer3.Add(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL), 0, wx.EXPAND)
        bSizer1.Add(bSizer3, 0, wx.ALL | wx.EXPAND, 10)

        self.SetSizer(bSizer1)
        self.Center()

        mainFrame.Bind(GE.EVT_SSO_LOGIN, self.OnLogin)

        from service.esi import Esi

        self.sEsi = Esi.getInstance()
        uri = self.sEsi.getLoginURI(None)
        webbrowser.open(uri)
Exemplo n.º 4
0
    def populateSkillTree(self, data):
        if data is None:
            return
        root = self.root
        tree = self.fittingsTreeCtrl
        tree.DeleteChildren(root)

        sEsi = Esi.getInstance()

        dict = {}
        fits = data
        for fit in fits:
            if fit['fitting_id'] in sEsi.fittings_deleted:
                continue
            ship = getItem(fit['ship_type_id'])
            if ship is None:
                pyfalog.debug('Cannot find ship type id: {}'.format(fit['ship_type_id']))
                continue
            if ship.name not in dict:
                dict[ship.name] = []
            dict[ship.name].append(fit)

        for name, fits in dict.items():
            shipID = tree.AppendItem(root, name)
            for fit in fits:
                fitId = tree.AppendItem(shipID, fit['name'])
                tree.SetItemData(fitId, json.dumps(fit))

        tree.SortChildren(root)
Exemplo n.º 5
0
 def fetchFittings(self, event):
     sEsi = Esi.getInstance()
     waitDialog = wx.BusyInfo("Fetching fits, please wait...", parent=self)
     activeChar = self.getActiveCharacter()
     if activeChar is None:
         msg = "Need at least one ESI character to fetch"
         pyfalog.warning(msg)
         self.statusbar.SetStatusText(msg)
         return
     try:
         self.fittings = sEsi.getFittings(activeChar)
         # self.cacheTime = fittings.get('cached_until')
         # self.updateCacheStatus(None)
         # self.cacheTimer.Start(1000)
         self.fitTree.populateSkillTree(self.fittings)
         del waitDialog
     except requests.exceptions.ConnectionError:
         msg = "Connection error, please check your internet connection"
         pyfalog.error(msg)
         self.statusbar.SetStatusText(msg)
     except APIException as ex:
         #  Can't do this in a finally because then it obscures the message dialog
         del waitDialog  # noqa: F821
         ESIExceptionHandler(self, ex)
     except (KeyboardInterrupt, SystemExit):
         raise
     except Exception as ex:
         del waitDialog  # noqa: F821
         raise ex
Exemplo n.º 6
0
 def ShowSsoLogin(self, event):
     if getattr(event, "login_mode", LoginMethod.SERVER) == LoginMethod.MANUAL and getattr(event, "sso_mode", SsoMode.AUTO) == SsoMode.AUTO:
         dlg = SsoLogin(self)
         if dlg.ShowModal() == wx.ID_OK:
             sEsi = Esi.getInstance()
             # todo: verify that this is a correct SSO Info block
             sEsi.handleLogin({'SSOInfo': [dlg.ssoInfoCtrl.Value.strip()]})
Exemplo n.º 7
0
    def run(self):
        try:
            char = eos.db.getCharacter(self.charID)

            sEsi = Esi.getInstance()
            sChar = Character.getInstance()
            ssoChar = sChar.getSsoCharacter(char.ID)

            if not self.running:
                self.callback[0](self.callback[1])
                return
            resp = sEsi.getSkills(ssoChar.ID)

            if not self.running:
                self.callback[0](self.callback[1])
                return
            # todo: check if alpha. if so, pop up a question if they want to apply it as alpha. Use threading events to set the answer?
            char.clearSkills()
            for skillRow in resp["skills"]:
                char.addSkill(
                    Skill(char, skillRow["skill_id"],
                          skillRow["trained_skill_level"]))

            if not self.running:
                self.callback[0](self.callback[1])
                return
            resp = sEsi.getSecStatus(ssoChar.ID)
            char.secStatus = resp['security_status']
            self.callback[0](self.callback[1])
        except (KeyboardInterrupt, SystemExit):
            raise
        except Exception as ex:
            pyfalog.warn(ex)
            self.callback[0](self.callback[1], sys.exc_info())
Exemplo n.º 8
0
    def __init__(self, port):
        self.mainFrame = gui.mainFrame.MainFrame.getInstance()
        super().__init__(self.mainFrame, id=wx.ID_ANY, title=_t("SSO Login"), size=(-1, -1), style=wx.DEFAULT_DIALOG_STYLE)

        from service.esi import Esi

        self.sEsi = Esi.getInstance()
        serverAddr = self.sEsi.startServer(port)

        uri = self.sEsi.getLoginURI(serverAddr)

        bSizer1 = wx.BoxSizer(wx.VERTICAL)
        self.mainFrame.Bind(GE.EVT_SSO_LOGIN, self.OnLogin)
        self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)

        text = wx.StaticText(self, wx.ID_ANY, _t("Waiting for character login through EVE Single Sign-On."))
        bSizer1.Add(text, 0, wx.ALL | wx.EXPAND, 10)

        bSizer3 = wx.BoxSizer(wx.VERTICAL)
        bSizer3.Add(wx.StaticLine(self, wx.ID_ANY), 0, wx.BOTTOM | wx.EXPAND, 10)

        bSizer3.Add(self.CreateStdDialogButtonSizer(wx.CANCEL), 0, wx.EXPAND)
        bSizer1.Add(bSizer3, 0, wx.BOTTOM | wx.RIGHT | wx.LEFT | wx.EXPAND, 10)

        self.SetSizer(bSizer1)
        self.Fit()
        self.Center()

        webbrowser.open(uri)
Exemplo n.º 9
0
 def deleteAllFittings(self, event):
     sEsi = Esi.getInstance()
     activeChar = self.getActiveCharacter()
     if activeChar is None:
         return
     charName = sEsi.getSsoCharacter(activeChar).characterName
     anyDeleted = False
     with wx.MessageDialog(
             self, "Do you really want to delete all fits from %s in EVE?" %
         (charName), "Confirm Delete",
             wx.YES | wx.NO | wx.ICON_QUESTION) as dlg:
         if dlg.ShowModal() == wx.ID_YES:
             try:
                 for fit in self.fittings:
                     sEsi.delFitting(activeChar, fit['fitting_id'])
                     anyDeleted = True
             except requests.exceptions.ConnectionError:
                 msg = "Connection error, please check your internet connection"
                 pyfalog.error(msg)
                 self.statusbar.SetStatusText(msg)
             except APIException as ex:
                 if anyDeleted:
                     msg = "Some fits were not deleted: ESI error {} received".format(
                         ex.status_code)
                 else:
                     msg = "Failed to delete fits: ESI error {} received".format(
                         ex.status_code)
                 pyfalog.error(msg)
                 self.statusbar.SetStatusText(msg)
     # repopulate the fitting list
     self.fitTree.populateSkillTree(self.fittings)
     self.fitView.update([])
Exemplo n.º 10
0
    def deleteFitting(self, event):
        sEsi = Esi.getInstance()
        selection = self.fitView.fitSelection
        if not selection:
            return
        data = json.loads(self.fitTree.fittingsTreeCtrl.GetItemData(selection))

        with wx.MessageDialog(
                self,
                _t("Do you really want to delete {} ({}) from EVE?").format(
                    (data['name'], getItem(data['ship_type_id']).name)),
                _t("Confirm Delete"),
                wx.YES | wx.NO | wx.ICON_QUESTION) as dlg:
            if dlg.ShowModal() == wx.ID_YES:
                activeChar = self.getActiveCharacter()
                if activeChar is None:
                    return
                try:
                    sEsi.delFitting(activeChar, data['fitting_id'])
                    # repopulate the fitting list
                    self.fitTree.populateSkillTree(self.fittings)
                    self.fitView.update([])
                except requests.exceptions.ConnectionError:
                    msg = _t(
                        "Connection error, please check your internet connection"
                    )
                    pyfalog.error(msg)
                    self.statusbar.SetStatusText(msg)
Exemplo n.º 11
0
 def delChar(self, event):
     item = self.lcCharacters.GetFirstSelected()
     if item > -1:
         charID = self.lcCharacters.GetItemData(item)
         sEsi = Esi.getInstance()
         sEsi.delSsoCharacter(charID)
         self.popCharList()
Exemplo n.º 12
0
    def __init__(self, port):
        mainFrame = gui.mainFrame.MainFrame.getInstance()
        wx.Dialog.__init__(self, mainFrame, id=wx.ID_ANY, title="SSO Login", size=(-1, -1))

        from service.esi import Esi

        self.sEsi = Esi.getInstance()
        serverAddr = self.sEsi.startServer(port)

        uri = self.sEsi.getLoginURI(serverAddr)

        bSizer1 = wx.BoxSizer(wx.VERTICAL)
        mainFrame.Bind(GE.EVT_SSO_LOGIN, self.OnLogin)
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        text = wx.StaticText(self, wx.ID_ANY, "Waiting for character login through EVE Single Sign-On.")
        bSizer1.Add(text, 0, wx.ALL | wx.EXPAND, 10)

        bSizer3 = wx.BoxSizer(wx.VERTICAL)
        bSizer3.Add(wx.StaticLine(self, wx.ID_ANY), 0, wx.BOTTOM | wx.EXPAND, 10)

        bSizer3.Add(self.CreateStdDialogButtonSizer(wx.CANCEL), 0, wx.EXPAND)
        bSizer1.Add(bSizer3, 0, wx.BOTTOM | wx.RIGHT | wx.LEFT | wx.EXPAND, 10)

        self.SetSizer(bSizer1)
        self.Fit()
        self.Center()

        webbrowser.open(uri)
Exemplo n.º 13
0
    def __init__(self):
        mainFrame = gui.mainFrame.MainFrame.getInstance()

        super().__init__(
                mainFrame, id=wx.ID_ANY, title=_t("SSO Login"), style=wx.DEFAULT_DIALOG_STYLE,
                size=wx.Size(450, 240) if "wxGTK" in wx.PlatformInfo else wx.Size(400, 240))

        bSizer1 = wx.BoxSizer(wx.VERTICAL)

        text = wx.StaticText(self, wx.ID_ANY, _t("Copy and paste the block of text provided by pyfa.io"))
        bSizer1.Add(text, 0, wx.ALL | wx.EXPAND, 10)

        self.ssoInfoCtrl = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, (-1, -1), style=wx.TE_MULTILINE)
        self.ssoInfoCtrl.SetFont(wx.Font(8, wx.FONTFAMILY_TELETYPE, wx.NORMAL, wx.NORMAL))
        self.ssoInfoCtrl.Layout()

        bSizer1.Add(self.ssoInfoCtrl, 1, wx.LEFT | wx.RIGHT | wx.EXPAND, 10)

        bSizer3 = wx.BoxSizer(wx.VERTICAL)
        bSizer3.Add(wx.StaticLine(self, wx.ID_ANY), 0, wx.BOTTOM | wx.EXPAND, 10)

        bSizer3.Add(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL), 0, wx.EXPAND)
        bSizer1.Add(bSizer3, 0, wx.ALL | wx.EXPAND, 10)

        self.SetSizer(bSizer1)
        self.Center()

        from service.esi import Esi

        self.sEsi = Esi.getInstance()
        uri = self.sEsi.getLoginURI(None)
        webbrowser.open(uri)
Exemplo n.º 14
0
    def updateEsiMenus(self, type):
        menu = self.GetMenuBar()
        sEsi = Esi.getInstance()

        menu.SetLabel(menu.ssoLoginId, "Manage Characters")
        enable = len(sEsi.getSsoCharacters()) == 0
        menu.Enable(menu.eveFittingsId, not enable)
        menu.Enable(menu.exportToEveId, not enable)
Exemplo n.º 15
0
 def addChar(self, event):
     try:
         sEsi = Esi.getInstance()
         sEsi.login()
     except (KeyboardInterrupt, SystemExit):
         raise
     except Exception as ex:
         ESIServerExceptionHandler(self, ex)
Exemplo n.º 16
0
    def updateEsiMenus(self, type):
        menu = self.GetMenuBar()
        sEsi = Esi.getInstance()

        menu.SetLabel(menu.ssoLoginId, "Manage Characters")
        enable = len(sEsi.getSsoCharacters()) == 0
        menu.Enable(menu.eveFittingsId, not enable)
        menu.Enable(menu.exportToEveId, not enable)
Exemplo n.º 17
0
    def exportFitting(self, event):
        sPort = Port.getInstance()
        fitID = self.mainFrame.getActiveFit()

        self.statusbar.SetStatusText("", 0)

        if fitID is None:
            self.statusbar.SetStatusText(
                "Please select an active fitting in the main window", 1)
            return

        self.statusbar.SetStatusText("Sending request and awaiting response",
                                     1)
        sEsi = Esi.getInstance()

        sFit = Fit.getInstance()
        exportCharges = self.exportChargesCb.GetValue()
        try:
            data = sPort.exportESI(sFit.getFit(fitID), exportCharges)
        except ESIExportException as e:
            msg = str(e)
            if not msg:
                msg = "Failed to generate export data"
            pyfalog.warning(msg)
            self.statusbar.SetStatusText(msg, 1)
            return
        activeChar = self.getActiveCharacter()
        if activeChar is None:
            msg = "Need at least one ESI character to export"
            pyfalog.warning(msg)
            self.statusbar.SetStatusText(msg, 1)
            return
        res = sEsi.postFitting(activeChar, data)

        try:
            res.raise_for_status()
            self.statusbar.SetStatusText("", 0)
            self.statusbar.SetStatusText(res.reason, 1)
        except requests.exceptions.ConnectionError:
            msg = "Connection error, please check your internet connection"
            pyfalog.error(msg)
            self.statusbar.SetStatusText("ERROR", 0)
            self.statusbar.SetStatusText(msg, 1)
        except ESIExportException as ex:
            pyfalog.error(ex)
            self.statusbar.SetStatusText("ERROR", 0)
            self.statusbar.SetStatusText(
                "{} - {}".format(res.status_code, res.reason), 1)
        except APIException as ex:
            try:
                ESIExceptionHandler(self, ex)
            except (KeyboardInterrupt, SystemExit):
                raise
            except Exception as ex:
                self.statusbar.SetStatusText("ERROR", 0)
                self.statusbar.SetStatusText(
                    "{} - {}".format(res.status_code, res.reason), 1)
                pyfalog.error(ex)
Exemplo n.º 18
0
    def updateCharList(self):
        sEsi = Esi.getInstance()
        chars = sEsi.getSsoCharacters()

        self.charChoice.Clear()
        for char in chars:
            self.charChoice.Append(char.characterName, char.ID)
        if len(chars) > 0:
            self.charChoice.SetSelection(0)
Exemplo n.º 19
0
    def exportFitting(self, event):
        sPort = Port.getInstance()
        fitID = self.mainFrame.getActiveFit()

        self.statusbar.SetStatusText("", 0)

        if fitID is None:
            self.statusbar.SetStatusText(
                _t("Please select an active fitting in the main window"), 1)
            return

        self.statusbar.SetStatusText(
            _t("Sending request and awaiting response"), 1)
        sEsi = Esi.getInstance()

        sFit = Fit.getInstance()
        exportCharges = self.exportChargesCb.GetValue()
        try:
            data = sPort.exportESI(sFit.getFit(fitID), exportCharges)
        except ESIExportException as e:
            msg = str(e)
            if not msg:
                msg = _t("Failed to generate export data")
            pyfalog.warning(msg)
            self.statusbar.SetStatusText(msg, 1)
            return
        activeChar = self.getActiveCharacter()
        if activeChar is None:
            msg = _t("Need at least one ESI character to export")
            pyfalog.warning(msg)
            self.statusbar.SetStatusText(msg, 1)
            return

        try:
            res = sEsi.postFitting(activeChar, data)
            res.raise_for_status()
            self.statusbar.SetStatusText("", 0)
            self.statusbar.SetStatusText(res.reason, 1)
        except requests.exceptions.ConnectionError:
            msg = _t("Connection error, please check your internet connection")
            pyfalog.error(msg)
            self.statusbar.SetStatusText(_t("ERROR"), 0)
            self.statusbar.SetStatusText(msg, 1)
        except APIException as ex:
            pyfalog.error(ex)
            self.statusbar.SetStatusText(_t("ERROR"), 0)
            self.statusbar.SetStatusText(
                "HTTP {} - {}".format(ex.status_code, ex.response["error"]), 1)
            try:
                ESIExceptionHandler(ex)
            except:
                # don't need to do anything - we should already get the error in ex.response
                pass
        except Exception as ex:
            self.statusbar.SetStatusText(_t("ERROR"), 0)
            self.statusbar.SetStatusText("Unknown error", 1)
            pyfalog.error(ex)
Exemplo n.º 20
0
    def fetchSkills(self, event):
        sEsi = Esi.getInstance()
        chars = sEsi.getSsoCharacters()

        for ssoChar in chars:
            if not ssoChar.characters:
                char = Character.new(ssoChar.characterName)
                char.setSsoCharacter(ssoChar, config.getClientSecret())
            for char in ssoChar.characters:
                sChar = Character.getInstance()
                sChar.apiFetch(char.ID, APIView.fetchCallback)
Exemplo n.º 21
0
    def updateCharList(self):
        sEsi = Esi.getInstance()
        chars = sEsi.getSsoCharacters()

        if len(chars) == 0:
            self.Close()

        self.charChoice.Clear()
        for char in chars:
            self.charChoice.Append(char.characterName, char.ID)

        self.charChoice.SetSelection(0)
Exemplo n.º 22
0
    def popCharList(self):
        sEsi = Esi.getInstance()
        chars = sEsi.getSsoCharacters()

        self.lcCharacters.DeleteAllItems()

        for index, char in enumerate(chars):
            self.lcCharacters.InsertItem(index, char.characterName)
            self.lcCharacters.SetItem(index, 1, str(char.characterID))
            self.lcCharacters.SetItemData(index, char.ID)

        self.lcCharacters.SetColumnWidth(0, wx.LIST_AUTOSIZE)
        self.lcCharacters.SetColumnWidth(1, wx.LIST_AUTOSIZE)
Exemplo n.º 23
0
    def popCharList(self):
        sEsi = Esi.getInstance()
        chars = sEsi.getSsoCharacters()

        self.lcCharacters.DeleteAllItems()

        for index, char in enumerate(chars):
            self.lcCharacters.InsertItem(index, char.characterName)
            self.lcCharacters.SetItem(index, 1, str(char.characterID))
            self.lcCharacters.SetItemData(index, char.ID)

        self.lcCharacters.SetColumnWidth(0, wx.LIST_AUTOSIZE)
        self.lcCharacters.SetColumnWidth(1, wx.LIST_AUTOSIZE)
Exemplo n.º 24
0
    def ssoListChanged(self, event):
        sEsi = Esi.getInstance()
        ssoChars = sEsi.getSsoCharacters()

        if len(ssoChars) == 0:
            self.charChoice.Hide()
            self.m_staticCharText.Hide()
            self.noCharactersTip.Show()
        else:
            self.noCharactersTip.Hide()
            self.m_staticCharText.Show()
            self.charChoice.Show()

        self.charChanged(event)
Exemplo n.º 25
0
    def charChanged(self, event):
        sChar = Character.getInstance()
        sEsi = Esi.getInstance()

        activeChar = self.charEditor.entityEditor.getActiveEntity()

        if event and event.EventType == GE.EVT_SSO_LOGIN.typeId and hasattr(
                event, 'character'):
            # Automatically assign the character that was just logged into
            sChar.setSsoCharacter(activeChar.ID, event.character.ID)

        sso = sChar.getSsoCharacter(activeChar.ID)

        self.fetchButton.Enable(sso is not None)

        ssoChars = sEsi.getSsoCharacters()

        self.charChoice.Clear()

        noneID = self.charChoice.Append("None", None)

        for char in ssoChars:
            currId = self.charChoice.Append(char.characterName, char.ID)

            if sso is not None and char.ID == sso.ID:
                self.charChoice.SetSelection(currId)

        if sso is None:
            self.charChoice.SetSelection(noneID)

        #
        # if chars:
        #     for charName in chars:
        #         self.charChoice.Append(charName)
        #     self.charChoice.SetStringSelection(char)
        # else:
        #     self.charChoice.Append("No characters...", 0)
        #     self.charChoice.SetSelection(0)
        #
        if activeChar.name in ("All 0", "All 5"):
            self.Enable(False)
            self.stDisabledTip.Show()
            self.Layout()
        else:
            self.Enable()
            self.stDisabledTip.Hide()
            self.Layout()

        if event is not None:
            event.Skip()
Exemplo n.º 26
0
    def charChanged(self, event):
        sChar = Character.getInstance()
        sEsi = Esi.getInstance()

        activeChar = self.charEditor.entityEditor.getActiveEntity()

        if event and event.EventType == GE.EVT_SSO_LOGIN.typeId and hasattr(event, 'character'):
            # Automatically assign the character that was just logged into
            sChar.setSsoCharacter(activeChar.ID, event.character.ID)

        sso = sChar.getSsoCharacter(activeChar.ID)

        self.fetchButton.Enable(sso is not None)

        ssoChars = sEsi.getSsoCharacters()

        self.charChoice.Clear()

        noneID = self.charChoice.Append("None", None)

        for char in ssoChars:
            currId = self.charChoice.Append(char.characterName, char.ID)

            if sso is not None and char.ID == sso.ID:
                self.charChoice.SetSelection(currId)

        if sso is None:
            self.charChoice.SetSelection(noneID)

        #
        # if chars:
        #     for charName in chars:
        #         self.charChoice.Append(charName)
        #     self.charChoice.SetStringSelection(char)
        # else:
        #     self.charChoice.Append("No characters...", 0)
        #     self.charChoice.SetSelection(0)
        #
        if activeChar.name in ("All 0", "All 5"):
            self.Enable(False)
            self.stDisabledTip.Show()
            self.Layout()
        else:
            self.Enable()
            self.stDisabledTip.Hide()
            self.Layout()

        if event is not None:
            event.Skip()
Exemplo n.º 27
0
    def ssoListChanged(self, event):
        if not self:  # todo: fix event not unbinding properly
            return
        sEsi = Esi.getInstance()
        ssoChars = sEsi.getSsoCharacters()

        if len(ssoChars) == 0:
            self.charChoice.Hide()
            self.m_staticCharText.Hide()
            self.noCharactersTip.Show()
        else:
            self.noCharactersTip.Hide()
            self.m_staticCharText.Show()
            self.charChoice.Show()

        self.charChanged(event)
Exemplo n.º 28
0
    def __init__(self):
        mainFrame = gui.mainFrame.MainFrame.getInstance()

        wx.Dialog.__init__(self,
                           mainFrame,
                           id=wx.ID_ANY,
                           title="SSO Login",
                           size=wx.Size(400, 240))

        bSizer1 = wx.BoxSizer(wx.VERTICAL)

        text = wx.StaticText(
            self, wx.ID_ANY,
            "Copy and paste the block of text provided by pyfa.io, then click OK"
        )
        bSizer1.Add(text, 0, wx.ALL | wx.EXPAND, 10)

        self.ssoInfoCtrl = wx.TextCtrl(self,
                                       wx.ID_ANY,
                                       wx.EmptyString,
                                       wx.DefaultPosition, (-1, -1),
                                       style=wx.TE_MULTILINE)
        self.ssoInfoCtrl.SetFont(
            wx.Font(8, wx.FONTFAMILY_TELETYPE, wx.NORMAL, wx.NORMAL))
        self.ssoInfoCtrl.Layout()

        bSizer1.Add(self.ssoInfoCtrl, 1, wx.LEFT | wx.RIGHT | wx.EXPAND, 10)

        bSizer3 = wx.BoxSizer(wx.VERTICAL)
        bSizer3.Add(wx.StaticLine(self, wx.ID_ANY), 0, wx.BOTTOM | wx.EXPAND,
                    10)

        bSizer3.Add(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL), 0,
                    wx.EXPAND)
        bSizer1.Add(bSizer3, 0, wx.ALL | wx.EXPAND, 10)

        self.SetSizer(bSizer1)
        self.Center()

        mainFrame.Bind(GE.EVT_SSO_LOGIN, self.OnLogin)

        from service.esi import Esi

        self.sEsi = Esi.getInstance()
        uri = self.sEsi.getLoginURI(None)
        webbrowser.open(uri)
Exemplo n.º 29
0
    def deleteFitting(self, event):
        sEsi = Esi.getInstance()
        selection = self.fitView.fitSelection
        if not selection:
            return
        data = json.loads(self.fitTree.fittingsTreeCtrl.GetItemData(selection))

        dlg = wx.MessageDialog(
            self, "Do you really want to delete %s (%s) from EVE?" %
            (data['name'], getItem(data['ship_type_id']).name),
            "Confirm Delete", wx.YES | wx.NO | wx.ICON_QUESTION)

        if dlg.ShowModal() == wx.ID_YES:
            try:
                sEsi.delFitting(self.getActiveCharacter(), data['fitting_id'])
            except requests.exceptions.ConnectionError:
                msg = "Connection error, please check your internet connection"
                pyfalog.error(msg)
                self.statusbar.SetStatusText(msg)
Exemplo n.º 30
0
    def __init__(self, parent):
        wx.Frame.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          title="Export fit to EVE",
                          pos=wx.DefaultPosition,
                          size=(wx.Size(350, 100)),
                          style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)

        self.mainFrame = parent
        self.SetBackgroundColour(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))

        sEsi = Esi.getInstance()
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        hSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.charChoice = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition,
                                    wx.DefaultSize, [])
        hSizer.Add(self.charChoice, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        self.updateCharList()
        self.charChoice.SetSelection(0)

        self.exportBtn = wx.Button(self, wx.ID_ANY, "Export Fit",
                                   wx.DefaultPosition, wx.DefaultSize, 5)
        hSizer.Add(self.exportBtn, 0, wx.ALL, 5)

        mainSizer.Add(hSizer, 0, wx.EXPAND, 5)

        self.exportBtn.Bind(wx.EVT_BUTTON, self.exportFitting)

        self.statusbar = wx.StatusBar(self)
        self.statusbar.SetFieldsCount(2)
        self.statusbar.SetStatusWidths([100, -1])

        self.Bind(wx.EVT_CLOSE, self.OnClose)

        self.SetSizer(mainSizer)
        self.SetStatusBar(self.statusbar)
        self.Layout()

        self.Centre(wx.BOTH)
Exemplo n.º 31
0
    def fetchFittings(self, event):
        sEsi = Esi.getInstance()
        waitDialog = wx.BusyInfo("Fetching fits, please wait...", parent=self)

        try:
            fittings = sEsi.getFittings(self.getActiveCharacter())
            # self.cacheTime = fittings.get('cached_until')
            # self.updateCacheStatus(None)
            # self.cacheTimer.Start(1000)
            self.fitTree.populateSkillTree(fittings)
            del waitDialog
        except requests.exceptions.ConnectionError:
            msg = "Connection error, please check your internet connection"
            pyfalog.error(msg)
            self.statusbar.SetStatusText(msg)
        except APIException as ex:
            del waitDialog  # Can't do this in a finally because then it obscures the message dialog
            ESIExceptionHandler(self, ex)
        except Exception as ex:
            del waitDialog
Exemplo n.º 32
0
    def exportFitting(self, event):
        sPort = Port.getInstance()
        fitID = self.mainFrame.getActiveFit()

        self.statusbar.SetStatusText("", 0)

        if fitID is None:
            self.statusbar.SetStatusText(
                "Please select an active fitting in the main window", 1)
            return

        self.statusbar.SetStatusText("Sending request and awaiting response",
                                     1)
        sEsi = Esi.getInstance()

        sFit = Fit.getInstance()
        data = sPort.exportESI(sFit.getFit(fitID))
        res = sEsi.postFitting(self.getActiveCharacter(), data)

        try:
            res.raise_for_status()
            self.statusbar.SetStatusText("", 0)
            self.statusbar.SetStatusText(res.reason, 1)
        except requests.exceptions.ConnectionError:
            msg = "Connection error, please check your internet connection"
            pyfalog.error(msg)
            self.statusbar.SetStatusText("ERROR", 0)
            self.statusbar.SetStatusText(msg, 1)
        except ESIExportException as ex:
            pyfalog.error(ex)
            self.statusbar.SetStatusText("ERROR", 0)
            self.statusbar.SetStatusText(
                "{} - {}".format(res.status_code, res.reason), 1)
        except APIException as ex:
            try:
                ESIExceptionHandler(self, ex)
            except Exception as ex:
                self.statusbar.SetStatusText("ERROR", 0)
                self.statusbar.SetStatusText(
                    "{} - {}".format(res.status_code, res.reason), 1)
                pyfalog.error(ex)
Exemplo n.º 33
0
    def deleteFitting(self, event):
        sEsi = Esi.getInstance()
        selection = self.fitView.fitSelection
        if not selection:
            return
        data = json.loads(self.fitTree.fittingsTreeCtrl.GetItemData(selection))

        dlg = wx.MessageDialog(self,
                               "Do you really want to delete %s (%s) from EVE?" % (data['name'], getItem(data['ship_type_id']).name),
                               "Confirm Delete", wx.YES | wx.NO | wx.ICON_QUESTION)

        if dlg.ShowModal() == wx.ID_YES:
            try:
                sEsi.delFitting(self.getActiveCharacter(), data['fitting_id'])
                # repopulate the fitting list
                self.fitTree.populateSkillTree(self.fittings)
                self.fitView.update([])
            except requests.exceptions.ConnectionError:
                msg = "Connection error, please check your internet connection"
                pyfalog.error(msg)
                self.statusbar.SetStatusText(msg)
Exemplo n.º 34
0
    def deleteFitting(self, event):
        self.statusbar.SetStatusText("")
        sEsi = Esi.getInstance()
        selection = self.fitView.fitSelection
        if not selection:
            return
        data = json.loads(self.fitTree.fittingsTreeCtrl.GetItemData(selection))

        with wx.MessageDialog(
                self,
                _t("Do you really want to delete {} ({}) from EVE?").format(
                    data['name'],
                    getItem(data['ship_type_id']).name), _t("Confirm Delete"),
                wx.YES | wx.NO | wx.ICON_QUESTION) as dlg:
            if dlg.ShowModal() == wx.ID_YES:
                activeChar = self.getActiveCharacter()
                if activeChar is None:
                    return
                try:
                    try:
                        sEsi.delFitting(activeChar, data['fitting_id'])
                        # repopulate the fitting list
                        self.fitTree.populateSkillTree(self.fittings)
                        self.fitView.update([])
                    except APIException as ex:
                        pyfalog.error(ex)
                        self.statusbar.SetStatusText(
                            "Failed to delete fit: ESI error {} received - {}".
                            format(ex.status_code, ex.response["error"]))
                        try:
                            ESIExceptionHandler(ex)
                        except:
                            # don't need to do anything - we should already have error code in the status
                            pass
                except requests.exceptions.ConnectionError:
                    msg = _t(
                        "Connection error, please check your internet connection"
                    )
                    pyfalog.error(msg)
                    self.statusbar.SetStatusText(msg)
Exemplo n.º 35
0
    def fetchFittings(self, event):
        sEsi = Esi.getInstance()
        waitDialog = wx.BusyInfo("Fetching fits, please wait...", parent=self)

        try:
            self.fittings = sEsi.getFittings(self.getActiveCharacter())
            # self.cacheTime = fittings.get('cached_until')
            # self.updateCacheStatus(None)
            # self.cacheTimer.Start(1000)
            self.fitTree.populateSkillTree(self.fittings)
            del waitDialog
        except requests.exceptions.ConnectionError:
            msg = "Connection error, please check your internet connection"
            pyfalog.error(msg)
            self.statusbar.SetStatusText(msg)
        except APIException as ex:
            #  Can't do this in a finally because then it obscures the message dialog
            del waitDialog  # noqa: F821
            ESIExceptionHandler(self, ex)
        except Exception as ex:
            del waitDialog  # noqa: F821
            raise ex
Exemplo n.º 36
0
    def run(self):
        try:
            char = eos.db.getCharacter(self.charID)

            sEsi = Esi.getInstance()
            sChar = Character.getInstance()
            ssoChar = sChar.getSsoCharacter(char.ID)
            resp = sEsi.getSkills(ssoChar.ID)

            # todo: check if alpha. if so, pop up a question if they want to apply it as alpha. Use threading events to set the answer?
            char.clearSkills()
            for skillRow in resp["skills"]:
                char.addSkill(Skill(char, skillRow["skill_id"], skillRow["trained_skill_level"]))

            resp = sEsi.getSecStatus(ssoChar.ID)

            char.secStatus = resp['security_status']

            self.callback[0](self.callback[1])
        except Exception as ex:
            pyfalog.warn(ex)
            self.callback[0](self.callback[1], sys.exc_info())
Exemplo n.º 37
0
    def exportFitting(self, event):
        sPort = Port.getInstance()
        fitID = self.mainFrame.getActiveFit()

        self.statusbar.SetStatusText("", 0)

        if fitID is None:
            self.statusbar.SetStatusText(
                "Please select an active fitting in the main window", 1)
            return

        self.statusbar.SetStatusText("Sending request and awaiting response",
                                     1)
        sEsi = Esi.getInstance()

        try:
            sFit = Fit.getInstance()
            data = sPort.exportESI(sFit.getFit(fitID))
            res = sEsi.postFitting(self.getActiveCharacter(), data)

            self.statusbar.SetStatusText("", 0)
            self.statusbar.SetStatusText("", 1)
            # try:
            #     text = json.loads(res.text)
            #     self.statusbar.SetStatusText(text['message'], 1)
            # except ValueError:
            #     pyfalog.warning("Value error on loading JSON.")
            #     self.statusbar.SetStatusText("", 1)
        except requests.exceptions.ConnectionError:
            msg = "Connection error, please check your internet connection"
            pyfalog.error(msg)
            self.statusbar.SetStatusText(msg)
        except ESIExportException as ex:
            pyfalog.error(ex)
            self.statusbar.SetStatusText("ERROR", 0)
            self.statusbar.SetStatusText(ex.args[0], 1)
        except APIException as ex:
            ESIExceptionHandler(self, ex)
Exemplo n.º 38
0
    def exportFitting(self, event):
        sPort = Port.getInstance()
        fitID = self.mainFrame.getActiveFit()

        self.statusbar.SetStatusText("", 0)

        if fitID is None:
            self.statusbar.SetStatusText("Please select an active fitting in the main window", 1)
            return

        self.statusbar.SetStatusText("Sending request and awaiting response", 1)
        sEsi = Esi.getInstance()

        sFit = Fit.getInstance()
        data = sPort.exportESI(sFit.getFit(fitID))
        res = sEsi.postFitting(self.getActiveCharacter(), data)

        try:
            res.raise_for_status()
            self.statusbar.SetStatusText("", 0)
            self.statusbar.SetStatusText(res.reason, 1)
        except requests.exceptions.ConnectionError:
            msg = "Connection error, please check your internet connection"
            pyfalog.error(msg)
            self.statusbar.SetStatusText("ERROR", 0)
            self.statusbar.SetStatusText(msg, 1)
        except ESIExportException as ex:
            pyfalog.error(ex)
            self.statusbar.SetStatusText("ERROR", 0)
            self.statusbar.SetStatusText("{} - {}".format(res.status_code, res.reason), 1)
        except APIException as ex:
            try:
                ESIExceptionHandler(self, ex)
            except Exception as ex:
                self.statusbar.SetStatusText("ERROR", 0)
                self.statusbar.SetStatusText("{} - {}".format(res.status_code, res.reason), 1)
                pyfalog.error(ex)
Exemplo n.º 39
0
    def __init__(self, port):
        mainFrame = gui.mainFrame.MainFrame.getInstance()
        wx.Dialog.__init__(self,
                           mainFrame,
                           id=wx.ID_ANY,
                           title="SSO Login",
                           size=(-1, -1))

        from service.esi import Esi

        self.sEsi = Esi.getInstance()
        serverAddr = self.sEsi.startServer(port)

        uri = self.sEsi.getLoginURI(serverAddr)

        bSizer1 = wx.BoxSizer(wx.VERTICAL)
        mainFrame.Bind(GE.EVT_SSO_LOGIN, self.OnLogin)
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        text = wx.StaticText(
            self, wx.ID_ANY,
            "Waiting for character login through EVE Single Sign-On.")
        bSizer1.Add(text, 0, wx.ALL | wx.EXPAND, 10)

        bSizer3 = wx.BoxSizer(wx.VERTICAL)
        bSizer3.Add(wx.StaticLine(self, wx.ID_ANY), 0, wx.BOTTOM | wx.EXPAND,
                    10)

        bSizer3.Add(self.CreateStdDialogButtonSizer(wx.CANCEL), 0, wx.EXPAND)
        bSizer1.Add(bSizer3, 0, wx.BOTTOM | wx.RIGHT | wx.LEFT | wx.EXPAND, 10)

        self.SetSizer(bSizer1)
        self.Fit()
        self.Center()

        webbrowser.open(uri)
Exemplo n.º 40
0
 def addChar(self, event):
     try:
         sEsi = Esi.getInstance()
         sEsi.login()
     except Exception as ex:
         ESIServerExceptionHandler(self, ex)
Exemplo n.º 41
0
 def addCharacter(self, event):
     sEsi = Esi.getInstance()
     sEsi.login()
Exemplo n.º 42
0
 def addCharacter(self, event):
     sEsi = Esi.getInstance()
     sEsi.login()
Exemplo n.º 43
0
 def addChar(self, event):
     try:
         sEsi = Esi.getInstance()
         sEsi.login()
     except Exception as ex:
         ESIServerExceptionHandler(self, ex)
Exemplo n.º 44
0
 def addChar(event):
     sEsi = Esi.getInstance()
     sEsi.login()