Spaces:
Runtime error
Runtime error
File size: 1,811 Bytes
a07ed46 |
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
import time
import json
def get_time_utc(zone ,delay=0):
loc_time = time.gmtime(time.time() + delay + zone * 60 * 60)
return time.strftime("%Y-%m-%d %H:%M:%S",loc_time)
def clear_dict(d):
if d is None:
return None
elif isinstance(d, list):
return list(filter(lambda x: x is not None, map(clear_dict, d)))
elif not isinstance(d, dict):
return d
else:
r = dict(
filter(lambda x: x[1] is not None,
map(lambda x: (x[0], clear_dict(x[1])),
d.items())))
if not bool(r):
return None
return r
def print_env(server_port=6006, sleep=3):
print("")
print("")
print("###########################################")
print("environment variable start-----------------------------------")
print("###########################################")
print("")
print("server_port: " + str(server_port))
print("")
print("###########################################")
print("Please check the environment variables (the program will start in 3 seconds) ββββββββββββββββββββββββββββββββ")
print("###########################################")
print("")
print("")
time.sleep(sleep)
return
def print_log(request, respose, time_start=0):
print("______________________________________________")
print("request" + ":::\n" + json.dumps(clear_dict(request.__dict__))) # class dict convert to json
print("respose" + ":::")
if isinstance(respose, dict) or isinstance(respose,list):
print(respose)
else:
print(respose.__dict__)
print("cost:::\n" + str(time.time() - time_start) + "s")
print("finish:::\n" + get_time_utc(-8))
return |