Trying some str formatting
[arvados.git] / sdk / python / arvados_version.py
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: Apache-2.0
4
5 import subprocess
6 import time
7
8 class VersionInfoFromGit():
9     """Return arvados version from git
10     """
11     def git_latest_tag(self):
12         gitinfo = subprocess.check_output(
13             ['git', 'describe', '--abbrev=0']).strip()
14         return str(gitinfo.decode('utf-8'))
15
16     def git_timestamp_tag(self):
17         gitinfo = subprocess.check_output(
18             ['git', 'log', '--first-parent', '--max-count=1',
19              '--format=format:%ct', '.']).strip()
20         return str(time.strftime('.%Y%m%d%H%M%S', time.gmtime(int(gitinfo))))