-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsso.py
executable file
·35 lines (26 loc) · 1021 Bytes
/
sso.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/python3
import os
import sys
import time
import datetime
import struct
from time import mktime
def gettime(myTime):
print(datetime(myTime.hour))
return
try:
awsCredsExpiry = int(os.environ['AWS_CREDS_EXPIRY'])
except:
print("ERROR: Try to connect to AWS before you use this script...")
sys.exit(1)
awsCredsExpiryTimestamp = time.strftime('%Y-%m-%d %a %H:%M:%S', time.localtime(awsCredsExpiry))
currentTimestamp=time.strftime('%Y-%m-%d %a %H:%M:%S', time.localtime())
currentTime = time.time()
delta = round((awsCredsExpiry - currentTime), 0)
if delta <= 0:
print("\nCredentials have expired on: {} :(".format(awsCredsExpiryTimestamp))
else:
print("Current time: {}".format(currentTimestamp))
print("Credentials will expire on: {}".format(awsCredsExpiryTimestamp))
print("You still have some time left: {}".format(str(datetime.timedelta(seconds=delta))))
print("You are in region : {}".format(os.environ['AWS_DEFAULT_REGION']))