Skip to content

Commit 4c164df

Browse files
Added Time in both brief and detailed output
Signed-off-by: alokgoswami-ag <[email protected]>
1 parent 26d9729 commit 4c164df

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

monitor.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def fetch_build_time(build):
5555

5656
try:
5757
response = requests.get(url, verify=False, timeout=15)
58+
<<<<<<< HEAD
5859
if response.status_code == 200:
5960
buildtime = json.loads(response.text)
6061
timestamp_str = buildtime["metadata"]["creationTimestamp"]
@@ -73,6 +74,24 @@ def fetch_build_time(build):
7374
else:
7475
return 'ERROR'
7576

77+
=======
78+
response.raise_for_status() # Raise exception for non-200 responses
79+
80+
buildtime = response.json() # Directly parse JSON
81+
timestamp_str = buildtime["metadata"]["creationTimestamp"]
82+
83+
# Convert timestamp to datetime object (UTC)
84+
utc_time = datetime.strptime(timestamp_str, "%Y-%m-%dT%H:%M:%SZ")
85+
86+
# Convert UTC to IST (UTC +5:30)
87+
ist_time = utc_time + timedelta(hours=5, minutes=30)
88+
89+
# Extract date and time separately
90+
ist_date = ist_time.strftime("%Y-%m-%d") # YYYY-MM-DD
91+
ist_time_formatted = ist_time.strftime("%H:%M") # HH:MM (without seconds)
92+
93+
return ist_date, ist_time_formatted # Returning both date and time
94+
>>>>>>> 2464102 (Added Time in both brief and detailed output)
7695

7796
except requests.Timeout:
7897
return "Request timed out", None
@@ -1323,7 +1342,11 @@ def get_detailed_job_info(build_list,prow_ci_name,zone=None):
13231342
date,time=fetch_build_time(build)
13241343

13251344
print(i,"Job link:"+constants.JOB_LINK_URL+build)
1345+
<<<<<<< HEAD
13261346
print("Build start time: "+time +" "+date)
1347+
=======
1348+
print("Build started time: "+time +" "+date)
1349+
>>>>>>> 2464102 (Added Time in both brief and detailed output)
13271350

13281351
build_status = check_job_status(build)
13291352
sensitive_info_expose_status=check_if_sensitive_info_exposed(build)

0 commit comments

Comments
 (0)