Mercurial > personal > weatherlog
comparison weatherlog/types.py @ 14:c01f9929ae38
Make logger and HTTP writer more general and resilient.
This makes the logger and HTTP writer more general, by removing
any dependency upon the exact data type they are writing.
They can now handle any type of BSON-serializable dict,
and track what they have sent by keeping track of the last *byte*,
not the last timestamp.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Tue, 15 Oct 2019 22:40:24 -0400 |
parents | 885bff085edf |
children | b5625b531d2d |
comparison
equal
deleted
inserted
replaced
13:4c81182eaa6b | 14:c01f9929ae38 |
---|---|
7 import pytz | 7 import pytz |
8 | 8 |
9 | 9 |
10 def _utc_now() -> datetime.datetime: | 10 def _utc_now() -> datetime.datetime: |
11 """utcnow, but timezone-aware.""" | 11 """utcnow, but timezone-aware.""" |
12 return datetime.datetime.utcnow().replace(tzinfo=pytz.UTC) | 12 return datetime.datetime.now(tz=pytz.UTC) |
13 | 13 |
14 | 14 |
15 @attr.s(frozen=True, slots=True) | 15 @attr.s(frozen=True, slots=True) |
16 class Reading(object): | 16 class Reading(object): |
17 """A single reading from a temperature/humidity sensor.""" | 17 """A single reading from a temperature/humidity sensor.""" |