fix: replace deprecated utcnow() with datetime.now(timezone.utc)
Deploy via Portainer / deploy (push) Successful in 0s
Deploy via Portainer / deploy (push) Successful in 0s
This commit is contained in:
Binary file not shown.
@@ -4,7 +4,7 @@ try:
|
|||||||
import requests as _requests
|
import requests as _requests
|
||||||
except ImportError:
|
except ImportError:
|
||||||
_requests = None
|
_requests = None
|
||||||
from datetime import datetime, timedelta, date as date_cls
|
from datetime import datetime, timedelta, date as date_cls, timezone
|
||||||
from authlib.integrations.flask_client import OAuth
|
from authlib.integrations.flask_client import OAuth
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@@ -1938,7 +1938,7 @@ def calendar_ics():
|
|||||||
ORDER BY cb.date''').fetchall()
|
ORDER BY cb.date''').fetchall()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
now_str = datetime.utcnow().strftime('%Y%m%dT%H%M%SZ')
|
now_str = datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%SZ')
|
||||||
lines = [
|
lines = [
|
||||||
'BEGIN:VCALENDAR',
|
'BEGIN:VCALENDAR',
|
||||||
'VERSION:2.0',
|
'VERSION:2.0',
|
||||||
@@ -2044,8 +2044,8 @@ def _ha_sync_once():
|
|||||||
"SELECT id, name, ha_entity_prefix FROM printers "
|
"SELECT id, name, ha_entity_prefix FROM printers "
|
||||||
"WHERE ha_entity_prefix IS NOT NULL AND ha_entity_prefix != ''"
|
"WHERE ha_entity_prefix IS NOT NULL AND ha_entity_prefix != ''"
|
||||||
).fetchall()
|
).fetchall()
|
||||||
now_iso = datetime.utcnow().isoformat()
|
now_iso = datetime.now(timezone.utc).replace(tzinfo=None).isoformat()
|
||||||
window = (datetime.utcnow() + timedelta(minutes=30)).isoformat()
|
window = (datetime.now(timezone.utc).replace(tzinfo=None) + timedelta(minutes=30)).isoformat()
|
||||||
for p in printers:
|
for p in printers:
|
||||||
prefix = p['ha_entity_prefix']
|
prefix = p['ha_entity_prefix']
|
||||||
ha_status = states.get(f'sensor.{prefix}_etat_de_l_impression', 'unknown')
|
ha_status = states.get(f'sensor.{prefix}_etat_de_l_impression', 'unknown')
|
||||||
|
|||||||
Reference in New Issue
Block a user