fix python 3.8 compat for edoxid calendar sync
apache/airflow:2.7.1 base image ships Python 3.8, which doesn't have zoneinfo (3.9+) and can't evaluate `X | Y` / list[X] type hints at runtime (3.10+). Add `from __future__ import annotations` everywhere and swap zoneinfo -> pytz (already a dependency in this repo).
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import date, datetime
|
||||
|
||||
import pymysql
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
from email.mime.text import MIMEText
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from datetime import datetime, timedelta
|
||||
from zoneinfo import ZoneInfo
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import pytz
|
||||
from google.auth.transport.requests import Request
|
||||
from google.oauth2.credentials import Credentials
|
||||
from googleapiclient.discovery import build
|
||||
@@ -8,7 +10,7 @@ from googleapiclient.errors import HttpError
|
||||
|
||||
from scripts.edoxid_calendar_config import GoogleConfig
|
||||
|
||||
JAKARTA_TZ = ZoneInfo("Asia/Jakarta")
|
||||
JAKARTA_TZ = pytz.timezone("Asia/Jakarta")
|
||||
|
||||
TYPE_LABELS = {
|
||||
1: "Seminar Proposal",
|
||||
@@ -34,7 +36,9 @@ def get_schedule_datetime(submission: dict) -> datetime:
|
||||
schedule = submission["schedule"]
|
||||
if isinstance(schedule, str):
|
||||
schedule = datetime.fromisoformat(schedule)
|
||||
return schedule.replace(tzinfo=JAKARTA_TZ)
|
||||
if schedule.tzinfo is not None:
|
||||
return schedule
|
||||
return JAKARTA_TZ.localize(schedule)
|
||||
|
||||
|
||||
def get_type_label(submission: dict) -> str:
|
||||
@@ -50,8 +54,8 @@ def format_indonesian_date(date: datetime) -> str:
|
||||
def build_description(submission: dict) -> str:
|
||||
schedule = get_schedule_datetime(submission)
|
||||
type_label = get_type_label(submission)
|
||||
pembimbing = [v for v in submission["verificators"] if v["type"] == "Pembimbing"]
|
||||
penguji = [v for v in submission["verificators"] if v["type"] == "Penguji"]
|
||||
pembimbing = [v["name"] for v in submission["verificators"] if v["type"] == "Pembimbing"]
|
||||
penguji = [v["name"] for v in submission["verificators"] if v["type"] == "Penguji"]
|
||||
|
||||
lines = [
|
||||
f"UNDANGAN {type_label.upper()} SECARA LURING",
|
||||
@@ -69,10 +73,10 @@ def build_description(submission: dict) -> str:
|
||||
"",
|
||||
]
|
||||
|
||||
for i, v in enumerate(pembimbing, start=1):
|
||||
lines.append(f"📕 Pembimbing {i} : {v['name']}")
|
||||
for i, v in enumerate(penguji, start=1):
|
||||
lines.append(f"📒 Penguji {i} : {v['name']}")
|
||||
for i, name in enumerate(pembimbing, start=1):
|
||||
lines.append(f"📕 Pembimbing {i} : {name}")
|
||||
for i, name in enumerate(penguji, start=1):
|
||||
lines.append(f"📒 Penguji {i} : {name}")
|
||||
|
||||
lines += [
|
||||
"",
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import sqlite3
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
import pytz
|
||||
|
||||
from scripts.edoxid_calendar_config import (
|
||||
get_db_config,
|
||||
@@ -22,7 +25,7 @@ from scripts.edoxid_calendar_state_store import StateStore
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
JAKARTA_TZ = ZoneInfo("Asia/Jakarta")
|
||||
JAKARTA_TZ = pytz.timezone("Asia/Jakarta")
|
||||
|
||||
# Toleransi jendela waktu untuk cek reminder — harus >= interval polling DAG (5 menit)
|
||||
# supaya tidak ada window yang "kelewat" di antara 2 run.
|
||||
|
||||
Reference in New Issue
Block a user