mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #897 from elventear/utils_py24
Syntax changes necessary to make test-module work with Python 2.4
This commit is contained in:
commit
36944053b1
1 changed files with 10 additions and 5 deletions
|
@ -307,13 +307,18 @@ def _gitinfo():
|
||||||
result = None
|
result = None
|
||||||
repo_path = os.path.join(os.path.dirname(__file__), '..', '..', '.git')
|
repo_path = os.path.join(os.path.dirname(__file__), '..', '..', '.git')
|
||||||
if os.path.exists(repo_path):
|
if os.path.exists(repo_path):
|
||||||
with open(os.path.join(repo_path, "HEAD")) as f:
|
f = open(os.path.join(repo_path, "HEAD"))
|
||||||
branch = f.readline().split('/')[-1].rstrip("\n")
|
branch = f.readline().split('/')[-1].rstrip("\n")
|
||||||
|
f.close()
|
||||||
branch_path = os.path.join(repo_path, "refs", "heads", branch)
|
branch_path = os.path.join(repo_path, "refs", "heads", branch)
|
||||||
with open(branch_path) as f:
|
f = open(branch_path)
|
||||||
commit = f.readline()[:10]
|
commit = f.readline()[:10]
|
||||||
|
f.close()
|
||||||
date = time.localtime(os.stat(branch_path).st_mtime)
|
date = time.localtime(os.stat(branch_path).st_mtime)
|
||||||
offset = time.timezone if (time.daylight == 0) else time.altzone
|
if time.daylight == 0:
|
||||||
|
offset = time.timezone
|
||||||
|
else:
|
||||||
|
offset = time.altzone
|
||||||
result = "({0} {1}) last updated {2} (GMT {3:+04d})".format(branch, commit,
|
result = "({0} {1}) last updated {2} (GMT {3:+04d})".format(branch, commit,
|
||||||
time.strftime("%Y/%m/%d %H:%M:%S", date), offset / -36)
|
time.strftime("%Y/%m/%d %H:%M:%S", date), offset / -36)
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Reference in a new issue