Esempio n. 1
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)
Esempio n. 2
0
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()))

config_path = utils.to_config_path('config.json')

try:
    config = utils.parse_config(config_path, utils.config_defaults)
except IOError:
    raise utils.EngineFatal("Couldn't open config file.")