24 lines
No EOL
855 B
Python
24 lines
No EOL
855 B
Python
from logger import logger
|
|
from typing import Optional,List,Dict,Any
|
|
from config import Settings
|
|
|
|
def accounts_info(config: Settings) -> Optional[Dict[str, Any]]:
|
|
if config is None:
|
|
logger.error({"config_err": "config is null, can not get accounts"})
|
|
return None
|
|
return config.accounts
|
|
|
|
def accounts_list(config: Settings) -> Optional[List[str]]:
|
|
info = accounts_info(config)
|
|
|
|
if info is None:
|
|
logger.error({"config_account_err": "can not get accounts from config file"})
|
|
return None
|
|
|
|
accounts=[]
|
|
for account_id,value in info.items():
|
|
if not value.get("session_id") or not value.get("cookie"):
|
|
logger.error({"config_account_err": "account config error"})
|
|
return {"config_account_err": "account config error"}
|
|
accounts.append(account_id)
|
|
return accounts |