debugtalk.py 2.2 KB
import random
import string
import time,datetime
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

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 create_phone_number(num):
    phone_number = []
    for i in range(num):
        number = random.randint(0,9)
        phone_number.append('1%d%d%08d'%(number,number+1,number+2))
    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)