Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM python:3.11-slim
FROM python:3.13-slim

WORKDIR /app
# Install all dependencies (including dev)
RUN pip install --no-cache-dir poetry
COPY pyproject.toml poetry.lock ./
COPY . ./
RUN poetry config virtualenvs.create false \
&& poetry install --no-root --no-interaction --no-ansi
&& poetry lock && poetry install --no-root --no-interaction --no-ansi

ENV PYTHONPATH="${PYTHONPATH}:/app"

CMD ["python"]
CMD ["python"]
36 changes: 34 additions & 2 deletions examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
import argparse
import json
import os
import time

from pycheckwatt import CheckwattManager
from pycheckwatt import CheckwattManager, CheckwattStateInfo


async def main(show_details=False):
username = os.getenv("CHECKWATT_USERNAME")
password = os.getenv("CHECKWATT_PASSWORD")

# create authinfo object to persist between sessions
state_info = CheckwattStateInfo()

# Create the async class
async with CheckwattManager(username, password) as check_watt_instance:
async with CheckwattManager(username, password, state_info) as check_watt_instance:
try:
# Login to EnergyInBalance and check kill switch
if await check_watt_instance.login():
Expand Down Expand Up @@ -112,6 +116,34 @@ async def main(show_details=False):
except Exception as e:
print(f"An error occurred: {e}")

# Do another session, re-using the state_info, and see if we re-use the JWT
async with CheckwattManager(username, password, state_info) as check_watt_instance:
try:
# Login to EnergyInBalance and check kill switch
if await check_watt_instance.login():
# Fetch customer detail
await check_watt_instance.get_customer_details()

# Do a sample
print("Customer Details\n================")
print(check_watt_instance.registered_owner)
except Exception as e:
print(f"An error occurred: {e}")

# one more time, get rid of token so we don't have to wait
state_info.jwt_token = ""
async with CheckwattManager(username, password, state_info) as check_watt_instance:
try:
# Login to EnergyInBalance and check kill switch
if await check_watt_instance.login():
# Fetch customer detail
await check_watt_instance.get_customer_details()

# Do a sample
print("Customer Details\n================")
print(check_watt_instance.registered_owner)
except Exception as e:
print(f"An error occurred: {e}")

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Checkwatt Information")
Expand Down
3 changes: 3 additions & 0 deletions examples/history_inject.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ async def main():
print("You need to update EIB_USERNAME/EIB_PASSWORD")
return

# create authinfo object to persist between sessions
state_info = CheckwattStateInfo()

async with CheckwattManager(EIB_USERNAME, EIB_PASSWORD, "cwTest") as cw:
try:
# Login to EnergyInBalance
Expand Down
967 changes: 598 additions & 369 deletions poetry.lock

Large diffs are not rendered by default.

Loading