~athorp96/energy-monitor

c17a7d070f8bfc95248f37ab65605afbcedb4415 — Andrew Thorp 2 months ago 9e4a033
fix: fix context manager, verbosity bugs
3 files changed, 5 insertions(+), 4 deletions(-)

M harmon-e
M lib/__pycache__/circular_buffer.cpython-310.pyc
M lib/circular_buffer.py
M harmon-e => harmon-e +4 -3
@@ 3,7 3,7 @@
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
import datetime as dt
import serial
from enum import Enum
from enum import IntEnum
import sys
import math
import time


@@ 15,7 15,7 @@ from lib.circular_buffer import CircularBuffer
from lib.reading import Reading


class Verbosity(Enum):
class Verbosity(IntEnum):
    NONE = 0
    VERBOSE = 1
    ALL = 2


@@ 83,9 83,10 @@ class Receiver:
            timeout=1,
        )

    def __enter__(self):
    def __enter__(self) -> "Receiver":
        self._start_time = dt.datetime.now()
        self.vcc = self._handshake()
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        duration = dt.datetime.now() - self._start_time

M lib/__pycache__/circular_buffer.cpython-310.pyc => lib/__pycache__/circular_buffer.cpython-310.pyc +0 -0
M lib/circular_buffer.py => lib/circular_buffer.py +1 -1
@@ 29,7 29,7 @@ class CircularBuffer(t.Generic[T]):
        self._full = False

    @classmethod
    def from_buffer(buff: list[T]) -> "CircularBuffer":
    def from_buffer(cls, buff: list[T]) -> "CircularBuffer":
        self = CircularBuffer[T](len(buff))
        self._buffer = buff
        self._front = 0