2025-02-07 15:21:15 +08:00
|
|
|
import random
|
|
|
|
|
import string
|
2024-12-13 15:58:25 +08:00
|
|
|
import uuid
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
from time import sleep
|
|
|
|
|
from src.libs.custom_logger import get_custom_logger
|
|
|
|
|
import os
|
|
|
|
|
import allure
|
|
|
|
|
|
|
|
|
|
logger = get_custom_logger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def attach_allure_file(file):
|
|
|
|
|
logger.debug(f"Attaching file {file}")
|
|
|
|
|
allure.attach.file(file, name=os.path.basename(file), attachment_type=allure.attachment_type.TEXT)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def delay(num_seconds):
|
|
|
|
|
logger.debug(f"Sleeping for {num_seconds} seconds")
|
|
|
|
|
sleep(num_seconds)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def gen_step_id():
|
|
|
|
|
return f"{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}__{str(uuid.uuid4())}"
|
2025-02-07 15:21:15 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate_log_prefix():
|
|
|
|
|
return "".join(random.choices(string.ascii_lowercase, k=4))
|
2025-02-13 11:07:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def to_index(n: int) -> list:
|
|
|
|
|
if n < 0:
|
|
|
|
|
raise ValueError("Input must be an unsigned integer (non-negative)")
|
|
|
|
|
return list(n.to_bytes(8, byteorder="big"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def to_app_id(n: int) -> list:
|
|
|
|
|
if n < 0:
|
|
|
|
|
raise ValueError("Input must be an unsigned integer (non-negative)")
|
|
|
|
|
return list(n.to_bytes(32, byteorder="big"))
|