From 3e5df40f0f14c6177264bc250bade24f2553e871 Mon Sep 17 00:00:00 2001 From: Dariusz Suchojad Date: Mon, 4 Dec 2023 11:27:24 +0100 Subject: [PATCH] GH #755 - Adding platforms to zato --version. --- code/.version.py | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/code/.version.py b/code/.version.py index a9efa6e2aa..fe64852157 100644 --- a/code/.version.py +++ b/code/.version.py @@ -10,22 +10,43 @@ import inspect import json import os +import platform from subprocess import PIPE, run as subprocess_run +# ################################################################################################################################ +# ################################################################################################################################ + # Cannot use built in __file__ because we are execfile'd _file = inspect.currentframe().f_code.co_filename +# ################################################################################################################################ +# ################################################################################################################################ + # Prepare all the directories needed curdir = os.path.dirname(os.path.abspath(_file)) release_info_dir = os.path.join(curdir, 'release-info') git_repo_dir = os.path.abspath(os.path.join(release_info_dir, '..')) +# ################################################################################################################################ +# ################################################################################################################################ + # # This is Zato version information # release = open(os.path.join(release_info_dir, 'release.json')).read() release = json.loads(release) +# ################################################################################################################################ +# ################################################################################################################################ + +platform_system = platform.system().lower() + +is_windows = 'windows' in platform_system +is_linux = 'linux' in platform_system # noqa: E272 + +# ################################################################################################################################ +# ################################################################################################################################ + # # This is last git commit ID. # @@ -33,7 +54,7 @@ # the latter may result in spurious pip errors, such as: # "error in zato-agent setup command: Distribution contains no modules or packages for namespace package 'zato'" # -git_command_date = ['git', 'log', '-1', "--pretty=%cd", "--date=format:%Y.%m.%d"] +git_command_date = ['git', 'log', '-1', '--pretty=%cd', '--date=format:%Y.%m.%d'] git_command_revision = ['git', 'rev-parse', '--short', 'HEAD'] try: @@ -49,11 +70,21 @@ revision = revision.strip() except Exception as e: - version = '3.2-nogit' + + if is_windows: + suffix = 'windows' + elif is_linux: + suffix = 'linux' + else: + suffix = platform_system + + version = f'3.2-nogit-{suffix}' else: + major = release['major'] minor = release['minor'] - version = '{}.{}.{}+rev.{}'.format(major, minor, date, revision) + + version = f'{major}.{minor}.{date}+rev.{revision}' # ################################################################################################################################ # ################################################################################################################################