import subprocess def git_describe(request) -> str: try: git_describe = subprocess.check_output( ["git", "describe", "--always"], stderr=subprocess.STDOUT ).decode() except subprocess.CalledProcessError as e: print("Exception on process, rc=", e.returncode, "output=", e.output) git_describe = "" try: git_date = subprocess.check_output( ["git", "show", "-s", r"--format=%cd", r"--date=format:%d-%m-%Y"], stderr=subprocess.STDOUT ).decode() except subprocess.CalledProcessError as e: print("Exception on process, rc=", e.returncode, "output=", e.output) git_date = "" return { "git_describe": git_describe, "git_date": git_date }