Coverage for sparkle/tools/general.py: 100%
6 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-05 14:48 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-05 14:48 +0000
1"""General tools for Sparkle."""
2import time
3import random
4import os
7def get_time_pid_random_string() -> str:
8 """Return a combination of time, Process ID, and random int as string.
10 Returns:
11 A random string composed of time, PID and a random positive integer value.
12 """
13 time_stamp = time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime(time.time()))
14 return f"{time_stamp}_{os.getpid()}_{int(random.getrandbits(32))}"