From 208a68e451635883d0c6f58e56c8308bafe8b16c Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sun, 09 Jun 2013 22:06:54 +0000 Subject: refactoring based on lasted commits upstream --- (limited to 'src/jarabe/web/accountsmanager.py') diff --git a/src/jarabe/web/accountsmanager.py b/src/jarabe/web/accountsmanager.py index cd1da83..fb7b632 100644 --- a/src/jarabe/web/accountsmanager.py +++ b/src/jarabe/web/accountsmanager.py @@ -21,13 +21,14 @@ import logging from gi.repository import Gtk from jarabe import config +from jarabe.web.account import Account _accounts = [] def get_all_accounts(): ''' Returns a list of all installed online account managers ''' - global _accounts # No need to do this every time. + global _accounts if len(_accounts) > 0: return _accounts @@ -54,8 +55,8 @@ def _load_module(dir_path): for f in os.listdir(dir_path): if f == 'account.py': module_name = f[:-3] - logging.debug('OnlineAccountsManager loading %s' % ( - module_name)) + logging.debug('OnlineAccountsManager loading %s' % + (module_name)) module_path = 'web.%s.%s' % (os.path.basename(dir_path), module_name) try: @@ -65,8 +66,8 @@ def _load_module(dir_path): module = mod.get_account() except Exception as e: - logging.exception('Exception while loading %s: %s' % ( - module_name, str(e))) + logging.exception('Exception while loading %s: %s' % + (module_name, str(e))) return module @@ -90,8 +91,11 @@ def _extend_icon_theme_search_path(dir_path): def get_configured_accounts(): - return [a for a in get_all_accounts() if a.is_configured()] + return [a for a in get_all_accounts() + if a.get_token_state() in (Account.STATE_VALID, + Account.STATE_EXPIRED)] def get_active_accounts(): - return [a for a in get_all_accounts() if a.is_active()] + return [a for a in get_all_accounts() + if a.get_token_state() == Account.STATE_VALID] -- cgit v0.9.1