2023-11-17 08:47:22 +02:00
|
|
|
from time import sleep
|
|
|
|
|
from src.libs.custom_logger import get_custom_logger
|
2023-11-01 16:44:42 +02:00
|
|
|
import os
|
2023-11-01 14:02:29 +02:00
|
|
|
import base64
|
2023-11-01 16:44:42 +02:00
|
|
|
import allure
|
|
|
|
|
|
2023-11-17 08:47:22 +02:00
|
|
|
logger = get_custom_logger(__name__)
|
2023-11-01 14:02:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def bytes_to_hex(byte_array):
|
|
|
|
|
return "".join(format(byte, "02x") for byte in byte_array)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def to_base64(input_data):
|
|
|
|
|
if isinstance(input_data, str):
|
|
|
|
|
input_bytes = input_data.encode()
|
|
|
|
|
elif isinstance(input_data, int):
|
|
|
|
|
input_bytes = str(input_data).encode()
|
|
|
|
|
elif isinstance(input_data, bytes):
|
|
|
|
|
input_bytes = input_data
|
|
|
|
|
else:
|
|
|
|
|
input_bytes = str(input_data).encode()
|
|
|
|
|
base64_encoded = base64.b64encode(input_bytes)
|
|
|
|
|
return base64_encoded.decode()
|
2023-11-01 16:44:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def attach_allure_file(file):
|
2023-11-17 08:47:22 +02:00
|
|
|
logger.debug(f"Attaching file {file}")
|
2023-11-01 16:44:42 +02:00
|
|
|
allure.attach.file(file, name=os.path.basename(file), attachment_type=allure.attachment_type.TEXT)
|
2023-11-17 08:47:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def delay(num_seconds):
|
|
|
|
|
logger.debug(f"Sleeping for {num_seconds} seconds")
|
|
|
|
|
sleep(num_seconds)
|