Python
pip install bothyWheels are abi3 for CPython 3.9 or newer on Linux (x86_64, aarch64, armv7), macOS and Windows. The API is synchronous and thread-safe, and calls release the GIL.
import bothy, bothy.auth
grant = bothy.auth.device_login("client_tv.json") # once, on a board without a browsergrant.save("token.json") # readable only by youtokens = bothy.auth.TokenProvider("client_tv.json", bothy.auth.Grant.load("token.json"))
db = bothy.Database.open("robot.db", app_id="com.example.robot", remote=bothy.DriveRemote.folder("robot", tokens), p2p=True)db.init_or_join()
missions = db.collection("missions")missions.put("m1", {"goal": "dock", "speed": 0.5})missions.patch("m1", {"state": "accepted"})
db.start_auto_sync()for change in db.changes(timeout=30): # local and remote changes print(change.collection, change.id, change.remote)Signing in
Section titled “Signing in”- Boards without a browser:
bothy.auth.device_loginwith a “TVs and Limited Input devices” client prints a URL and a code to enter on a phone. It only grantsdrive.file, so useDriveRemote.folder. - Desktops:
bothy.auth.loopback_loginwith a “Desktop app” client opens the browser and can useDriveRemote.appdata. - Your own tokens: any callable
(force_refresh: bool) -> strworks astokens.
Encryption
Section titled “Encryption”db = bothy.Database.open(..., encrypt=True, password=pw) # the device that creates itdb = bothy.Database.open(..., password=pw) # devices that joinkey = db.export_key() # keep it to skip the passworddb = bothy.Database.open(..., key=key)Errors
Section titled “Errors”Every engine error is a bothy.BothyError, with one subclass per kind: OfflineError,
AuthRequiredError, WrongPasswordError, KeyRequiredError, InvalidInputError and so on.