47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
import time,datetime,random,os,sys,string
|
|
|
|
|
|
class Common():
|
|
|
|
def __init__(self):
|
|
self.timestamp = int(time.time())
|
|
self.Datetime = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
|
|
self.today_date = datetime.date.today().strftime('%Y-%m-%d')
|
|
self.rootpath = os.path.dirname(os.path.dirname(__file__))
|
|
|
|
def return_folder(self):
|
|
ReportPath = os.path.join(self.rootpath, 'YiMao/reports', str(self.Datetime)).replace("\\", "/")
|
|
if not os.path.exists(ReportPath):
|
|
os.makedirs(ReportPath)
|
|
return ReportPath + '/'
|
|
|
|
def delete_txt_files(self):
|
|
txtPath = os.path.join(self.rootpath, 'YiMao/ProcessData')
|
|
for root, dirs, files in os.walk(txtPath):
|
|
for file_name in files:
|
|
if file_name.endswith('.txt'):
|
|
file_path = os.path.join(root, file_name)
|
|
os.remove(file_path)
|
|
print(f"已删除: {file_path}")
|
|
|
|
def return_sission_id(self):
|
|
def generate_24_digit_random_integer():
|
|
timestamp = int(time.time() * 1000)
|
|
random_number = random.randint(0, 99999999999999)
|
|
combined_number = str(timestamp) + str(random_number)
|
|
if len(combined_number) >= 24:
|
|
return int(combined_number[:24])
|
|
else:
|
|
combined_number = combined_number.ljust(24, '0')
|
|
return int(combined_number)
|
|
random_integer = generate_24_digit_random_integer()
|
|
return random_integer
|
|
|
|
def return_timestamp(self):
|
|
timestamp_seconds = time.time()
|
|
timestamp_milliseconds = int(timestamp_seconds * 1000)
|
|
return str(timestamp_milliseconds)
|
|
|
|
|