From ef5d4bc57962d260d292ba7a13ffd4d7494baeb0 Mon Sep 17 00:00:00 2001 From: Izalia Mae Date: Wed, 16 Nov 2022 10:41:00 -0500 Subject: [PATCH] only fetch commit hash if in running from git repo --- relay/__main__.py | 2 +- relay/views.py | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/relay/__main__.py b/relay/__main__.py index 3280f12..8ed335a 100644 --- a/relay/__main__.py +++ b/relay/__main__.py @@ -1,4 +1,4 @@ -from .manage import main +from relay.manage import main if __name__ == '__main__': diff --git a/relay/views.py b/relay/views.py index e427a1f..c069c68 100644 --- a/relay/views.py +++ b/relay/views.py @@ -2,6 +2,8 @@ import logging import subprocess import traceback +from pathlib import Path + from . import __version__, misc from .http_debug import STATS from .misc import Message, Response, WKNodeinfo @@ -9,13 +11,16 @@ from .processors import run_processor routes = [] +version = __version__ -try: - commit_label = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip().decode('ascii') - version = f'{__version__} {commit_label}' -except: - version = __version__ +if Path(__file__).parent.parent.joinpath('.git').exists(): + try: + commit_label = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip().decode('ascii') + version = f'{__version__} {commit_label}' + + except: + pass def register_route(method, path):