From e4a2de4f82e53d8b824c688d67a0543aa85f3dfd Mon Sep 17 00:00:00 2001 From: Pepe Barbe Date: Fri, 17 Aug 2012 10:35:17 -0500 Subject: [PATCH] Syntax changes necessary to make test-module work with Python 2.4 --- lib/ansible/utils.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/ansible/utils.py b/lib/ansible/utils.py index be66883889c..5680f613e0f 100644 --- a/lib/ansible/utils.py +++ b/lib/ansible/utils.py @@ -307,13 +307,18 @@ def _gitinfo(): result = None repo_path = os.path.join(os.path.dirname(__file__), '..', '..', '.git') if os.path.exists(repo_path): - with open(os.path.join(repo_path, "HEAD")) as f: - branch = f.readline().split('/')[-1].rstrip("\n") + f = open(os.path.join(repo_path, "HEAD")) + branch = f.readline().split('/')[-1].rstrip("\n") + f.close() branch_path = os.path.join(repo_path, "refs", "heads", branch) - with open(branch_path) as f: - commit = f.readline()[:10] + f = open(branch_path) + commit = f.readline()[:10] + f.close() 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, time.strftime("%Y/%m/%d %H:%M:%S", date), offset / -36) return result