mirror of
https://github.com/iFargle/headscale-webui.git
synced 2026-01-05 20:23:52 +01:00
test
This commit is contained in:
19
helper.py
19
helper.py
@@ -14,19 +14,18 @@ def pretty_print_duration(duration):
|
||||
hours = (days * 24 + seconds // 3600)
|
||||
mins = (seconds % 3600) // 60
|
||||
secs = seconds % 60
|
||||
if days > 0: return str(days ) + " days ago" if days > 1 else str(days ) + " day ago"
|
||||
if days > 0: return str(days ) + " days ago" if days > 1 else str(days ) + " day ago"
|
||||
if hours > 0: return str(hours) + " hours ago" if hours > 1 else str(hours) + " hour ago"
|
||||
if mins > 0: return str(mins ) + " minutes ago" if mins > 1 else str(mins ) + " minute ago"
|
||||
return str(secs ) + " seconds ago" if secs >= 1 or secs == 0 else str(secs ) + " second ago"
|
||||
else:
|
||||
days, seconds = abs(duration.days), abs(duration.seconds)
|
||||
hours = (days * 24 + seconds // 3600)
|
||||
mins = (seconds % 3600) // 60
|
||||
secs = seconds % 60
|
||||
if days > 0: return "in "+str(days ) + " days" if days > 1 else str(days ) + " day"
|
||||
if hours > 0: return "in "+ str(hours) + " hours" if hours > 1 else str(hours) + " hour"
|
||||
if mins > 0: return "in "+ str(mins ) + " minutes" if mins > 1 else str(mins ) + " minute"
|
||||
return "in "+ str(secs ) + " seconds" if secs >= 1 or secs == 0 else str(secs ) + " second"
|
||||
days, seconds = abs(int(duration.days)), abs(int(duration.seconds))
|
||||
hours = (days * 24 + seconds // 3600)
|
||||
mins = (seconds % 3600) // 60
|
||||
secs = seconds % 60
|
||||
if days > 0: return "in "+str(days ) + " days" if days > 1 else str(days ) + " day"
|
||||
if hours > 0: return "in "+ str(hours) + " hours" if hours > 1 else str(hours) + " hour"
|
||||
if mins > 0: return "in "+ str(mins ) + " minutes" if mins > 1 else str(mins ) + " minute"
|
||||
return "in "+ str(secs ) + " seconds" if secs >= 1 or secs == 0 else str(secs ) + " second"
|
||||
def text_color_duration(duration):
|
||||
""" Prints a color based on duratioin (imported as seconds) """
|
||||
|
||||
|
||||
@@ -347,10 +347,14 @@ def thread_machine_content(machine, machine_content, idx):
|
||||
|
||||
expiry_parse = parser.parse(machine["expiry"])
|
||||
expiry_local = expiry_parse.astimezone(timezone)
|
||||
expiry_delta = (int(expiry_local) - int(local_time))*-1
|
||||
expiry_delta = expiry_local - local_time
|
||||
expiry_print = helper.pretty_print_duration(expiry_delta)
|
||||
expiry_time = str(expiry_local.strftime('%A %m/%d/%Y, %H:%M:%S'))+" "+str(timezone)+" ("+str(expiry_print)+")"
|
||||
|
||||
LOG.error("created_delta.seconds: "+created_delta.seconds)
|
||||
LOG.error("expiry_delta.seconds: "+expiry_delta.seconds)
|
||||
|
||||
|
||||
# Get the first 10 characters of the PreAuth Key:
|
||||
if machine["preAuthKey"]:
|
||||
preauth_key = str(machine["preAuthKey"]["key"])[0:10]
|
||||
|
||||
Reference in New Issue
Block a user