File size: 504 Bytes
1e9ebb3
 
 
 
 
 
 
 
 
 
 
 
7ccee96
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import datetime
import random
import os


def generate_temp_filename(folder='./outputs/', extension='png'):
    current_time = datetime.datetime.now()
    date_string = current_time.strftime("%Y-%m-%d")
    time_string = current_time.strftime("%Y-%m-%d_%H-%M-%S")
    random_number = random.randint(1000, 9999)
    filename = f"{time_string}_{random_number}.{extension}"
    result = os.path.join(folder, date_string, filename)
    return date_string, os.path.abspath(os.path.realpath(result)), filename