Skip to content

Commit

Permalink
Merge pull request #311 from QuantumDancer/update-pyauditor-v0.2.0
Browse files Browse the repository at this point in the history
Update pyauditor to 0.2.0
  • Loading branch information
giffels authored Sep 28, 2023
2 parents 24cdb48 + 755c901 commit 886255e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ def get_cryptography_version():
"pydantic<2.0.0",
"asyncstdlib",
"typing_extensions",
"python-auditor==0.1.0",
"pytz",
"python-auditor==0.2.0",
"tzlocal",
*REST_REQUIRES,
],
Expand Down
8 changes: 4 additions & 4 deletions tardis/plugins/auditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import pyauditor

import datetime
import logging
import pytz
from tzlocal import get_localzone


Expand Down Expand Up @@ -83,13 +83,13 @@ async def notify(self, state: State, resource_attributes: AttributeDict) -> None
record.with_stop_time(
resource_attributes["updated"]
.replace(tzinfo=self._local_timezone)
.astimezone(pytz.utc)
.astimezone(datetime.timezone.utc)
)
try:
await self._client.update(record)
except RuntimeError as e:
if str(e).startswith(
"Reqwest Error: HTTP status client error (400 Bad Request)"
"Reqwest Error: HTTP status client error (404 Not Found)"
):
self.logger.debug(
f"Could not update record {record.record_id}, "
Expand Down Expand Up @@ -117,7 +117,7 @@ def construct_record(self, resource_attributes: AttributeDict):
resource_attributes["drone_uuid"],
resource_attributes["updated"]
.replace(tzinfo=self._local_timezone)
.astimezone(pytz.utc),
.astimezone(datetime.timezone.utc),
).with_meta(meta)

for resource, amount in self._resources[resource_attributes["site_name"]][
Expand Down
2 changes: 1 addition & 1 deletion tests/plugins_t/test_auditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def test_notify(self):

# test exception handling
self.client.update.side_effect = RuntimeError(
"Reqwest Error: HTTP status client error (400 Bad Request) "
"Reqwest Error: HTTP status client error (404 Not Found) "
"for url (http://127.0.0.1:8000/update)"
)
run_async(
Expand Down

0 comments on commit 886255e

Please sign in to comment.