Skip to content

Commit 5dcde3e

Browse files
pepegapepega
authored andcommitted
fix(lab03): fix Python linting issues - use datetime.UTC and sort imports
1 parent a85f145 commit 5dcde3e

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

app_python/app.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
DevOps Info Service
33
Main application module providing system information and health check.
44
"""
5+
56
import os
6-
import socket
77
import platform
8-
from datetime import datetime, timezone
8+
import socket
9+
from datetime import UTC, datetime
10+
911
from flask import Flask, jsonify, request
1012

1113
app = Flask(__name__)
@@ -16,7 +18,7 @@
1618
DEBUG = os.getenv('DEBUG', 'False').lower() == 'true'
1719

1820
# Application start time for uptime calculation
19-
START_TIME = datetime.now(timezone.utc)
21+
START_TIME = datetime.now(UTC)
2022

2123

2224
def get_system_info():
@@ -33,7 +35,7 @@ def get_system_info():
3335

3436
def get_uptime():
3537
"""Calculate application uptime."""
36-
delta = datetime.now(timezone.utc) - START_TIME
38+
delta = datetime.now(UTC) - START_TIME
3739
seconds = int(delta.total_seconds())
3840
hours = seconds // 3600
3941
minutes = (seconds % 3600) // 60
@@ -53,7 +55,7 @@ def get_runtime_info():
5355
return {
5456
'uptime_seconds': uptime['seconds'],
5557
'uptime_human': uptime['human'],
56-
'current_time': datetime.now(timezone.utc).isoformat(),
58+
'current_time': datetime.now(UTC).isoformat(),
5759
'timezone': 'UTC'
5860
}
5961

@@ -118,7 +120,7 @@ def health():
118120
"""
119121
response = {
120122
'status': 'healthy',
121-
'timestamp': datetime.now(timezone.utc).isoformat(),
123+
'timestamp': datetime.now(UTC).isoformat(),
122124
'uptime_seconds': get_uptime()['seconds']
123125
}
124126

0 commit comments

Comments
 (0)