From 136c862df8cf8e8f418bc189a8bccb715c5264ba Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Mon, 22 Jan 2024 13:44:29 +0300 Subject: [PATCH] fix: modification date of MANIFEST.MF in war file is build date Signed-off-by: Mustafa Baser --- setup_app/utils/printVersion.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/setup_app/utils/printVersion.py b/setup_app/utils/printVersion.py index 28e5b3342..a10da3f2d 100644 --- a/setup_app/utils/printVersion.py +++ b/setup_app/utils/printVersion.py @@ -9,6 +9,7 @@ import ssl import json import argparse +import datetime try: from urllib.request import urlopen @@ -36,8 +37,9 @@ def get_latest_commit(service, branch): def get_war_info(war_fn): retDict = {'title':'', 'version':'', 'build':'', 'buildDate':'', 'branch':''} - war_zip = zipfile.ZipFile(war_fn,"r") - menifest = war_zip.read('META-INF/MANIFEST.MF') + war_zip = zipfile.ZipFile(war_fn, 'r') + menifest_fn = 'META-INF/MANIFEST.MF' + menifest = war_zip.read(menifest_fn) for l in menifest.splitlines(): ls = l.strip().decode('utf-8') @@ -51,16 +53,10 @@ def get_war_info(war_fn): branch = branch.split('/')[1] retDict['branch'] = branch - - for f in war_zip.filelist: - if f.filename.startswith('META-INF/maven/org.gluu') and f.filename.endswith('pom.properties'): - pom_prop = war_zip.read(f.filename) - for l in pom_prop.splitlines(): - build_date = re.findall("\w{3}\s\w{3}\s{1,2}\w{1,2}\s\w{2}:\w{2}:\w{2}\s[+\w]{3}\s\w{4}", l.decode('utf-8')) - if build_date: - retDict['buildDate'] = build_date[0] - break + menifest_info = war_zip.getinfo(menifest_fn) + retDict['buildDate'] = str(datetime.datetime(*menifest_info.date_time)) + return retDict