From 486ee25708a247a5c320e1058ffb5aa26537effd Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 22 Jan 2018 14:00:16 +0100 Subject: [PATCH] wiki: log build start/stop time, command line, RAM, and processor count --- fdroidserver/build.py | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/fdroidserver/build.py b/fdroidserver/build.py index f3b25c9c..a431dd52 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -17,13 +17,13 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import sys import os import shutil import glob import subprocess import re import resource +import sys import tarfile import traceback import time @@ -1027,12 +1027,13 @@ def parse_commandline(): options = None config = None buildserverid = None -starttime = common.get_wiki_timestamp() +fdroidserverid = None +start_timestamp = time.gmtime() def main(): - global options, config, buildserverid + global options, config, buildserverid, fdroidserverid options, parser = parse_commandline() @@ -1269,7 +1270,7 @@ def main(): newpage = site.Pages[lastbuildpage] with open(os.path.join('tmp', 'fdroidserverid')) as fp: fdroidserverid = fp.read().rstrip() - txt = "* build session started at " + starttime + '\n' \ + txt = "* build session started at " + common.get_wiki_timestamp(start_timestamp) + '\n' \ + "* this build started at " + build_starttime + '\n' \ + "* this build completed at " + common.get_wiki_timestamp() + '\n' \ + '* fdroidserverid: [https://gitlab.com/fdroid/fdroidserver/commit/' \ @@ -1338,6 +1339,35 @@ def main(): logging.info(ngettext("{} build failed", "{} builds failed", len(failed_apps)).format(len(failed_apps))) + if options.wiki: + wiki_page_path = 'build_' + time.strftime('%s', start_timestamp) + newpage = site.Pages[wiki_page_path] + txt = '' + txt += "* command line: %s\n" % ' '.join(sys.argv) + txt += "* started at %s\n" % common.get_wiki_timestamp(start_timestamp) + txt += "* completed at %s\n" % common.get_wiki_timestamp() + if buildserverid: + txt += ('* buildserverid: [https://gitlab.com/fdroid/fdroidserver/commit/{id} {id}]\n' + .format(id=buildserverid)) + if fdroidserverid: + txt += ('* fdroidserverid: [https://gitlab.com/fdroid/fdroidserver/commit/{id} {id}]\n' + .format(id=fdroidserverid)) + if os.cpu_count(): + txt += "* host processors: %d\n" % os.cpu_count() + if os.path.isfile('/proc/meminfo') and os.access('/proc/meminfo', os.R_OK): + with open('/proc/meminfo') as fp: + for line in fp: + m = re.search(r'MemTotal:\s*([0-9].*)', line) + if m: + txt += "* host RAM: %s\n" % m.group(1) + break + txt += "* successful builds: %d\n" % len(build_succeeded) + txt += "* failed builds: %d\n" % len(failed_apps) + txt += "\n\n" + newpage.save(txt, summary='Run log') + newpage = site.Pages['build'] + newpage.save('#REDIRECT [[' + wiki_page_path + ']]', summary='Update redirect') + # hack to ensure this exits, even is some threads are still running sys.stdout.flush() sys.stderr.flush() -- 2.30.2