debugtalk.py
3.1 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import random
import string
import time,datetime
from urllib import parse
from helpfunc.login_func import *
# from helpfunc.pg_db_func import *
from helpfunc.db_func import *
from helpfunc.header_func import *
from random import randint
# from helpfunc.pg_app_db_func import *
from datetime import date, timedelta
import datetime
from helpfunc.cal_func import *
def sleep(n_secs):
time.sleep(n_secs)
def convert_to_string(value):
return str(value)
def get_nowtime():
return time.strftime("%Y%m%d%H%M%S",time.localtime(time.time()))
def get_today():
now_today = datetime.datetime.now()
str_time = now_today.strftime("%Y-%m-%d")
return str_time
def get_tomorrow():
tomorrow = (date.today() + timedelta(days=1)).strftime("%Y-%m-%d")
return tomorrow
def get_second():
curr_time = datetime.datetime.now()
return curr_time.second
def create_channel(num):
channel = []
for i in range(num+1):
channel.append(i)
return channel
def get_minute():
i = datetime.datetime.now()
return i.minute
def create_phone_number(num):
phone_number = []
for i in range(num):
number = random.randint(0,9)
phone_number.append('1%d%d%07d'%(get_minute(),number+1,number))
return phone_number
def getMonth():
year = str(datetime.date.today().year)
d = datetime.date.today()
month = '%02d' % d.month
if month in ['01', '03', '05', '07', '08', '10', '12']:
s = str("-01 00:00:00")
e = str("-31 23:59:59")
startTime = year + "-" + str(month) + s
endTime = year + "-" + str(month) + e
list = [startTime, endTime]
return list
elif month == '02':
s = str("-01 00:00:00")
e = str("-28 23:59:59")
startTime = year + "-" + str(month) + s
endTime = year + "-" + str(month) + e
list = [startTime, endTime]
return list
else:
s = str("-01 00:00:00")
e = str("-30 23:59:59")
startTime = year + "-" + str(month) + s
endTime = year + "-" + str(month) + e
list = [startTime, endTime]
return list
list_time = getMonth()
def get_starTimestamp():
return int(time.mktime(time.strptime(list_time[0], '%Y-%m-%d %H:%M:%S'))*1000)
def get_endTimestamp():
return int(time.mktime(time.strptime(list_time[1], '%Y-%m-%d %H:%M:%S'))*1000)
def get_January_timestamp():
return int(time.mktime(time.strptime('2020-04-01 00:00:00', '%Y-%m-%d %H:%M:%S'))*1000)
def get_Decembe_timestamp():
return int(time.mktime(time.strptime('2021-3-31 23:59:59', '%Y-%m-%d %H:%M:%S'))*1000)
#获取secret用于子系统单点登录
def get_secret(url):
urllist = url.split('code=',1)
code = urllist[1]
de_code = parse.unquote(code)
return de_code
def get_stringcode(n):
"""
随机生成n位数字符串
:param n:
:return:
"""
ran_str = ''.join(random.sample(string.ascii_letters + string.digits, n))
return ran_str
def get_randint(value1, value2):
return randint(value1, value2)
def convert_to_string(value):
return str(value)
def convert_to_int(value):
return int(value)