Skip to content

Commit e95b549

Browse files
committed
fix: Replace datetime.UTC with timezone.utc for Python 3.9 compatibility
datetime.UTC was introduced in Python 3.11. Using timezone.utc instead for compatibility with Python 3.9 and 3.10.
1 parent 262583a commit e95b549

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
runs-on: ubuntu-latest
3232
strategy:
3333
matrix:
34-
python-version: ["3.9", "3.10", "3.11", "3.12"]
34+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
3535

3636
steps:
3737
- uses: actions/checkout@v4

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img src="tests/mcphawk_logo.png" alt="MCPHawk Logo" height="130">
33

44
[![CI](https://github.com/tech4242/mcphawk/actions/workflows/ci.yml/badge.svg)](https://github.com/tech4242/mcphawk/actions/workflows/ci.yml)
5-
[![Python](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
5+
[![Python](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
66
[![FastAPI](https://img.shields.io/badge/FastAPI-005571?style=flat&logo=fastapi)](https://fastapi.tiangolo.com/)
77
[![Vue.js](https://img.shields.io/badge/vue.js-3.x-brightgreen.svg)](https://vuejs.org/)
88
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

mcphawk/logger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
import sqlite3
3-
from datetime import UTC, datetime
3+
from datetime import datetime, timezone
44
from pathlib import Path
55
from typing import Any
66

@@ -58,7 +58,7 @@ def log_message(entry: dict[str, Any]) -> None:
5858
direction (str): 'incoming', 'outgoing', or 'unknown'
5959
message (str)
6060
"""
61-
timestamp = entry.get("timestamp", datetime.now(tz=UTC))
61+
timestamp = entry.get("timestamp", datetime.now(tz=timezone.utc))
6262
conn = sqlite3.connect(DB_PATH)
6363
cur = conn.cursor()
6464
cur.execute(

mcphawk/sniffer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import asyncio
22
import logging
33
import platform
4-
from datetime import UTC, datetime
4+
from datetime import datetime, timezone
55

66
# Suppress Scapy warnings before importing
77
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
@@ -48,7 +48,7 @@ def packet_callback(pkt):
4848
if decoded.startswith("{") and "jsonrpc" in decoded:
4949
logger.debug(f"Sniffer captured: {decoded}")
5050

51-
ts = datetime.now(tz=UTC)
51+
ts = datetime.now(tz=timezone.utc)
5252
src_port = pkt[TCP].sport if pkt.haslayer(TCP) else 0
5353
dst_port = pkt[TCP].dport if pkt.haslayer(TCP) else 0
5454

0 commit comments

Comments
 (0)