Exemplo n.º 1
0
    def _show_accounts(self, switch=True, forget=False):
        manager = AccountManager()

        if forget:
            manager.set_default(None)

        accountsel = AccountsWindow(manager, transient_for=self)
        accountsel.connect('account-open', self._on_account_open)
        accountsel.connect('account-cancel', self._on_account_cancel, switch)
        accountsel.connect('destroy', self._on_modal_destroy)
        accountsel.present()
        self._modals.append(accountsel)
Exemplo n.º 2
0
    def _show_accounts(self, switch=True, forget=False):
        manager = AccountManager()

        if forget:
            manager.set_default(None)

        def _on_accountsel_cancel(accounts_window):
            Gtk.main_quit()

        accountsel = AccountsWindow(manager, transient_for=self)
        accountsel.connect('account-open', self._on_account_open)

        if not switch:
            accountsel.connect('account-cancel', _on_accountsel_cancel)
Exemplo n.º 3
0
    def _on_account_open(self, accounts_window, account_num, remember):
        manager = AccountManager()
        account = manager.get_account(account_num)

        if remember:
            manager.set_default(account_num)
        else:
            manager.set_default(None)

        # Reload the engine if already started,
        # start it otherwise
        if self._engine and self._engine.loaded:
            self._main_view.load_account_mediatype(account, None, None)
        else:
            self._create_engine(account)
Exemplo n.º 4
0
 def forget_account(self):
     manager = AccountManager()
     manager.set_default(None)
Exemplo n.º 5
0
 def forget_account(self):
     manager = AccountManager()
     manager.set_default(None)
Exemplo n.º 6
0
import os
from trackma.accounts import AccountManager
from trackma import utils
from envparse import env

username = env.str('ACCOUNT_USERNAME')
password = env.str('ACCOUNT_PASSWORD')
api = env.str('ACCOUNT_API')

manager = AccountManager()

if len(manager.get_accounts()) == 0:
    print("No accounts found, adding account...")
    manager.add_account(username, password, api)
    manager.set_default(1)
else:
    account_exists = False
    for num, account in manager.get_accounts():
        if account["username"] == username and account["api"] == api:
            account_exists = True
            if account["password"] != password:
                print("Account password mismatch, updating...")
                manager.edit_account(num, username, password, api)
            if manager.get_default() != manager.get_account(num):
                print("Setting account as default")
                manager.set_default(num)
            break
    if not account_exists:
        print ("Could not find account, adding account...")
        manager.add_account(username, password, api)
        manager.set_default(len(manager.get_accounts()))