Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -29,6 +29,8 @@ def get_status(credentials, instance_name):
|
|
29 |
return status, ip_address
|
30 |
|
31 |
def get_time_remaining(last_start_timestamp, run_duration_seconds):
|
|
|
|
|
32 |
run_duration_seconds = int(run_duration_seconds)
|
33 |
last_start_dt = parser.isoparse(last_start_timestamp)
|
34 |
end_run_dt = last_start_dt + timedelta(seconds=run_duration_seconds)
|
@@ -69,7 +71,7 @@ credentials = auth()
|
|
69 |
instance_info = get_server(credentials, instance_name)
|
70 |
status = instance_info['status']
|
71 |
ip_address = instance_info['networkInterfaces'][0]['accessConfigs'][0]['natIP'] if status == 'RUNNING' else None
|
72 |
-
max_run_duration = instance_info['scheduling']['maxRunDuration']['seconds']
|
73 |
last_start_timestamp = instance_info['lastStartTimestamp']
|
74 |
max_remaining_time = get_time_remaining(last_start_timestamp, max_run_duration)
|
75 |
|
|
|
29 |
return status, ip_address
|
30 |
|
31 |
def get_time_remaining(last_start_timestamp, run_duration_seconds):
|
32 |
+
if run_duration_seconds == -1:
|
33 |
+
return -1
|
34 |
run_duration_seconds = int(run_duration_seconds)
|
35 |
last_start_dt = parser.isoparse(last_start_timestamp)
|
36 |
end_run_dt = last_start_dt + timedelta(seconds=run_duration_seconds)
|
|
|
71 |
instance_info = get_server(credentials, instance_name)
|
72 |
status = instance_info['status']
|
73 |
ip_address = instance_info['networkInterfaces'][0]['accessConfigs'][0]['natIP'] if status == 'RUNNING' else None
|
74 |
+
max_run_duration = instance_info['scheduling']['maxRunDuration']['seconds'] if 'maxRunDuration' in instance_info['scheduling'] else -1
|
75 |
last_start_timestamp = instance_info['lastStartTimestamp']
|
76 |
max_remaining_time = get_time_remaining(last_start_timestamp, max_run_duration)
|
77 |
|