Python 3.9 friendly UTC timezone.

This commit is contained in:
Goran Peretin
2024-06-13 14:26:10 +02:00
parent 78215ac55e
commit a6f54c8523
2 changed files with 5 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
from datetime import UTC, datetime
from datetime import datetime, timezone
from typing import Optional
from pydantic import BaseModel, Field
@@ -96,13 +96,13 @@ class Executor(BaseAgent):
self.next_state.action = f'Skip "{cmd_name}"'
return AgentResponse.done(self)
started_at = datetime.now(UTC)
started_at = datetime.now(timezone.utc)
log.info(f"Running command `{cmd}` with timeout {timeout}s")
status_code, stdout, stderr = await self.process_manager.run_command(cmd, timeout=timeout)
llm_response = await self.check_command_output(cmd, timeout, stdout, stderr, status_code)
duration = (datetime.now(UTC) - started_at).total_seconds()
duration = (datetime.now(timezone.utc) - started_at).total_seconds()
self.complete()
self.next_state.action = f'Run "{cmd_name}"'

View File

@@ -1,11 +1,11 @@
from datetime import UTC, datetime
from datetime import datetime, timezone
from typing import Optional
from pydantic import BaseModel, Field
class ExecLog(BaseModel):
started_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
started_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
duration: float = Field(description="The duration of the command/process run in seconds")
cmd: str = Field(description="The full command (as executed in the shell)")
cwd: str = Field(description="The working directory for the command (relative to project root)")