From beb0761e5f5711a4363262c74574ee2aa28b0b6e Mon Sep 17 00:00:00 2001 From: Joerg Raedler Date: Sun, 24 Mar 2019 19:55:13 +0100 Subject: [PATCH] add entries fullplatform, hostname, username and functions timestamp() and infostamp() to systemCfg --- CoTeTo/Controller.py | 11 ++++++++++- Generators/TestCustomEntries/Templates/Main.tmpl | 3 +-- Generators/TestJinja2/Templates/Main.jinja2 | 3 +-- Generators/TestMako/Templates/Main.mako | 3 +-- Generators/TestPostExec/Templates/Main.mako | 3 +-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CoTeTo/Controller.py b/CoTeTo/Controller.py index 5cc3838..15ec88c 100644 --- a/CoTeTo/Controller.py +++ b/CoTeTo/Controller.py @@ -9,11 +9,13 @@ import os.path import zipfile import logging +import platform +import getpass +import time import CoTeTo from CoTeTo.Generator import Generator from urllib.request import pathname2url - class Controller(object): """main controller of the code generation framework""" @@ -29,9 +31,16 @@ def __init__(self, generatorPath=[], logger='CoTeTo', logHandler=None, logLevel= self.logger.info('Starting CoTeTo.Controller from file %s, version %s', __file__, CoTeTo.__version__) # create system configuration dict - will be available to subsystems self.systemCfg = { + # static entries: 'platform': sys.platform, 'version': CoTeTo.__version__, 'path': os.path.dirname(os.path.realpath(__file__)), + 'fullplatform': platform.platform(), + 'hostname': platform.node(), + 'username': getpass.getuser(), + # functions: + 'timestamp': time.asctime, + 'infostamp': lambda: '%s | %s@%s | %s | CoTeTo %s' % (time.asctime(), getpass.getuser(), platform.node(), platform.platform(), CoTeTo.__version__) # need more here? } self.pathname2url = pathname2url diff --git a/Generators/TestCustomEntries/Templates/Main.tmpl b/Generators/TestCustomEntries/Templates/Main.tmpl index c215219..b7e43bf 100644 --- a/Generators/TestCustomEntries/Templates/Main.tmpl +++ b/Generators/TestCustomEntries/Templates/Main.tmpl @@ -1,7 +1,6 @@ # # CoTeTo -# Version: ${systemCfg['version']} -# Platform: ${systemCfg['platform']} +# Info: ${systemCfg['infostamp']()} # Path: ${systemCfg['path']} # Gen-Path: ${', '.join(systemCfg['generatorPath'])} # diff --git a/Generators/TestJinja2/Templates/Main.jinja2 b/Generators/TestJinja2/Templates/Main.jinja2 index e6e7481..a3812bd 100644 --- a/Generators/TestJinja2/Templates/Main.jinja2 +++ b/Generators/TestJinja2/Templates/Main.jinja2 @@ -1,7 +1,6 @@ # # CoTeTo -# Version: {{systemCfg['version']}} -# Platform: {{systemCfg['platform']}} +# Info: {{systemCfg['infostamp']()}} # Path: {{systemCfg['path']}} # Gen-Path: {{', '.join(systemCfg['generatorPath'])}} # diff --git a/Generators/TestMako/Templates/Main.mako b/Generators/TestMako/Templates/Main.mako index fed1400..f282ca2 100644 --- a/Generators/TestMako/Templates/Main.mako +++ b/Generators/TestMako/Templates/Main.mako @@ -1,7 +1,6 @@ # # CoTeTo -# Version: ${systemCfg['version']} -# Platform: ${systemCfg['platform']} +# Info: ${systemCfg['infostamp']()} # Path: ${systemCfg['path']} # Gen-Path: ${', '.join(systemCfg['generatorPath'])} # diff --git a/Generators/TestPostExec/Templates/Main.mako b/Generators/TestPostExec/Templates/Main.mako index fed1400..f282ca2 100644 --- a/Generators/TestPostExec/Templates/Main.mako +++ b/Generators/TestPostExec/Templates/Main.mako @@ -1,7 +1,6 @@ # # CoTeTo -# Version: ${systemCfg['version']} -# Platform: ${systemCfg['platform']} +# Info: ${systemCfg['infostamp']()} # Path: ${systemCfg['path']} # Gen-Path: ${', '.join(systemCfg['generatorPath'])} #