From 47c324e905d5a055d794adff55f0e7da7e2b3b89 Mon Sep 17 00:00:00 2001 From: BennyThink Date: Wed, 12 Jan 2022 20:16:54 +0800 Subject: [PATCH] add exception for subprocess git version fix #35 --- .gitignore | 3 ++- ytdlbot/utils.py | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 77bac53..ea7f521 100644 --- a/.gitignore +++ b/.gitignore @@ -158,4 +158,5 @@ env/* ytdlbot/ytdl.session data/* upgrade_worker.sh -ytdl.session \ No newline at end of file +ytdl.session +reinforcement/* \ No newline at end of file diff --git a/ytdlbot/utils.py b/ytdlbot/utils.py index 22a506c..45513e0 100644 --- a/ytdlbot/utils.py +++ b/ytdlbot/utils.py @@ -7,10 +7,10 @@ __author__ = "Benny " +import contextlib import logging import os import pathlib -import signal import subprocess import time import uuid @@ -107,8 +107,9 @@ def current_time(ts=None): def get_revision(): - revision = subprocess.check_output("git -C ../ rev-parse --short HEAD".split()).decode("u8").replace("\n", "") - return revision + with contextlib.suppress(subprocess.SubprocessError): + return subprocess.check_output("git -C ../ rev-parse --short HEAD".split()).decode("u8").replace("\n", "") + return "unknown" def get_func_queue(func) -> int: