From f49afe55c75d3ed0288ceda6bf79b38a0550054c Mon Sep 17 00:00:00 2001 From: AHReccese Date: Fri, 19 Jan 2024 23:49:26 +0330 Subject: [PATCH] add `is_platform_linux` & `get_random_name` utility function --- reserver/util.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 reserver/util.py diff --git a/reserver/util.py b/reserver/util.py new file mode 100644 index 0000000..d7b8199 --- /dev/null +++ b/reserver/util.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +"""Utility functions.""" + +from platform import system +from hashlib import sha256 +from time import time + +def is_platform_linux(): + """ + Check whether current platform is linux or not. + + :return: bool + """ + return system() == "Linux" + +def get_random_name(): + """ + Generate a random str based on current timestamp. + + :return: str + """ + return sha256(str(time()).encode("utf-8")).hexdigest() \ No newline at end of file