Skip to content

bendikrb/politikontroller-py

Repository files navigation

politikontroller-py

GitHub Release Python Versions PyPI Downloads Project Maintenance License Made with Love in Norway

Build Status Code coverage

Install

pip install politikontroller-py

Usage

Basic usage

from politikontroller_py import Client

client = Client.initialize("4790112233", "super-secret")

async def main():
    police_controls = await client.get_controls(63, 11)
    print(police_controls)

With account

from politikontroller_py import Client
from politikontroller_py.models import Account

# A valid registered user @ politikontroller.no
user = Account(
    username="4790112233",  # Include 2 digit prefix - or else DEFAULT_COUNTRY is assumed
    password="super-secret",
)

client = Client(user)

async def main():
    police_controls = await client.get_controls(63, 11)
    print(police_controls)

With session

from aiohttp import ClientSession
from politikontroller_py import Client

async def main():
    async with ClientSession() as session:
        client = Client.initialize("4790112233", "super-secret", session=session)
        police_controls = await client.get_controls(63, 11)
        print(police_controls)

CLI tool

$ politikontroller --help
Usage: politikontroller [OPTIONS] COMMAND [ARGS]...

  Connect to politikontroller.no and fetch data in a simple way.

  Username and password can be defined using env vars.

  POLITIKONTROLLER_USERNAME POLITIKONTROLLER_PASSWORD

Options:
  -u, --username TEXT  Username (i.e. phone number)  [required]
  -p, --password TEXT  Password  [required]
  --debug              Set logging level to DEBUG
  --help               Show this message and exit.

Commands:
  account-auth         activate account
  account-auth-sms     activate account by sms
  account-register     register new account
  account-send-sms     send activation sms
  check                server health check.
  exchange-points      exchange points (?)
  get-control          get details on a control.
  get-control-types    get a list of control types.
  get-controls         get a list of all active controls.
  get-controls-radius  get all active controls inside a radius.
  get-maps             get own maps.
  get-settings         get own settings.