def mintLogin(self): username, passwd = [ ctrl.Value for ctrl in (self.usernameBox, self.passwordBox) ] if self.saveAuthCheck.IsChecked(): Keyring().set_credentials(username, passwd) Mint.LoginFromKeyring() else: Mint.Login(username, passwd)
def LoginFromKeyring(cls, notify=True): if Keyring is None: raise Exception("Keyring was unable to be imported") keyring = Keyring() if keyring.get_credentials() is None: raise Exception("Keyring does not have Mint.com credentials") user, passwd = keyring.get_credentials() return cls.Login(user, passwd, notify)
def __init__(self, parent, account): wx.Panel.__init__(self, parent) self.Account = account self.NoneAccount = _("None") self.headerText = wx.StaticText(self, -1, _("Mint.com credentials:")) self.usernameBox = wx.TextCtrl(self) self.passwordBox = wx.TextCtrl(self, style=wx.TE_PASSWORD) self.saveAuthCheck = wx.CheckBox( self, label=_("Save credentials in keyring")) self.accountText = wx.StaticText( self, -1, _("Corresponding Mint account for %(name)s:") % {"name": account.Name}) self.mintCombo = wx.Choice(self, choices=[self.NoneAccount]) self.mintUpdateButton = wx.Button(self, label=_("Update"), id=self.ID_UPDATE) gridSizer = wx.GridSizer(2, 2, 3, 3) gridSizer.Add(wx.StaticText(self, label=_("Username:"******"Password:"******"Save"), id=wx.ID_SAVE) closeButton = wx.Button(self, label=_("Cancel"), id=wx.ID_CLOSE) buttonSizer = wx.BoxSizer() buttonSizer.Add(saveButton) buttonSizer.AddSpacer(12) buttonSizer.Add(closeButton) buttonSizer.AddSpacer(6) self.Sizer = wx.BoxSizer(wx.VERTICAL) self.Sizer.AddSpacer(6) self.Sizer.Add(self.headerText, 0, wx.LEFT, 6) self.Sizer.AddSpacer(12) self.Sizer.Add(gridSizer, 0, wx.EXPAND | wx.LEFT, 6) self.Sizer.AddSpacer(12) self.Sizer.Add(self.saveAuthCheck, 0, wx.LEFT, 12) self.Sizer.AddSpacer(24) self.Sizer.Add(self.accountText, 0, wx.LEFT, 6) self.Sizer.AddSpacer(6) self.Sizer.Add(mintAccountSizer) self.Sizer.AddStretchSpacer(1) self.Sizer.Add(buttonSizer, flag=wx.ALIGN_RIGHT) self.Sizer.AddSpacer(6) # If we have a keyring, enable the checkbox, and populate any existing data. if Keyring: self.saveAuthCheck.Enable(True) keyring = Keyring() if keyring.get_credentials() is not None: self.saveAuthCheck.Value = True user, passwd = keyring.get_credentials() self.usernameBox.Value = user self.passwordBox.Value = passwd # Properly populate the list of accounts if we are already logged in. if Mint().IsLoggedIn(): self.updateMintAccounts() self.mintUpdateButton.Bind(wx.EVT_BUTTON, self.onUpdateButton) self.Bind(wx.EVT_BUTTON, self.onButton)