mirror of
https://github.com/malmeloo/FindMy.py.git
synced 2026-04-18 00:53:56 +02:00
fix(reports): Update examples to use new api
This commit is contained in:
@@ -5,19 +5,28 @@ import sys
|
||||
from _login import get_account_async
|
||||
|
||||
from findmy import KeyPair
|
||||
from findmy.reports import RemoteAnisetteProvider
|
||||
|
||||
# URL to (public or local) anisette server
|
||||
ANISETTE_SERVER = "http://localhost:6969"
|
||||
# Path where login session will be stored.
|
||||
# This is necessary to avoid generating a new session every time we log in.
|
||||
STORE_PATH = "account.json"
|
||||
|
||||
# URL to LOCAL anisette server. Set to None to use built-in Anisette generator instead (recommended)
|
||||
# IF YOU USE A PUBLIC SERVER, DO NOT COMPLAIN THAT YOU KEEP RUNNING INTO AUTHENTICATION ERRORS!
|
||||
# If you change this value, make sure to remove the account store file.
|
||||
ANISETTE_SERVER = None
|
||||
|
||||
# Path where Anisette libraries will be stored.
|
||||
# This is only relevant when using the built-in Anisette server.
|
||||
# It can be omitted (set to None) to avoid saving to disk,
|
||||
# but specifying a path is highly recommended to avoid downloading the bundle on every run.
|
||||
ANISETTE_LIBS_PATH = "ani_libs.bin"
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
async def fetch_reports(priv_key: str) -> int:
|
||||
key = KeyPair.from_b64(priv_key)
|
||||
acc = await get_account_async(
|
||||
RemoteAnisetteProvider(ANISETTE_SERVER),
|
||||
)
|
||||
acc = await get_account_async(STORE_PATH, ANISETTE_SERVER, ANISETTE_LIBS_PATH)
|
||||
|
||||
try:
|
||||
print(f"Logged in as: {acc.account_name} ({acc.first_name} {acc.last_name})")
|
||||
@@ -29,6 +38,9 @@ async def fetch_reports(priv_key: str) -> int:
|
||||
finally:
|
||||
await acc.close()
|
||||
|
||||
# Make sure to save account state when you're done!
|
||||
acc.to_json(STORE_PATH)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user