Пример #1
0
    def _on_account_cancel(self, _accounts_window, switch):
        manager = AccountManager()

        if not switch or not manager.get_accounts():
            self._quit()
Пример #2
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()))